hyrax 2.0.0.rc1 → 2.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +5 -1
- data/app/assets/stylesheets/hyrax/_header.scss +6 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +4 -3
- data/app/controllers/hyrax/collections_controller.rb +2 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +113 -48
- data/app/jobs/ingest_local_file_job.rb +0 -1
- data/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb +25 -0
- data/app/search_builders/hyrax/deposit_search_builder.rb +6 -3
- data/app/search_builders/hyrax/stats/work_status_search_builder.rb +4 -5
- data/app/services/hyrax/default_middleware_stack.rb +0 -1
- data/app/services/hyrax/file_set_derivatives_service.rb +13 -4
- data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
- data/app/services/hyrax/workflow/abstract_notification.rb +3 -2
- data/app/services/hyrax/workflow/notification_service.rb +3 -12
- data/app/services/hyrax/workflow/permission_query.rb +3 -3
- data/app/services/hyrax/workflow/status_list_service.rb +1 -1
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +1 -0
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +1 -1
- data/app/views/hyrax/base/_attribute_rows.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +3 -0
- data/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb +1 -0
- data/app/views/hyrax/notifications/_notifications.html.erb +1 -0
- data/config/locales/hyrax.de.yml +7 -3
- data/config/locales/hyrax.en.yml +16 -12
- data/config/locales/hyrax.es.yml +4 -0
- data/config/locales/hyrax.fr.yml +4 -0
- data/config/locales/hyrax.it.yml +4 -0
- data/config/locales/hyrax.pt-BR.yml +4 -0
- data/config/locales/hyrax.zh.yml +4 -0
- data/hyrax.gemspec +2 -2
- data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
- data/lib/hyrax/configuration.rb +11 -0
- data/lib/hyrax/version.rb +1 -1
- data/spec/abilities/file_set_abilities_spec.rb +3 -3
- data/spec/abilities/generic_work_abilities_spec.rb +5 -5
- data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +12 -12
- data/spec/actors/hyrax/actors/transactional_request_spec.rb +1 -1
- data/spec/controllers/hyrax/api/items_controller_spec.rb +6 -6
- data/spec/controllers/hyrax/citations_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/collections_controller_spec.rb +1 -0
- data/spec/controllers/hyrax/content_blocks_controller_spec.rb +5 -5
- data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/downloads_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/pages_controller_spec.rb +6 -6
- data/spec/controllers/hyrax/users_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +1 -1
- data/spec/conversions/power_converters/polymorphic_type_spec.rb +1 -1
- data/spec/factories/admin_sets.rb +1 -1
- data/spec/factories/api_items.rb +1 -1
- data/spec/factories/collections_factory.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/file_sets.rb +3 -3
- data/spec/factories/generic_works.rb +15 -15
- data/spec/factories/operations.rb +1 -1
- data/spec/factories/permission_template_accesses.rb +1 -1
- data/spec/factories/permission_templates.rb +1 -1
- data/spec/factories/proxy_deposit_requests.rb +2 -2
- data/spec/factories/single_use_links.rb +1 -1
- data/spec/factories/sipity_entities.rb +1 -1
- data/spec/factories/uploaded_files.rb +1 -1
- data/spec/factories/users.rb +2 -2
- data/spec/factories/workflow_actions.rb +1 -1
- data/spec/factories/workflow_states.rb +1 -1
- data/spec/factories/workflows.rb +1 -1
- data/spec/features/notifications_spec.rb +1 -1
- data/spec/forms/hyrax/forms/permission_template_form_spec.rb +113 -2
- data/spec/helpers/hyrax/collections_helper_spec.rb +2 -2
- data/spec/helpers/hyrax/content_block_helper_spec.rb +1 -1
- data/spec/helpers/hyrax/trophy_helper_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +3 -4
- data/spec/jobs/ingest_local_file_job_spec.rb +2 -5
- data/spec/lib/hyrax/arkivo/actor_spec.rb +2 -2
- data/spec/lib/hyrax/arkivo/metadata_munger_spec.rb +1 -1
- data/spec/lib/hyrax/arkivo/schema_validator_spec.rb +1 -1
- data/spec/lib/hyrax/configuration_spec.rb +4 -0
- data/spec/models/file_set_spec.rb +1 -1
- data/spec/models/generic_work_spec.rb +1 -1
- data/spec/models/hyrax/user_usage_stats_spec.rb +1 -1
- data/spec/models/sipity/entity_spec.rb +1 -1
- data/spec/models/user_spec.rb +7 -7
- data/spec/presenters/hyrax/admin/users_presenter_spec.rb +2 -2
- data/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb +20 -0
- data/spec/search_builders/hyrax/stats/work_status_search_builder_spec.rb +12 -12
- data/spec/services/hyrax/default_middleware_stack_spec.rb +0 -1
- data/spec/services/hyrax/embargo_service_spec.rb +4 -4
- data/spec/services/hyrax/workflow/notification_service_spec.rb +0 -35
- data/spec/services/hyrax/workflow/permission_generator_spec.rb +1 -1
- data/spec/services/hyrax/workflow/status_list_service_spec.rb +12 -0
- data/spec/spec_helper.rb +6 -6
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/views/hyrax/admin/users/index.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/collections/show.html.erb_spec.rb +23 -5
- data/spec/views/pages/show.html.erb_spec.rb +1 -1
- data/template.rb +1 -1
- metadata +8 -6
- data/app/actors/hyrax/actors/assign_representative_actor.rb +0 -22
|
@@ -55,7 +55,7 @@ RSpec.describe Hyrax::CollectionsHelper do
|
|
|
55
55
|
|
|
56
56
|
describe "button_for_remove_from_collection" do
|
|
57
57
|
let(:item) { double(id: 'changeme:123') }
|
|
58
|
-
let(:collection) {
|
|
58
|
+
let(:collection) { FactoryBot.create(:collection) }
|
|
59
59
|
|
|
60
60
|
it "generates a form that can remove the item" do
|
|
61
61
|
str = button_for_remove_from_collection collection, item
|
|
@@ -92,7 +92,7 @@ RSpec.describe Hyrax::CollectionsHelper do
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
describe "button_for_remove_selected_from_collection" do
|
|
95
|
-
let(:collection) {
|
|
95
|
+
let(:collection) { FactoryBot.create(:collection) }
|
|
96
96
|
|
|
97
97
|
it "creates a button to the collections delete path" do
|
|
98
98
|
str = button_for_remove_selected_from_collection collection
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
RSpec.describe Hyrax::ContentBlockHelper, type: :helper do
|
|
2
|
-
let(:content_block) {
|
|
2
|
+
let(:content_block) { FactoryBot.create(:content_block, value: "<p>foo bar</p>") }
|
|
3
3
|
|
|
4
4
|
describe '#displayable_content_block' do
|
|
5
5
|
let(:options) { {} }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
RSpec.describe Hyrax::TrophyHelper, type: :helper do
|
|
2
2
|
describe "#display_trophy_link" do
|
|
3
|
-
let(:user) {
|
|
3
|
+
let(:user) { FactoryBot.create(:user) }
|
|
4
4
|
let(:id) { '9999' }
|
|
5
5
|
|
|
6
6
|
let(:text_attributes) { '[data-add-text="Highlight Work on Profile"][data-remove-text="Unhighlight Work"]' }
|
|
@@ -83,11 +83,10 @@ RSpec.describe CreateDerivativesJob do
|
|
|
83
83
|
.with(/test\.pdf/, outputs: [{ label: :thumbnail,
|
|
84
84
|
format: 'jpg',
|
|
85
85
|
size: '338x493',
|
|
86
|
-
url: String
|
|
86
|
+
url: String,
|
|
87
|
+
layer: 0 }])
|
|
87
88
|
expect(Hydra::Derivatives::FullTextExtract).to receive(:create)
|
|
88
|
-
.with(/test\.pdf/, outputs: [{ url: RDF::URI,
|
|
89
|
-
container: "extracted_text" }])
|
|
90
|
-
|
|
89
|
+
.with(/test\.pdf/, outputs: [{ url: RDF::URI, container: "extracted_text" }])
|
|
91
90
|
described_class.perform_now(file_set, file.id)
|
|
92
91
|
end
|
|
93
92
|
end
|
|
@@ -4,16 +4,13 @@ RSpec.describe IngestLocalFileJob do
|
|
|
4
4
|
let(:file_set) { FileSet.new }
|
|
5
5
|
let(:actor) { double }
|
|
6
6
|
|
|
7
|
-
let(:mock_upload_directory) { 'spec/mock_upload_directory' }
|
|
8
|
-
|
|
9
7
|
before do
|
|
10
|
-
Dir.mkdir mock_upload_directory unless File.exist? mock_upload_directory
|
|
11
|
-
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
|
12
8
|
allow(Hyrax::Actors::FileSetActor).to receive(:new).with(file_set, user).and_return(actor)
|
|
13
9
|
end
|
|
14
10
|
|
|
15
11
|
it 'has attached a file' do
|
|
12
|
+
expect(FileUtils).not_to receive(:rm)
|
|
16
13
|
expect(actor).to receive(:create_content).and_return(true)
|
|
17
|
-
described_class.perform_now(file_set, File.join(
|
|
14
|
+
described_class.perform_now(file_set, File.join(fixture_path, 'world.png'), user)
|
|
18
15
|
end
|
|
19
16
|
end
|
|
@@ -9,7 +9,7 @@ RSpec.describe Hyrax::Arkivo::Actor do
|
|
|
9
9
|
subject { described_class.new(user, item) }
|
|
10
10
|
|
|
11
11
|
let(:user) { create(:user) }
|
|
12
|
-
let(:item) { JSON.parse(
|
|
12
|
+
let(:item) { JSON.parse(FactoryBot.json(:post_item)) }
|
|
13
13
|
let(:work_actor) { instance_double(Hyrax::Actors::TransactionalRequest) }
|
|
14
14
|
let(:file_actor) { double }
|
|
15
15
|
|
|
@@ -41,7 +41,7 @@ RSpec.describe Hyrax::Arkivo::Actor do
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
describe '#update_work_from_item' do
|
|
44
|
-
let(:item) { JSON.parse(
|
|
44
|
+
let(:item) { JSON.parse(FactoryBot.json(:put_item)) }
|
|
45
45
|
let(:title) { ['ZZZZZ'] }
|
|
46
46
|
let(:description) { ['This is rather lengthy.'] }
|
|
47
47
|
let(:checksum) { 'abc123' }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Hyrax::Arkivo::MetadataMunger do
|
|
2
2
|
subject { described_class.new(metadata) }
|
|
3
3
|
|
|
4
|
-
let(:metadata) { JSON.parse(
|
|
4
|
+
let(:metadata) { JSON.parse(FactoryBot.json(:post_item))['metadata'] }
|
|
5
5
|
|
|
6
6
|
it 'makes camelCase symbols into underscored strings' do
|
|
7
7
|
expect(metadata).to include('resourceType', 'dateCreated', 'basedNear')
|
|
@@ -43,6 +43,8 @@ RSpec.describe Hyrax::Configuration do
|
|
|
43
43
|
it { is_expected.to respond_to(:google_analytics_id?) }
|
|
44
44
|
it { is_expected.to respond_to(:google_analytics_id) }
|
|
45
45
|
it { is_expected.to respond_to(:libreoffice_path) }
|
|
46
|
+
it { is_expected.to respond_to(:license_service_class) }
|
|
47
|
+
it { is_expected.to respond_to(:license_service_class=) }
|
|
46
48
|
it { is_expected.to respond_to(:max_days_between_fixity_checks=) }
|
|
47
49
|
it { is_expected.to respond_to(:max_days_between_fixity_checks) }
|
|
48
50
|
it { is_expected.to respond_to(:max_notifications_for_dashboard) }
|
|
@@ -52,6 +54,8 @@ RSpec.describe Hyrax::Configuration do
|
|
|
52
54
|
it { is_expected.to respond_to(:persistent_hostpath) }
|
|
53
55
|
it { is_expected.to respond_to(:realtime_notifications?) }
|
|
54
56
|
it { is_expected.to respond_to(:realtime_notifications=) }
|
|
57
|
+
it { is_expected.to respond_to(:rights_statement_service_class) }
|
|
58
|
+
it { is_expected.to respond_to(:rights_statement_service_class=) }
|
|
55
59
|
it { is_expected.to respond_to(:redis_namespace) }
|
|
56
60
|
it { is_expected.to respond_to(:subject_prefix) }
|
|
57
61
|
it { is_expected.to respond_to(:translate_id_to_uri) }
|
|
@@ -213,7 +213,7 @@ RSpec.describe FileSet do
|
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
context 'when there are related files' do
|
|
216
|
-
let(:parent_work) {
|
|
216
|
+
let(:parent_work) { FactoryBot.create(:work_with_files) }
|
|
217
217
|
let(:f1) { parent_work.file_sets.first }
|
|
218
218
|
let(:f2) { parent_work.file_sets.last }
|
|
219
219
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
RSpec.describe Hyrax::UserUsageStats do
|
|
2
|
-
subject {
|
|
2
|
+
subject { FactoryBot.create(:user) }
|
|
3
3
|
|
|
4
4
|
describe 'with cached stats' do
|
|
5
5
|
let!(:stat_1_day_ago) { UserStat.create!(user_id: subject.id, date: 1.day.ago, file_views: 3, file_downloads: 2, work_views: 5) }
|
|
@@ -16,7 +16,7 @@ module Sipity
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe '#proxy_for' do
|
|
19
|
-
let(:work) {
|
|
19
|
+
let(:work) { FactoryBot.create(:generic_work) }
|
|
20
20
|
let(:entity) { Sipity::Entity.new(proxy_for_global_id: work.to_global_id) }
|
|
21
21
|
|
|
22
22
|
it 'will retrieve based on a GlobalID of the object' do
|
data/spec/models/user_spec.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
RSpec.describe User, type: :model do
|
|
2
|
-
let(:user) {
|
|
3
|
-
let(:another_user) {
|
|
2
|
+
let(:user) { FactoryBot.build(:user) }
|
|
3
|
+
let(:another_user) { FactoryBot.build(:user) }
|
|
4
4
|
|
|
5
5
|
describe 'verifying factories' do
|
|
6
6
|
describe ':user' do
|
|
7
|
-
let(:user) {
|
|
7
|
+
let(:user) { FactoryBot.build(:user) }
|
|
8
8
|
|
|
9
9
|
it 'will, by default, have no groups' do
|
|
10
10
|
expect(user.groups).to eq([])
|
|
@@ -13,7 +13,7 @@ RSpec.describe User, type: :model do
|
|
|
13
13
|
expect(user.class.find(user.id).groups).to eq([])
|
|
14
14
|
end
|
|
15
15
|
it 'will allow for override of groups' do
|
|
16
|
-
user =
|
|
16
|
+
user = FactoryBot.build(:user, groups: 'chicken')
|
|
17
17
|
expect(user.groups).to eq(['chicken'])
|
|
18
18
|
user.save!
|
|
19
19
|
# Ensuring that we can refind it and have the correct groups
|
|
@@ -21,7 +21,7 @@ RSpec.describe User, type: :model do
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
describe ':admin' do
|
|
24
|
-
let(:admin_user) {
|
|
24
|
+
let(:admin_user) { FactoryBot.create(:admin) }
|
|
25
25
|
|
|
26
26
|
it 'will have an "admin" group' do
|
|
27
27
|
expect(admin_user.groups).to eq(['admin'])
|
|
@@ -236,8 +236,8 @@ RSpec.describe User, type: :model do
|
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
describe "scope Users" do
|
|
239
|
-
let!(:basic_user) {
|
|
240
|
-
let!(:guest_user) {
|
|
239
|
+
let!(:basic_user) { FactoryBot.create(:user) }
|
|
240
|
+
let!(:guest_user) { FactoryBot.create(:user, :guest) }
|
|
241
241
|
let!(:audit_user) { User.audit_user }
|
|
242
242
|
let!(:batch_user) { User.batch_user }
|
|
243
243
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
RSpec.describe Hyrax::Admin::UsersPresenter do
|
|
2
2
|
let(:instance) { described_class.new }
|
|
3
|
-
let!(:user) {
|
|
4
|
-
let!(:admin_user) {
|
|
3
|
+
let!(:user) { FactoryBot.create(:user) }
|
|
4
|
+
let!(:admin_user) { FactoryBot.create(:user, groups: 'admin') }
|
|
5
5
|
let!(:audit_user) { User.audit_user }
|
|
6
6
|
let!(:batch_user) { User.batch_user }
|
|
7
7
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
RSpec.describe Hyrax::Renderers::RightsStatementAttributeRenderer do
|
|
2
|
+
let(:field) { :rights_statement }
|
|
3
|
+
let(:renderer) { described_class.new(field, ['http://rightsstatements.org/vocab/InC/1.0/']) }
|
|
4
|
+
|
|
5
|
+
describe "#attribute_to_html" do
|
|
6
|
+
subject { Nokogiri::HTML(renderer.render) }
|
|
7
|
+
|
|
8
|
+
let(:expected) { Nokogiri::HTML(tr_content) }
|
|
9
|
+
|
|
10
|
+
let(:tr_content) do
|
|
11
|
+
"<tr><th>Rights statement</th>\n" \
|
|
12
|
+
"<td><ul class='tabular'>" \
|
|
13
|
+
"<li class=\"attribute rights_statement\"><a href=\"http://rightsstatements.org/vocab/InC/1.0/\" target=\"_blank\">In Copyright</a></li>" \
|
|
14
|
+
"</ul></td></tr>"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it { expect(renderer).not_to be_microdata(field) }
|
|
18
|
+
it { expect(subject).to be_equivalent_to(expected) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -11,22 +11,22 @@ RSpec.describe Hyrax::Stats::WorkStatusSearchBuilder do
|
|
|
11
11
|
describe "#query" do
|
|
12
12
|
subject { instance.query }
|
|
13
13
|
|
|
14
|
-
let(:stub_relation) do
|
|
15
|
-
instance_double(Hyrax::WorkRelation,
|
|
16
|
-
search_model_clause: "(model clauses)")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
before do
|
|
20
|
-
# Prevent the stub relation from returning different filters depending on
|
|
21
|
-
# how many models have been generated
|
|
22
|
-
allow(instance).to receive(:work_relation).and_return(stub_relation)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
14
|
it "sets required parameters" do
|
|
26
15
|
expect(subject['facet.field']).to eq ["suppressed_bsi"]
|
|
27
|
-
expect(subject['fq']).to eq "(model clauses)"
|
|
28
16
|
expect(subject['facet.missing']).to eq true
|
|
29
17
|
expect(subject['rows']).to eq 0
|
|
30
18
|
end
|
|
31
19
|
end
|
|
20
|
+
|
|
21
|
+
describe "#only_works?" do
|
|
22
|
+
subject { instance.send(:only_works?) }
|
|
23
|
+
|
|
24
|
+
it { is_expected.to be true }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "::default_processor_chain" do
|
|
28
|
+
subject { described_class.default_processor_chain }
|
|
29
|
+
|
|
30
|
+
it { is_expected.to include(:filter_models) }
|
|
31
|
+
end
|
|
32
32
|
end
|
|
@@ -13,7 +13,6 @@ RSpec.describe Hyrax::DefaultMiddlewareStack do
|
|
|
13
13
|
Hyrax::Actors::CreateWithFilesActor,
|
|
14
14
|
Hyrax::Actors::CollectionsMembershipActor,
|
|
15
15
|
Hyrax::Actors::AddToWorkActor,
|
|
16
|
-
Hyrax::Actors::AssignRepresentativeActor,
|
|
17
16
|
Hyrax::Actors::AttachMembersActor,
|
|
18
17
|
Hyrax::Actors::ApplyOrderActor,
|
|
19
18
|
Hyrax::Actors::InterpretVisibilityActor,
|
|
@@ -5,19 +5,19 @@ RSpec.describe Hyrax::EmbargoService do
|
|
|
5
5
|
let(:past_date) { 2.days.ago }
|
|
6
6
|
|
|
7
7
|
let!(:work_with_expired_embargo1) do
|
|
8
|
-
|
|
8
|
+
FactoryBot.build(:generic_work, embargo_release_date: past_date.to_s).tap do |work|
|
|
9
9
|
work.save(validate: false)
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
let!(:work_with_expired_embargo2) do
|
|
14
|
-
|
|
14
|
+
FactoryBot.build(:generic_work, embargo_release_date: past_date.to_s).tap do |work|
|
|
15
15
|
work.save(validate: false)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
let!(:work_with_embargo_in_effect) {
|
|
20
|
-
let!(:work_without_embargo) {
|
|
19
|
+
let!(:work_with_embargo_in_effect) { FactoryBot.create(:generic_work, embargo_release_date: future_date.to_s) }
|
|
20
|
+
let!(:work_without_embargo) { FactoryBot.create(:generic_work) }
|
|
21
21
|
|
|
22
22
|
describe '#assets_with_expired_embargoes' do
|
|
23
23
|
it 'returns an array of assets with expired embargoes' do
|
|
@@ -23,11 +23,6 @@ RSpec.describe Hyrax::Workflow::NotificationService do
|
|
|
23
23
|
let(:action) { Sipity::WorkflowAction.new(notifiable_contexts: [notifiable_context]) }
|
|
24
24
|
let(:entity) { Sipity::Entity.new }
|
|
25
25
|
let(:user) { User.new }
|
|
26
|
-
|
|
27
|
-
let(:workflow) { Sipity::Workflow.new }
|
|
28
|
-
let(:workflow_state) { Sipity::WorkflowState.new }
|
|
29
|
-
let(:permission_template) { Hyrax::PermissionTemplate.new }
|
|
30
|
-
|
|
31
26
|
let(:instance) do
|
|
32
27
|
described_class.new(entity: entity,
|
|
33
28
|
action: action,
|
|
@@ -35,34 +30,6 @@ RSpec.describe Hyrax::Workflow::NotificationService do
|
|
|
35
30
|
user: user)
|
|
36
31
|
end
|
|
37
32
|
|
|
38
|
-
describe '#recipients' do
|
|
39
|
-
context 'when an entity requires review' do
|
|
40
|
-
let(:creator) { [instance_double(User)] }
|
|
41
|
-
let(:managers) { [instance_double(User), instance_double(User)] }
|
|
42
|
-
let(:notification) { Sipity::Notification.new(name: 'pending review notification') }
|
|
43
|
-
|
|
44
|
-
before do
|
|
45
|
-
allow(instance).to receive(:send_notification) # mock it so it does nothing
|
|
46
|
-
allow(entity).to receive(:workflow_state).and_return(workflow_state)
|
|
47
|
-
allow(workflow_state).to receive(:name).and_return('pending_review')
|
|
48
|
-
allow(entity).to receive(:workflow).and_return(workflow)
|
|
49
|
-
# Mock the permission_template queries
|
|
50
|
-
allow(workflow).to receive(:permission_template).and_return(permission_template)
|
|
51
|
-
allow(permission_template).to receive(:agent_ids_for)
|
|
52
|
-
.with(access: 'manage', agent_type: 'user')
|
|
53
|
-
.and_return(managers)
|
|
54
|
-
allow(permission_template).to receive(:agent_ids_for)
|
|
55
|
-
.with(access: 'deposit', agent_type: 'user')
|
|
56
|
-
.and_return(creator)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'identifies the managers and depositor for notifications' do
|
|
60
|
-
recipients = instance.recipients(notification)
|
|
61
|
-
expect(recipients).to eq(to: managers, cc: creator)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
33
|
describe "#call" do
|
|
67
34
|
subject { instance.call }
|
|
68
35
|
|
|
@@ -81,8 +48,6 @@ RSpec.describe Hyrax::Workflow::NotificationService do
|
|
|
81
48
|
let(:creator_rel) { double(ActiveRecord::Relation, to_ary: creator) }
|
|
82
49
|
|
|
83
50
|
before do
|
|
84
|
-
allow(entity).to receive(:workflow_state).and_return(workflow_state)
|
|
85
|
-
allow(workflow_state).to receive(:name).and_return('not_pending_review')
|
|
86
51
|
allow(Hyrax::Workflow::PermissionQuery).to receive(:scope_users_for_entity_and_roles)
|
|
87
52
|
.with(entity: entity,
|
|
88
53
|
roles: advising)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Hyrax
|
|
2
2
|
module Workflow
|
|
3
3
|
RSpec.describe PermissionGenerator do
|
|
4
|
-
let(:user) {
|
|
4
|
+
let(:user) { FactoryBot.create(:user) }
|
|
5
5
|
let(:role) { Sipity::Role.create!(name: 'creating_user') }
|
|
6
6
|
let(:workflow) { create(:workflow, name: 'workflow') }
|
|
7
7
|
let(:workflow_state) { workflow.initial_workflow_state }
|
|
@@ -41,6 +41,18 @@ RSpec.describe Hyrax::Workflow::StatusListService do
|
|
|
41
41
|
expect(results.first.to_s).to eq 'Hey dood!'
|
|
42
42
|
expect(results.first.workflow_state).to eq 'initial'
|
|
43
43
|
end
|
|
44
|
+
|
|
45
|
+
describe '#search_solr' do
|
|
46
|
+
let(:mock_response) { { 'response' => { 'docs' => [{}, {}, {}] } } }
|
|
47
|
+
|
|
48
|
+
it 'queries Solr via HTTP POST method' do
|
|
49
|
+
allow(ActiveFedora::SolrService).to receive(:post).and_return(mock_response)
|
|
50
|
+
allow(ActiveFedora::SolrService).to receive(:get)
|
|
51
|
+
service.send(:search_solr)
|
|
52
|
+
expect(ActiveFedora::SolrService).to have_received(:post)
|
|
53
|
+
expect(ActiveFedora::SolrService).not_to have_received(:get)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
44
56
|
end
|
|
45
57
|
|
|
46
58
|
context "when user doesn't have roles" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -21,7 +21,7 @@ if coverage_needed?
|
|
|
21
21
|
SimpleCov.command_name 'spec'
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
require '
|
|
24
|
+
require 'factory_bot'
|
|
25
25
|
require 'engine_cart'
|
|
26
26
|
EngineCart.load_application!
|
|
27
27
|
|
|
@@ -89,7 +89,7 @@ end
|
|
|
89
89
|
|
|
90
90
|
class JsonStrategy
|
|
91
91
|
def initialize
|
|
92
|
-
@strategy =
|
|
92
|
+
@strategy = FactoryBot.strategy_by_name(:create).new
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
delegate :association, to: :@strategy
|
|
@@ -99,9 +99,9 @@ class JsonStrategy
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
FactoryBot.register_strategy(:json, JsonStrategy)
|
|
103
|
+
FactoryBot.definition_file_paths = [File.expand_path("../factories", __FILE__)]
|
|
104
|
+
FactoryBot.find_definitions
|
|
105
105
|
|
|
106
106
|
module EngineRoutes
|
|
107
107
|
def self.included(base)
|
|
@@ -195,7 +195,7 @@ RSpec.configure do |config|
|
|
|
195
195
|
|
|
196
196
|
config.include Capybara::RSpecMatchers, type: :input
|
|
197
197
|
config.include InputSupport, type: :input
|
|
198
|
-
config.include
|
|
198
|
+
config.include FactoryBot::Syntax::Methods
|
|
199
199
|
|
|
200
200
|
config.infer_spec_type_from_file_location!
|
|
201
201
|
|
|
@@ -3,7 +3,7 @@ module Features
|
|
|
3
3
|
module SessionHelpers
|
|
4
4
|
def sign_in(who = :user)
|
|
5
5
|
logout
|
|
6
|
-
user = who.is_a?(User) ? who :
|
|
6
|
+
user = who.is_a?(User) ? who : FactoryBot.build(:user).tap(&:save!)
|
|
7
7
|
visit new_user_session_path
|
|
8
8
|
fill_in 'Email', with: user.email
|
|
9
9
|
fill_in 'Password', with: user.password
|