hyrax 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +1 -0
- data/README.md +7 -1
- data/app/actors/hyrax/actors/file_set_actor.rb +22 -32
- data/app/assets/javascripts/hyrax/editor.es6 +1 -1
- data/app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee +8 -7
- data/app/assets/javascripts/hyrax/select_work_type.es6 +4 -0
- data/app/assets/stylesheets/hyrax/_dashboard.scss +10 -0
- data/app/assets/stylesheets/hyrax/_forms.scss +8 -0
- data/app/controllers/concerns/hyrax/controller.rb +2 -5
- data/app/controllers/hyrax/admin/workflow_roles_controller.rb +1 -1
- data/app/controllers/hyrax/workflow_actions_controller.rb +14 -4
- data/app/forms/hyrax/forms/permission_template_form.rb +38 -1
- data/app/forms/hyrax/forms/work_form.rb +16 -31
- data/app/forms/hyrax/forms/workflow_responsibility_form.rb +5 -2
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +1 -1
- data/app/jobs/attach_files_to_work_job.rb +5 -15
- data/app/models/concerns/hyrax/naming.rb +1 -0
- data/app/models/hyrax/permission_template_access.rb +10 -10
- data/app/models/sipity/workflow.rb +30 -0
- data/app/presenters/hyrax/admin/workflow_role_presenter.rb +17 -31
- data/app/presenters/hyrax/admin/workflow_roles_presenter.rb +43 -0
- data/app/presenters/hyrax/collection_options_presenter.rb +30 -0
- data/app/presenters/hyrax/workflow_presenter.rb +2 -2
- data/app/search_builders/hyrax/active_works_search_builder.rb +13 -0
- data/app/search_builders/hyrax/my_works_search_builder.rb +9 -12
- data/app/search_builders/hyrax/works_search_builder.rb +7 -0
- data/app/services/hyrax/actor_factory.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +24 -2
- data/app/services/hyrax/form_metadata_service.rb +13 -0
- data/app/services/hyrax/persist_directly_contained_output_file_service.rb +3 -3
- data/app/services/hyrax/workflow/abstract_notification.rb +3 -1
- data/app/services/hyrax/workflow/activate_object.rb +1 -1
- data/app/services/hyrax/workflow/deactivate_object.rb +1 -1
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +13 -0
- data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +11 -0
- data/app/services/hyrax/workflow/workflow_schema.rb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/hyrax/base/_form_visibility_component.html.erb +1 -0
- data/app/views/hyrax/homepage/index.html.erb +11 -4
- data/app/views/hyrax/my/_facet_limit.html.erb +11 -8
- data/app/views/hyrax/my/_index_partials/_default_group.html.erb +2 -1
- data/app/views/hyrax/my/_index_partials/_list_works.html.erb +1 -0
- data/config/locales/hyrax.en.yml +5 -0
- data/config/locales/hyrax.es.yml +8 -3
- data/config/locales/hyrax.zh.yml +730 -0
- data/hyrax.gemspec +5 -8
- data/lib/generators/hyrax/install_generator.rb +2 -3
- data/lib/generators/hyrax/models_generator.rb +1 -1
- data/lib/generators/hyrax/templates/catalog_controller.rb +37 -37
- data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +43 -0
- data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +43 -0
- data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +55 -0
- data/lib/generators/hyrax/templates/mediated_deposit_workflow.json.erb +4 -1
- data/lib/generators/hyrax/work/templates/controller.rb.erb +1 -1
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +12 -5
- data/lib/generators/hyrax/work/templates/locale.zh.yml.erb +10 -0
- data/lib/generators/hyrax/work/work_generator.rb +29 -13
- data/lib/hyrax/collections_migration.rb +18 -0
- data/lib/hyrax/engine.rb +1 -2
- data/lib/hyrax/errors.rb +11 -0
- data/lib/hyrax/rails/routes.rb +1 -1
- data/lib/hyrax/search_state.rb +1 -9
- data/lib/hyrax/specs/shared_specs.rb +1 -0
- data/lib/hyrax/specs/shared_specs/workflow_method.rb +46 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/tasks/migrate.rake +5 -0
- data/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/batch_uploads_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +18 -0
- data/spec/features/browse_catalog_spec.rb +1 -1
- data/spec/features/workflow_roles_spec.rb +1 -1
- data/spec/forms/hyrax/forms/work_form_spec.rb +19 -0
- data/spec/forms/hyrax/forms/workflow_responsibility_form_spec.rb +15 -7
- data/spec/helpers/blacklight_helper_spec.rb +1 -1
- data/spec/helpers/hyrax_helper_spec.rb +1 -1
- data/spec/jobs/attach_files_to_work_job_spec.rb +8 -14
- data/spec/lib/hyrax/collections_migration_spec.rb +34 -0
- data/spec/lib/hyrax/search_state_spec.rb +2 -2
- data/spec/models/hyrax/permission_template_spec.rb +1 -1
- data/spec/models/sipity/workflow_role_spec.rb +1 -0
- data/spec/presenters/hyrax/admin/workflow_role_presenter_spec.rb +8 -10
- data/spec/presenters/hyrax/admin/workflow_roles_presenter_spec.rb +18 -0
- data/spec/presenters/hyrax/collection_options_presenter_spec.rb +14 -0
- data/spec/search_builders/hyrax/active_works_search_builder_spec.rb +53 -0
- data/spec/search_builders/hyrax/works_search_builder_spec.rb +24 -0
- data/spec/services/hyrax/admin_set_create_service_spec.rb +64 -35
- data/spec/services/hyrax/persist_directly_contained_output_file_service_spec.rb +11 -7
- data/spec/services/hyrax/workflow/activate_object_spec.rb +4 -0
- data/spec/services/hyrax/workflow/changes_required_notification_spec.rb +2 -2
- data/spec/services/hyrax/workflow/deactivate_object_spec.rb +4 -0
- data/spec/services/hyrax/workflow/deposited_notification_spec.rb +2 -2
- data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +4 -0
- data/spec/services/hyrax/workflow/pending_review_notification_spec.rb +2 -2
- data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +35 -0
- data/spec/support/controller_level_helpers.rb +1 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +10 -2
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +1 -2
- data/spec/views/hyrax/admin/workflow_roles/index.html.erb_spec.rb +2 -2
- data/spec/views/hyrax/homepage/index.html.erb_spec.rb +22 -2
- data/spec/views/shared/select_work_type_modal.html.erb_spec.rb +3 -3
- data/template.rb +1 -1
- metadata +34 -45
- data/lib/hyrax/single_use_error.rb +0 -3
- data/lib/hyrax/workflow_authorization_exception.rb +0 -4
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Hyrax::ActiveWorksSearchBuilder do
|
4
|
+
let(:me) { create(:user) }
|
5
|
+
let(:config) { CatalogController.blacklight_config }
|
6
|
+
let(:scope) do
|
7
|
+
double('The scope',
|
8
|
+
blacklight_config: config,
|
9
|
+
params: {},
|
10
|
+
current_ability: Ability.new(me),
|
11
|
+
current_user: me)
|
12
|
+
end
|
13
|
+
let(:builder) { described_class.new(scope) }
|
14
|
+
|
15
|
+
describe "#to_hash" do
|
16
|
+
before do
|
17
|
+
# This prevents any generated classes from interfering with this test:
|
18
|
+
allow(builder).to receive(:work_classes).and_return([GenericWork])
|
19
|
+
|
20
|
+
allow(builder).to receive(:gated_discovery_filters)
|
21
|
+
.and_return(["depositor"])
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { builder.to_hash['fq'] }
|
25
|
+
|
26
|
+
it "filters works that we are the depositor of" do
|
27
|
+
expect(subject).to match_array ["{!terms f=has_model_ssim}GenericWork",
|
28
|
+
"-suppressed_bsi:true",
|
29
|
+
"depositor"]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".default_processor_chain" do
|
34
|
+
subject { described_class.default_processor_chain }
|
35
|
+
let(:expected_filters) do
|
36
|
+
[
|
37
|
+
:default_solr_parameters,
|
38
|
+
:add_query_to_solr,
|
39
|
+
:add_facet_fq_to_solr,
|
40
|
+
:add_facetting_to_solr,
|
41
|
+
:add_solr_fields_to_query,
|
42
|
+
:add_paging_to_solr,
|
43
|
+
:add_sorting_to_solr,
|
44
|
+
:add_group_config_to_solr,
|
45
|
+
:add_facet_paging_to_solr,
|
46
|
+
:add_access_controls_to_solr_params,
|
47
|
+
:filter_models,
|
48
|
+
:only_active_works
|
49
|
+
]
|
50
|
+
end
|
51
|
+
it { is_expected.to eq expected_filters }
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Hyrax::WorksSearchBuilder do
|
4
|
+
describe "::default_processor_chain" do
|
5
|
+
subject { described_class.default_processor_chain }
|
6
|
+
let(:blacklight_filters) do
|
7
|
+
# These filters are in Blacklight::Solr::SearchBuilderBehavior
|
8
|
+
[
|
9
|
+
:default_solr_parameters,
|
10
|
+
:add_query_to_solr,
|
11
|
+
:add_facet_fq_to_solr,
|
12
|
+
:add_facetting_to_solr,
|
13
|
+
:add_solr_fields_to_query,
|
14
|
+
:add_paging_to_solr,
|
15
|
+
:add_sorting_to_solr,
|
16
|
+
:add_group_config_to_solr,
|
17
|
+
:add_facet_paging_to_solr,
|
18
|
+
:add_access_controls_to_solr_params
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
it { is_expected.to eq blacklight_filters + [:filter_models] }
|
23
|
+
end
|
24
|
+
end
|
@@ -1,63 +1,92 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Hyrax::AdminSetCreateService do
|
4
|
-
let(:
|
5
|
-
let(:workflow_importer) { double(call: true) }
|
6
|
-
let(:service) { described_class.new(admin_set: admin_set, creating_user: user, workflow_importer: workflow_importer) }
|
7
|
-
let(:user) { instance_double(User, user_key: 'user-1234') }
|
8
|
-
|
9
|
-
subject { service }
|
10
|
-
its(:default_workflow_importer) { is_expected.to respond_to(:call) }
|
4
|
+
let(:user) { create(:user) }
|
11
5
|
|
12
6
|
describe '.create_default_admin_set' do
|
7
|
+
let(:admin_set) { AdminSet.find(AdminSet::DEFAULT_ID) }
|
8
|
+
let(:responsibilities) { Sipity::WorkflowResponsibility.where(workflow_role: admin_set.active_workflow.workflow_roles) }
|
13
9
|
# It is important to test the side-effects as a default admin set is a fundamental assumption for Hyrax.
|
14
10
|
it 'creates AdminSet, Hyrax::PermissionTemplate, Sipity::Workflow(s), and activates a Workflow', slow: true do
|
15
11
|
described_class.create_default_admin_set(admin_set_id: AdminSet::DEFAULT_ID, title: AdminSet::DEFAULT_TITLE)
|
16
|
-
admin_set = AdminSet.find(AdminSet::DEFAULT_ID)
|
17
12
|
expect(admin_set.permission_template).to be_persisted
|
18
13
|
expect(admin_set.active_workflow).to be_persisted
|
14
|
+
expect(responsibilities.count).to eq 1
|
15
|
+
expect(responsibilities.first.agent.proxy_for_id).to eq "registered"
|
16
|
+
expect(responsibilities.first.agent.proxy_for_type).to eq "Hyrax::Group"
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
20
|
describe ".call" do
|
23
|
-
|
24
|
-
|
21
|
+
subject { described_class.call(admin_set: admin_set, creating_user: user) }
|
22
|
+
|
23
|
+
let(:admin_set) { AdminSet.new(title: ['test']) }
|
24
|
+
|
25
|
+
context "when using the default admin set" do
|
26
|
+
let(:admin_set) { AdminSet.new(id: AdminSet::DEFAULT_ID) }
|
27
|
+
|
28
|
+
it 'will raise ActiveFedora::IllegalOperation if you attempt to a default admin set' do
|
29
|
+
expect { subject }.to raise_error(RuntimeError)
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
it "is a convenience method for .new#create" do
|
28
34
|
service = instance_double(described_class)
|
29
35
|
expect(described_class).to receive(:new).and_return(service)
|
30
36
|
expect(service).to receive(:create)
|
31
|
-
|
37
|
+
subject
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
|
-
describe "
|
36
|
-
subject { service
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
describe "an instance" do
|
42
|
+
subject { service }
|
43
|
+
|
44
|
+
let(:workflow_importer) { double(call: true) }
|
45
|
+
let(:admin_set) { AdminSet.new(title: ['test']) }
|
46
|
+
let(:service) { described_class.new(admin_set: admin_set, creating_user: user, workflow_importer: workflow_importer) }
|
47
|
+
|
48
|
+
its(:default_workflow_importer) { is_expected.to respond_to(:call) }
|
49
|
+
|
50
|
+
describe "#create" do
|
51
|
+
subject { service.create }
|
52
|
+
|
53
|
+
context "when the admin_set is valid" do
|
54
|
+
let(:permission_template) { Hyrax::PermissionTemplate.find_by(admin_set_id: admin_set.id) }
|
55
|
+
let(:grant) { permission_template.access_grants.first }
|
56
|
+
let!(:role1) { Sipity::Role.create(name: 'testing') }
|
57
|
+
let!(:role2) { Sipity::Role.create(name: 'breaking') }
|
58
|
+
let!(:role3) { Sipity::Role.create(name: 'fixing') }
|
59
|
+
let(:available_workflows) { [create(:workflow), create(:workflow)] }
|
60
|
+
|
61
|
+
# rubocop:disable RSpec/AnyInstance
|
62
|
+
before do
|
63
|
+
allow_any_instance_of(Hyrax::PermissionTemplate).to receive(:available_workflows).and_return(available_workflows)
|
64
|
+
end
|
65
|
+
# rubocop:enable RSpec/AnyInstance
|
66
|
+
|
67
|
+
it "creates an AdminSet, PermissionTemplate, Workflows, activates the default workflow, and sets access" do
|
68
|
+
expect(Sipity::Workflow).to receive(:activate!).with(permission_template: kind_of(Hyrax::PermissionTemplate), workflow_name: Hyrax.config.default_active_workflow_name)
|
69
|
+
expect do
|
70
|
+
expect(subject).to be true
|
71
|
+
end.to change { admin_set.persisted? }.from(false).to(true)
|
72
|
+
.and change { Sipity::WorkflowResponsibility.count }.by(6)
|
73
|
+
expect(admin_set.read_groups).to eq ['public']
|
74
|
+
expect(admin_set.edit_groups).to eq ['admin']
|
75
|
+
expect(grant.agent_id).to eq user.user_key
|
76
|
+
expect(grant.access).to eq 'manage'
|
77
|
+
expect(admin_set.creator).to eq [user.user_key]
|
78
|
+
expect(workflow_importer).to have_received(:call).with(permission_template: permission_template)
|
79
|
+
expect(permission_template).to be_persisted
|
80
|
+
end
|
53
81
|
end
|
54
|
-
end
|
55
82
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
83
|
+
context "when the admin_set is invalid" do
|
84
|
+
let(:admin_set) { AdminSet.new } # Missing title
|
85
|
+
|
86
|
+
it { is_expected.to be false }
|
87
|
+
it 'will not call the workflow_importer' do
|
88
|
+
expect(workflow_importer).not_to have_received(:call)
|
89
|
+
end
|
61
90
|
end
|
62
91
|
end
|
63
92
|
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Hyrax::PersistDirectlyContainedOutputFileService do
|
4
|
-
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
|
8
|
-
|
3
|
+
RSpec.describe Hyrax::PersistDirectlyContainedOutputFileService do
|
4
|
+
# PersistDirectlyContainedOutputFileService is used by FullTextExtract.output_file_service
|
5
|
+
let(:object) { FileSet.create! { |fs| fs.apply_depositor_metadata('justin') } }
|
6
|
+
let(:stream) { "fake file content" }
|
7
|
+
subject(:call) do
|
8
|
+
described_class.call(stream,
|
9
|
+
format: 'txt',
|
10
|
+
url: object.uri,
|
11
|
+
container: 'extracted_text')
|
12
|
+
end
|
9
13
|
|
10
14
|
it "persists the file to the specified destination on the given object" do
|
11
|
-
|
15
|
+
expect(call).to be true
|
12
16
|
expect(object.reload.extracted_text.content).to eq("fake file content")
|
13
17
|
end
|
14
18
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'hyrax/specs/shared_specs'
|
2
3
|
|
3
4
|
RSpec.describe Hyrax::Workflow::ActivateObject do
|
4
5
|
let(:work) { create(:generic_work) }
|
5
6
|
let(:user) { create(:user) }
|
6
7
|
|
8
|
+
let(:workflow_method) { described_class }
|
9
|
+
it_behaves_like "a Hyrax workflow method"
|
10
|
+
|
7
11
|
describe ".call" do
|
8
12
|
it "makes it active" do
|
9
13
|
if RDF::VERSION.to_s < '2.0'
|
@@ -16,7 +16,7 @@ RSpec.describe Hyrax::Workflow::ChangesRequiredNotification do
|
|
16
16
|
.with(anything,
|
17
17
|
"Test title (<a href=\"/concern/generic_works/#{work.id}\">#{work.id}</a>) " \
|
18
18
|
"requires additional changes before approval.\n\n 'A pleasant read'",
|
19
|
-
anything).
|
19
|
+
anything).exactly(3).times.and_call_original
|
20
20
|
|
21
21
|
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
|
22
22
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
@@ -26,7 +26,7 @@ RSpec.describe Hyrax::Workflow::ChangesRequiredNotification do
|
|
26
26
|
context 'without carbon-copied users' do
|
27
27
|
let(:recipients) { { 'to' => [to_user] } }
|
28
28
|
it 'sends a message to the to user(s)' do
|
29
|
-
expect(approver).to receive(:send_message).
|
29
|
+
expect(approver).to receive(:send_message).exactly(2).times.and_call_original
|
30
30
|
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
|
31
31
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
32
32
|
.and change { to_user.mailbox.inbox.count }.by(1)
|
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'hyrax/specs/shared_specs'
|
2
3
|
|
3
4
|
RSpec.describe Hyrax::Workflow::DeactivateObject do
|
4
5
|
let(:work) { create(:generic_work) }
|
5
6
|
let(:user) { create(:user) }
|
6
7
|
|
8
|
+
let(:workflow_method) { described_class }
|
9
|
+
it_behaves_like "a Hyrax workflow method"
|
10
|
+
|
7
11
|
describe ".call" do
|
8
12
|
it "makes it inactive" do
|
9
13
|
if RDF::VERSION.to_s < '2.0'
|
@@ -16,7 +16,7 @@ RSpec.describe Hyrax::Workflow::DepositedNotification do
|
|
16
16
|
.with(anything,
|
17
17
|
"Test title (<a href=\"/concern/generic_works/#{work.id}\">#{work.id}</a>) " \
|
18
18
|
"was approved by #{approver.user_key}. A pleasant read",
|
19
|
-
anything).
|
19
|
+
anything).exactly(3).times.and_call_original
|
20
20
|
|
21
21
|
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
|
22
22
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
@@ -26,7 +26,7 @@ RSpec.describe Hyrax::Workflow::DepositedNotification do
|
|
26
26
|
context 'without carbon-copied users' do
|
27
27
|
let(:recipients) { { 'to' => [to_user] } }
|
28
28
|
it 'sends a message to the to user(s)' do
|
29
|
-
expect(approver).to receive(:send_message).
|
29
|
+
expect(approver).to receive(:send_message).exactly(2).times.and_call_original
|
30
30
|
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
|
31
31
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
32
32
|
.and change { to_user.mailbox.inbox.count }.by(1)
|
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'hyrax/specs/shared_specs'
|
2
3
|
|
3
4
|
RSpec.describe Hyrax::Workflow::GrantEditToDepositor do
|
4
5
|
let(:depositor) { create(:user) }
|
5
6
|
let(:user) { User.new }
|
6
7
|
|
8
|
+
let(:workflow_method) { described_class }
|
9
|
+
it_behaves_like 'a Hyrax workflow method'
|
10
|
+
|
7
11
|
describe ".call" do
|
8
12
|
subject do
|
9
13
|
described_class.call(target: work,
|
@@ -15,7 +15,7 @@ RSpec.describe Hyrax::Workflow::PendingReviewNotification do
|
|
15
15
|
.with(anything,
|
16
16
|
"Test title (<a href=\"/concern/generic_works/#{work.id}\">#{work.id}</a>) "\
|
17
17
|
"was deposited by #{depositor.user_key} and is awaiting approval A pleasant read",
|
18
|
-
anything).
|
18
|
+
anything).exactly(3).times.and_call_original
|
19
19
|
|
20
20
|
expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) }
|
21
21
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
@@ -25,7 +25,7 @@ RSpec.describe Hyrax::Workflow::PendingReviewNotification do
|
|
25
25
|
context 'without carbon-copied users' do
|
26
26
|
let(:recipients) { { 'to' => [to_user] } }
|
27
27
|
it 'sends a message to the to user(s)' do
|
28
|
-
expect(depositor).to receive(:send_message).
|
28
|
+
expect(depositor).to receive(:send_message).exactly(2).times.and_call_original
|
29
29
|
expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) }
|
30
30
|
.to change { depositor.mailbox.inbox.count }.by(1)
|
31
31
|
.and change { to_user.mailbox.inbox.count }.by(1)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hyrax/specs/shared_specs'
|
3
|
+
|
4
|
+
RSpec.describe Hyrax::Workflow::RevokeEditFromDepositor do
|
5
|
+
let(:depositor) { create(:user) }
|
6
|
+
let(:user) { User.new }
|
7
|
+
|
8
|
+
let(:workflow_method) { described_class }
|
9
|
+
it_behaves_like 'a Hyrax workflow method'
|
10
|
+
|
11
|
+
describe ".call" do
|
12
|
+
subject do
|
13
|
+
described_class.call(target: work,
|
14
|
+
comment: "A pleasant read",
|
15
|
+
user: user)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with no additional editors" do
|
19
|
+
let(:work) { create(:work_without_access, depositor: depositor.user_key, edit_users: [depositor.user_key]) }
|
20
|
+
it "adds edit access" do
|
21
|
+
expect { subject }.to change { work.edit_users }.from([depositor.user_key]).to([])
|
22
|
+
expect(work).to be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with an additional editor" do
|
27
|
+
let(:editor) { create(:user) }
|
28
|
+
let(:work) { create(:work_without_access, depositor: depositor.user_key, edit_users: [depositor.user_key, editor.user_key]) }
|
29
|
+
it "adds edit access" do
|
30
|
+
expect { subject }.to change { work.edit_users }.from([depositor.user_key, editor.user_key]).to([editor.user_key])
|
31
|
+
expect(work).to be_valid
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,7 +4,7 @@ module ControllerLevelHelpers
|
|
4
4
|
# These are normally provided by the controller.
|
5
5
|
module ControllerViewHelpers
|
6
6
|
def search_state
|
7
|
-
@search_state ||=
|
7
|
+
@search_state ||= CatalogController.search_state_class.new(params, blacklight_config, controller)
|
8
8
|
end
|
9
9
|
|
10
10
|
# This allows you to set the configuration
|
@@ -10,9 +10,17 @@ class TestAppGenerator < Rails::Generators::Base
|
|
10
10
|
def create_generic_work
|
11
11
|
generate 'hyrax:work GenericWork'
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def create_atlas_work
|
15
|
-
|
15
|
+
# ActiveSupport interprets "atlas" as plural which causes
|
16
|
+
# counter-intuitive route paths. Add an inflection to correct
|
17
|
+
# these paths
|
18
|
+
append_file 'config/initializers/inflections.rb' do
|
19
|
+
"ActiveSupport::Inflector.inflections(:en) do |inflect|\n" \
|
20
|
+
" inflect.irregular 'atlas', 'atlases'\n" \
|
21
|
+
"end\n"
|
22
|
+
end
|
23
|
+
generate 'hyrax:work RareBooks/Atlas'
|
16
24
|
end
|
17
25
|
|
18
26
|
def comment_out_web_console
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'hyrax/admin/workflow_roles/index.html.erb', type: :view do
|
3
|
+
RSpec.describe 'hyrax/admin/workflow_roles/index.html.erb', type: :view do
|
4
4
|
let!(:user1) { create(:user) }
|
5
5
|
let!(:user2) { create(:user) }
|
6
6
|
let(:presenter) do
|
7
|
-
Hyrax::Admin::
|
7
|
+
Hyrax::Admin::WorkflowRolesPresenter.new
|
8
8
|
end
|
9
9
|
|
10
10
|
before do
|
@@ -2,9 +2,11 @@ describe "hyrax/homepage/index.html.erb", type: :view do
|
|
2
2
|
let(:groups) { [] }
|
3
3
|
let(:ability) { instance_double("Ability", can?: false) }
|
4
4
|
let(:presenter) { Hyrax::HomepagePresenter.new(ability) }
|
5
|
+
let(:type_presenter) { instance_double(Hyrax::SelectTypeListPresenter, many?: true) }
|
5
6
|
|
6
7
|
describe "share your work button" do
|
7
8
|
before do
|
9
|
+
allow(view).to receive(:create_work_presenter).and_return(type_presenter)
|
8
10
|
allow(view).to receive(:signed_in?).and_return(signed_in)
|
9
11
|
assign(:presenter, presenter)
|
10
12
|
allow(controller).to receive(:current_ability).and_return(ability)
|
@@ -32,14 +34,32 @@ describe "hyrax/homepage/index.html.erb", type: :view do
|
|
32
34
|
|
33
35
|
context "when signed in" do
|
34
36
|
let(:signed_in) { true }
|
37
|
+
|
35
38
|
context "when the button always displays" do
|
36
39
|
let(:display_share_button) { true }
|
37
|
-
|
38
|
-
|
40
|
+
|
41
|
+
context "and there are multiple work types" do
|
42
|
+
it "displays a button that pops up the modal" do
|
43
|
+
expect(rendered).to have_selector('a[data-behavior="select-work"][href="#"]',
|
44
|
+
text: t("hyrax.share_button"))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "and there is a single work type" do
|
49
|
+
let(:type_presenter) do
|
50
|
+
instance_double(Hyrax::SelectTypeListPresenter, many?: false, first_model: GenericWork)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "displays a link to create that work type" do
|
54
|
+
expect(rendered).to have_selector('a:not([data-behavior])[href="/concern/generic_works/new"]',
|
55
|
+
text: t("hyrax.share_button"))
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
59
|
+
|
41
60
|
context "when the button displays for users with rights" do
|
42
61
|
let(:display_share_button) { false }
|
62
|
+
|
43
63
|
it "does not display" do
|
44
64
|
expect(rendered).not_to have_content t("hyrax.share_button")
|
45
65
|
end
|