Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify to help us with seeding and testing our application #12

Closed
pgwillia opened this issue Sep 3, 2021 · 0 comments
Closed

Modify to help us with seeding and testing our application #12

pgwillia opened this issue Sep 3, 2021 · 0 comments

Comments

@pgwillia
Copy link
Member

pgwillia commented Sep 3, 2021

I'm thinking about modifying acts_as_rdfable to help us with this.

Any of the add/remove/delete methods in ActsAsRdfable::MigrationAnnotations::RdfConfig could create/update a db/seeds/rdf_annotations.rb file in our application (maybe seed_dump) with the current dump of the database.

# lib/acts_as_rdfable/migration_annotations.rb
def dump_rdf_annotations
  SeedDump.dump(RdfAnnotation, file: 'db/seeds/rdf_annotations.rb')
end
# db/seeds/rdf_annotations.rb
RdfAnnotation.create!([
  {table: "items", column: "title", predicate: "http://purl.org/dc/terms/title"},
  {table: "items", column: "fedora3_uuid", predicate: "http://terms.library.ualberta.ca/fedora3UUID"},
  {table: "items", column: "depositor", predicate: "http://terms.library.ualberta.ca/depositor"},
...
  {table: "items", column: "alternative_title", predicate: "http://purl.org/dc/terms/alternative"}
])

We could check this in along with our db/schema.rb. Then load it from our db/seeds.rb

# db/seeds.rb
load('db/seeds/rdf_annotations.rb')

Right now in order to get all the RdfAnnotations we need to run all the migrations rather than being able to take advantage of something like rails db:setup.

And for our tests, There's Rails.application.load_seed which isn't exactly what we want but we could add

# test/test_helper.rb
class ActiveSupport::TestCase

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all
  load('db/seeds/rdf_annotations.rb')

Originally posted by @pgwillia in ualbertalib/jupiter#2470 (comment)

@pgwillia pgwillia changed the title Modify [acts_as_rdfable](https://github.com/ualbertalib/acts_as_rdfable/) to help us with seeding and testing our application Modify to help us with seeding and testing our application Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant