-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add journal issue and etds factories
- Loading branch information
Showing
4 changed files
with
163 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :etd, aliases: [:gw_etd, :private_etd], class: 'GwEtd' do | ||
transient do | ||
user { FactoryBot.create(:user) } | ||
# Set to true (or a hash) if you want to create an admin set | ||
with_admin_set { false } | ||
end | ||
|
||
# It is reasonable to assume that a work has an admin set; However, we don't want to | ||
# go through the entire rigors of creating that admin set. | ||
before(:create) do |work, evaluator| | ||
if evaluator.with_admin_set | ||
attributes = {} | ||
attributes[:id] = work.admin_set_id if work.admin_set_id.present? | ||
attributes = evaluator.with_admin_set.merge(attributes) if evaluator.with_admin_set.respond_to?(:merge) | ||
admin_set = create(:admin_set, attributes) | ||
work.admin_set_id = admin_set.id | ||
end | ||
end | ||
|
||
after(:create) do |work, _evaluator| | ||
work.save! if work.try(:member_of_collections) && work.member_of_collections.present? | ||
end | ||
|
||
title { ["Test title"] } | ||
|
||
after(:build) do |work, evaluator| | ||
work.apply_depositor_metadata(evaluator.user.user_key) if work.try(:apply_depositor_metadata, evaluator.user.user_key) | ||
end | ||
|
||
factory :public_etd, traits: [:public] | ||
|
||
trait :public do | ||
visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC } | ||
end | ||
|
||
factory :authenticated_etd, traits: [:authenticated] | ||
|
||
trait :authenticated do | ||
visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED } | ||
end | ||
end | ||
end |
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,49 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :journal_issue, aliases: [:gw_journal_issue, :private_journal_issue], class: 'GwJournalIssue' do | ||
transient do | ||
user { FactoryBot.create(:user) } | ||
# Set to true (or a hash) if you want to create an admin set | ||
with_admin_set { false } | ||
end | ||
|
||
# It is reasonable to assume that a work has an admin set; However, we don't want to | ||
# go through the entire rigors of creating that admin set. | ||
before(:create) do |work, evaluator| | ||
if evaluator.with_admin_set | ||
attributes = {} | ||
attributes[:id] = work.admin_set_id if work.admin_set_id.present? | ||
attributes = evaluator.with_admin_set.merge(attributes) if evaluator.with_admin_set.respond_to?(:merge) | ||
admin_set = create(:admin_set, attributes) | ||
work.admin_set_id = admin_set.id | ||
end | ||
end | ||
|
||
after(:create) do |work, _evaluator| | ||
work.save! if work.try(:member_of_collections) && work.member_of_collections.present? | ||
end | ||
|
||
title { ["Test title"] } | ||
|
||
after(:build) do |work, evaluator| | ||
work.apply_depositor_metadata(evaluator.user.user_key) if work.try(:apply_depositor_metadata, evaluator.user.user_key) | ||
end | ||
|
||
factory :public_journal_issue, traits: [:public] | ||
|
||
trait :public do | ||
visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC } | ||
end | ||
|
||
factory :authenticated_journal_issue, traits: [:authenticated] | ||
|
||
trait :authenticated do | ||
visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED } | ||
end | ||
|
||
factory :invalid_journal_issue do | ||
title { nil } | ||
end | ||
end | ||
end |
File renamed without changes.