-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #406 from datacite/feature_seeds_for_tests
Feature seeds for validating in our Development or Stage environment
- Loading branch information
Showing
5 changed files
with
253 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "factory_bot_rails" | ||
|
||
fail "Seed tasks can only be used in the development enviroment" if Rails.env.production? | ||
fail "You need to set up a MDS_USERNAME and MDS_PASSWORD" if ENV["MDS_USERNAME"].blank? || ENV["MDS_PASSWORD"].blank? | ||
|
||
FactoryBot.create(:provider, symbol: "ADMIN") if Provider.where(symbol: "ADMIN").blank? | ||
provider = Provider.where(symbol: "DATACITE").first || FactoryBot.create(:provider, symbol: "DATACITE") | ||
client = Client.where(symbol: "DATACITE.TEST").first || FactoryBot.create(:client, provider: provider, symbol: ENV["MDS_USERNAME"], password: ENV["MDS_PASSWORD"]) | ||
if Prefix.where(uid: "10.14454").blank? | ||
prefix = FactoryBot.create(:prefix, uid: "10.14454") | ||
FactoryBot.create(:client_prefix, client_id: client.id, prefix_id: prefix.id) | ||
end | ||
dois = FactoryBot.create_list(:doi, 10, client: client, state: "findable") | ||
FactoryBot.create_list(:event_for_datacite_related, 3, obj_id: dois.first.doi) | ||
FactoryBot.create_list(:event_for_datacite_usage, 2, obj_id: dois.first.doi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "factory_bot_rails" | ||
|
||
fail "Seed tasks can only be used in the development enviroment" if Rails.env.production? | ||
|
||
after "development:base" do | ||
client = Client.all.first | ||
dois = FactoryBot.create_list(:doi, 70, client: client, state: "findable") | ||
|
||
FactoryBot.create_list(:event_for_datacite_related, 34, obj_id: dois.first.doi) | ||
FactoryBot.create_list(:event_for_datacite_usage, 32, obj_id: dois.first.doi) | ||
FactoryBot.create(:event_for_datacite_orcid_auto_update, subj_id: dois.first.doi, obj_id: "http://orcid.org/0000-0003-2926-8353") | ||
FactoryBot.create_list(:event_for_datacite_orcid_auto_update, 5, obj_id: "http://orcid.org/0000-0003-2926-8353") | ||
end |
Oops, something went wrong.