sufia 7.2.0 → 7.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +1 -2
- data/.travis.yml +0 -1
- data/Gemfile +2 -1
- data/README.md +23 -106
- data/app/actors/sufia/apply_permission_template_actor.rb +19 -0
- data/app/actors/sufia/create_with_remote_files_actor.rb +2 -2
- data/app/actors/sufia/default_admin_set_actor.rb +42 -0
- data/app/actors/sufia/interpret_visibility_actor.rb +115 -0
- data/app/assets/images/collection.png +0 -0
- data/app/assets/javascripts/sufia.js +6 -0
- data/app/assets/javascripts/sufia/admin/admin_set/participants.es6 +9 -0
- data/app/assets/javascripts/sufia/admin/admin_set/visibility.es6 +134 -0
- data/app/assets/javascripts/sufia/admin/admin_set_controls.es6 +11 -0
- data/app/assets/javascripts/sufia/app.js +27 -5
- data/app/assets/javascripts/sufia/autocomplete.es6 +15 -0
- data/app/assets/javascripts/sufia/autocomplete/work.es6 +29 -0
- data/app/assets/javascripts/sufia/dashboard_actions.js +2 -4
- data/app/assets/javascripts/sufia/save_work/save_work_control.es6 +14 -2
- data/app/assets/javascripts/sufia/save_work/uploaded_files.es6 +7 -2
- data/app/assets/javascripts/sufia/save_work/visibility_component.es6 +245 -4
- data/app/assets/javascripts/sufia/select_work_type.es6 +38 -0
- data/app/assets/javascripts/sufia/workflow_actions_affix.js +14 -0
- data/app/assets/stylesheets/sufia/_dashboard.scss +50 -29
- data/app/assets/stylesheets/sufia/_footer.scss +30 -0
- data/app/assets/stylesheets/sufia/_header.scss +3 -4
- data/app/assets/stylesheets/sufia/_home-page.scss +10 -8
- data/app/assets/stylesheets/sufia/_select_work_type.scss +43 -0
- data/app/assets/stylesheets/sufia/_sufia.scss +4 -1
- data/app/assets/stylesheets/sufia/_variables.scss +3 -0
- data/app/assets/stylesheets/sufia/admin.scss +66 -169
- data/app/assets/stylesheets/sufia/blacklight_gallery.scss +17 -0
- data/app/authorities/qa/authorities/find_works.rb +15 -0
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +2 -1
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +26 -13
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +25 -0
- data/app/controllers/concerns/sufia/controller.rb +8 -0
- data/app/controllers/concerns/sufia/deny_access_override_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/file_sets_controller_behavior.rb +5 -14
- data/app/controllers/concerns/sufia/homepage_controller_behavior.rb +2 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +18 -7
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +13 -10
- data/app/controllers/my/collections_controller.rb +5 -0
- data/app/controllers/my/shares_controller.rb +5 -0
- data/app/controllers/my/works_controller.rb +5 -0
- data/app/controllers/stats_controller.rb +1 -1
- data/app/controllers/sufia/admin/admin_sets_controller.rb +20 -2
- data/app/controllers/sufia/admin/permission_template_accesses_controller.rb +15 -0
- data/app/controllers/sufia/admin/permission_templates_controller.rb +29 -0
- data/app/controllers/sufia/admin_controller.rb +2 -0
- data/app/controllers/sufia/trophies_controller.rb +0 -2
- data/app/forms/sufia/forms/admin_set_form.rb +19 -0
- data/app/forms/sufia/forms/batch_edit_form.rb +16 -6
- data/app/forms/sufia/forms/batch_upload_form.rb +3 -2
- data/app/forms/sufia/forms/permission_template_form.rb +115 -0
- data/app/forms/sufia/forms/work_form.rb +6 -0
- data/app/helpers/batch_edits_helper.rb +1 -1
- data/app/helpers/sufia/citations_behavior.rb +0 -5
- data/app/helpers/sufia/citations_behaviors/formatters.rb +0 -1
- data/app/helpers/sufia/sufia_helper_behavior.rb +38 -6
- data/app/indexers/sufia/collection_indexer.rb +6 -0
- data/app/jobs/batch_create_job.rb +7 -15
- data/app/models/batch_upload_item.rb +2 -0
- data/app/models/concerns/sufia/ability.rb +12 -1
- data/app/models/sufia/permission_template.rb +102 -0
- data/app/models/sufia/permission_template_access.rb +18 -0
- data/app/presenters/sufia/admin_set_presenter.rb +1 -1
- data/app/presenters/sufia/model_icon.rb +7 -0
- data/app/presenters/sufia/select_type_list_presenter.rb +37 -0
- data/app/presenters/sufia/select_type_presenter.rb +35 -0
- data/app/presenters/sufia/work_show_presenter.rb +0 -2
- data/app/search_builders/collection_search_builder.rb +0 -2
- data/app/search_builders/sufia/admin_set_search_builder.rb +24 -0
- data/app/search_builders/sufia/catalog_search_builder.rb +10 -4
- data/app/search_builders/sufia/find_works_search_builder.rb +44 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +0 -4
- data/app/search_builders/sufia/my_works_search_builder.rb +1 -1
- data/app/services/sufia/actor_factory.rb +6 -2
- data/app/services/sufia/admin_set_create_service.rb +22 -0
- data/app/services/sufia/admin_set_service.rb +46 -16
- data/app/services/sufia/collection_thumbnail_path_service.rb +10 -0
- data/app/services/sufia/workflow/abstract_notification.rb +39 -0
- data/app/services/sufia/workflow/changes_required_notification.rb +22 -0
- data/app/services/sufia/workflow/complete_notification.rb +22 -0
- data/app/services/sufia/workflow/pending_review_notification.rb +21 -0
- data/app/services/sufia/workflow/workflow_by_admin_set_strategy.rb +15 -0
- data/app/views/_masthead.html.erb +4 -4
- data/app/views/_toolbar.html.erb +31 -9
- data/app/views/_user_util_links.html.erb +7 -7
- data/app/views/batch_edits/edit.html.erb +24 -12
- data/app/views/catalog/_thumbnail_list_collection.html.erb +1 -1
- data/app/views/collections/_form.html.erb +2 -2
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/curation_concerns/base/_find_work_widget.html.erb +16 -0
- data/app/views/curation_concerns/base/_form.html.erb +6 -0
- data/app/views/curation_concerns/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_metadata.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_parent_work_relationships.html.erb +43 -0
- data/app/views/curation_concerns/base/_form_progress.html.erb +7 -4
- data/app/views/curation_concerns/base/_form_relationships.html.erb +6 -6
- data/app/views/curation_concerns/base/_form_share.html.erb +1 -2
- data/app/views/curation_concerns/base/_guts4form.html.erb +1 -1
- data/app/views/curation_concerns/base/_social_media.html.erb +1 -1
- data/app/views/curation_concerns/base/_workflow_actions_widget.erb +3 -0
- data/app/views/curation_concerns/base/edit.html.erb +1 -1
- data/app/views/curation_concerns/base/new.html.erb +1 -1
- data/app/views/curation_concerns/base/show.html.erb +4 -1
- data/app/views/curation_concerns/file_sets/_show_actions.html.erb +0 -3
- data/app/views/dashboard/_create_work_action.html.erb +20 -0
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +9 -22
- data/app/views/layouts/admin.html.erb +8 -68
- data/app/views/layouts/curation_concerns/1_column.html.erb +4 -31
- data/app/views/layouts/homepage.html.erb +15 -45
- data/app/views/layouts/sufia-dashboard.html.erb +1 -36
- data/app/views/layouts/sufia.html.erb +49 -0
- data/app/views/my/_document_list.html.erb +1 -1
- data/app/views/my/_facet_limit.html.erb +2 -2
- data/app/views/my/_index_partials/_default_group.html.erb +10 -10
- data/app/views/my/_index_partials/_list_collections.html.erb +1 -1
- data/app/views/my/_sort_and_per_page.html.erb +8 -8
- data/app/views/records/edit_fields/_rights.html.erb +0 -1
- data/app/views/shared/_footer.html.erb +1 -1
- data/app/views/shared/_select_work_type_modal.html.erb +34 -0
- data/app/views/sufia/admin/_collections.html.erb +31 -0
- data/app/views/sufia/admin/_sidebar.html.erb +35 -23
- data/app/views/sufia/admin/admin_sets/_form.html.erb +38 -15
- data/app/views/sufia/admin/admin_sets/_form_metadata.html.erb +2 -0
- data/app/views/sufia/admin/admin_sets/_form_participant_table.html.erb +21 -0
- data/app/views/sufia/admin/admin_sets/_form_participants.html.erb +68 -0
- data/app/views/sufia/admin/admin_sets/_form_visibility.html.erb +58 -0
- data/app/views/sufia/admin/admin_sets/index.html.erb +29 -33
- data/app/views/sufia/admin/admin_sets/show.html.erb +3 -0
- data/app/views/sufia/admin/show.html.erb +22 -19
- data/app/views/sufia/batch_uploads/_form.html.erb +2 -1
- data/app/views/sufia/homepage/index.html.erb +11 -3
- data/app/views/sufia/uploads/_js_templates.html.erb +15 -11
- data/app/views/users/_user_row.html.erb +10 -0
- data/app/views/users/index.html.erb +1 -12
- data/config/features.rb +2 -0
- data/config/locales/sufia.en.yml +122 -37
- data/config/routes.rb +4 -1
- data/db/migrate/20161021175854_create_permission_template.rb +11 -0
- data/db/migrate/20161021180154_create_permission_template_access.rb +11 -0
- data/db/migrate/20161116222307_add_release_to_permission_templates.rb +6 -0
- data/lib/generators/sufia/install_generator.rb +12 -3
- data/lib/generators/sufia/templates/catalog_controller.rb +3 -13
- data/lib/generators/sufia/templates/workflow.json.erb +65 -0
- data/lib/generators/sufia/upgrade700_generator.rb +1 -1
- data/lib/generators/sufia/work/templates/locale.en.yml.erb +37 -0
- data/lib/generators/sufia/{work_generator.rb → work/work_generator.rb} +25 -5
- data/lib/sufia.rb +0 -1
- data/lib/sufia/engine.rb +7 -0
- data/lib/sufia/move_all_works_to_admin_set.rb +8 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/migrate.rake +8 -0
- data/spec/actors/sufia/apply_permission_template_actor_spec.rb +64 -0
- data/spec/actors/sufia/create_with_remote_files_actor_spec.rb +8 -0
- data/spec/actors/sufia/default_admin_set_actor_spec.rb +43 -0
- data/spec/actors/sufia/interpret_visibility_actor_spec.rb +266 -0
- data/spec/authorities/qa/authorities/find_works_spec.rb +55 -0
- data/spec/controllers/batch_edits_controller_spec.rb +1 -6
- data/spec/controllers/citations_controller_spec.rb +49 -10
- data/spec/controllers/collections_controller_spec.rb +39 -0
- data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +22 -1
- data/spec/controllers/dashboard_controller_spec.rb +0 -8
- data/spec/controllers/depositors_controller_spec.rb +2 -2
- data/spec/controllers/downloads_controller_spec.rb +2 -2
- data/spec/controllers/my/collections_controller_spec.rb +5 -0
- data/spec/controllers/my/shares_controller_spec.rb +5 -0
- data/spec/controllers/my/works_controller_spec.rb +5 -0
- data/spec/controllers/stats_controller_spec.rb +1 -1
- data/spec/controllers/sufia/admin/admin_sets_controller_spec.rb +33 -5
- data/spec/controllers/sufia/admin/permission_template_accesses_controller_spec.rb +36 -0
- data/spec/controllers/sufia/admin/permission_templates_controller_spec.rb +46 -0
- data/spec/controllers/sufia/admin_controller_spec.rb +6 -0
- data/spec/controllers/sufia/batch_uploads_controller_spec.rb +40 -42
- data/spec/controllers/sufia/homepage_controller_spec.rb +14 -0
- data/spec/controllers/sufia/trophies_controller_spec.rb +17 -4
- data/spec/controllers/users_controller_spec.rb +13 -4
- data/spec/factories/permission_template_accesses.rb +5 -0
- data/spec/factories/permission_templates.rb +5 -0
- data/spec/factories/sipity_entities.rb +7 -0
- data/spec/factories/users.rb +4 -0
- data/spec/factories/workflow_states.rb +6 -0
- data/spec/factories/workflows.rb +5 -0
- data/spec/features/admin_admin_set_spec.rb +6 -4
- data/spec/features/batch_edit_spec.rb +0 -1
- data/spec/features/collection_spec.rb +4 -4
- data/spec/features/edit_work_spec.rb +1 -0
- data/spec/features/work_show_spec.rb +10 -0
- data/spec/forms/sufia/forms/admin_set_form_spec.rb +2 -1
- data/spec/forms/sufia/forms/batch_edit_form_spec.rb +30 -0
- data/spec/forms/sufia/forms/permission_template_form_spec.rb +196 -0
- data/spec/forms/sufia/forms/work_form_spec.rb +35 -1
- data/spec/helpers/batch_edits_helper_spec.rb +4 -4
- data/spec/helpers/blacklight_helper_spec.rb +1 -1
- data/spec/helpers/sufia_helper_spec.rb +39 -7
- data/spec/indexers/sufia/collection_indexer_spec.rb +12 -0
- data/spec/javascripts/autocomplete_spec.js.coffee +46 -6
- data/spec/javascripts/visibility_component_spec.js +491 -0
- data/spec/jobs/batch_create_job_spec.rb +27 -28
- data/spec/lib/sufia/arkivo_spec.rb +14 -0
- data/spec/lib/sufia/controlled_vocabulary/importer/downloader_spec.rb +31 -0
- data/spec/lib/sufia/move_all_works_to_admin_set_spec.rb +13 -0
- data/spec/lib/sufia/zotero_spec.rb +8 -0
- data/spec/models/sufia/ability_spec.rb +54 -14
- data/spec/models/sufia/permission_template_spec.rb +144 -0
- data/spec/models/sufia/user_usage_stats_spec.rb +8 -2
- data/spec/presenters/sufia/homepage_presenter_spec.rb +1 -1
- data/spec/presenters/sufia/select_type_list_presenter_spec.rb +26 -0
- data/spec/presenters/sufia/select_type_presenter_spec.rb +21 -0
- data/spec/search_builder/sufia/admin_set_search_builder_spec.rb +57 -0
- data/spec/search_builder/sufia/catalog_search_builder_spec.rb +40 -14
- data/spec/search_builder/sufia/find_works_search_builder_spec.rb +60 -0
- data/spec/search_builder/sufia/my_shares_search_builder_spec.rb +4 -1
- data/spec/search_builder/sufia/single_admin_set_search_builder_spec.rb +5 -1
- data/spec/services/sufia/actor_factory_spec.rb +13 -5
- data/spec/services/sufia/admin_set_create_service_spec.rb +27 -0
- data/spec/services/sufia/admin_set_service_spec.rb +104 -17
- data/spec/services/sufia/workflow/changes_required_notification_spec.rb +32 -0
- data/spec/services/sufia/workflow/complete_notification_spec.rb +32 -0
- data/spec/services/sufia/workflow/pending_review_notification_spec.rb +31 -0
- data/spec/services/sufia/workflow/workflow_by_admin_set_strategy_spec.rb +22 -0
- data/spec/spec_helper.rb +24 -5
- data/spec/support/proxies.rb +1 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
- data/spec/views/_toolbar.html.erb_spec.rb +23 -6
- data/spec/views/batch_edits/edit.html.erb_spec.rb +7 -1
- data/spec/views/collections/_form_for_select_collection.html.erb_spec.rb +1 -3
- data/spec/views/curation_concerns/base/_find_work_widget.html.erb_spec.rb +22 -0
- data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +7 -0
- data/spec/views/curation_concerns/base/_form_child_work_relationships.html.erb_spec.rb +1 -0
- data/spec/views/curation_concerns/base/_form_parent_work_relationships.html.erb_spec.rb +114 -0
- data/spec/views/curation_concerns/base/_form_progress.html.erb_spec.rb +3 -2
- data/spec/views/curation_concerns/base/_social_media.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/edit.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/show.html.erb_spec.rb +5 -1
- data/spec/views/curation_concerns/file_sets/_show_actions.html.erb_spec.rb +2 -2
- data/spec/views/dashboard/create_work_action.html.erb_spec.rb +27 -0
- data/spec/views/dashboard/index_spec.rb +7 -2
- data/spec/views/my/_sort_and_per_page.html.erb_spec.rb +33 -0
- data/spec/views/shared/select_work_type_modal.html.erb_spec.rb +32 -0
- data/spec/views/sufia/admin/admin_sets/_form.html.erb_spec.rb +18 -0
- data/spec/views/sufia/admin/admin_sets/_form_participants.html.erb_spec.rb +13 -0
- data/spec/views/sufia/admin/admin_sets/_form_visibility.html.erb_spec.rb +23 -0
- data/spec/views/sufia/batch_uploads/_form.html.erb_spec.rb +2 -12
- data/spec/views/sufia/homepage/index.html.erb_spec.rb +29 -8
- data/sufia.gemspec +5 -6
- data/tasks/sufia-dev.rake +6 -10
- data/template.rb +15 -0
- metadata +140 -28
- data/app/assets/stylesheets/sufia/widgets.css +0 -288
- data/app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb +0 -49
- data/app/models/domain_term.rb +0 -4
- data/app/views/citations/file.html.erb +0 -0
- data/app/views/records/_rights_modal.html.erb +0 -1
- data/db/migrate/20160328222160_create_local_authorities.rb +0 -50
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Sufia::Forms::WorkForm do
|
1
|
+
describe Sufia::Forms::WorkForm, :no_clean do
|
2
2
|
let(:work) { GenericWork.new }
|
3
3
|
let(:form) { described_class.new(work, nil) }
|
4
4
|
let(:works) { [GenericWork.new, FileSet.new, GenericWork.new] }
|
@@ -17,4 +17,38 @@ describe Sufia::Forms::WorkForm do
|
|
17
17
|
expect(form.ordered_work_members.size).to eq(2)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
describe "#in_work_members" do
|
22
|
+
it "expects parent work members" do
|
23
|
+
allow(work).to receive(:in_works).and_return(works)
|
24
|
+
expect(form.in_work_members.size).to eq(3)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".build_permitted_params" do
|
29
|
+
before do
|
30
|
+
allow(described_class).to receive(:model_class).and_return(GenericWork)
|
31
|
+
end
|
32
|
+
subject { described_class.build_permitted_params }
|
33
|
+
context "without mediated deposit" do
|
34
|
+
it { is_expected.to include(permissions_attributes: [:type, :name, :access, :id, :_destroy]) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".model_attributes" do
|
39
|
+
before do
|
40
|
+
allow(described_class).to receive(:model_class).and_return(GenericWork)
|
41
|
+
end
|
42
|
+
subject { described_class.model_attributes(ActionController::Parameters.new(attributes)) }
|
43
|
+
|
44
|
+
context "when a user is granted edit access" do
|
45
|
+
let(:attributes) { { permissions_attributes: [{ type: 'person', name: 'justin', access: 'edit' }] } }
|
46
|
+
it { is_expected.to eq ActionController::Parameters.new(permissions_attributes: [ActionController::Parameters.new(type: 'person', name: 'justin', access: 'edit')]).permit! }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "without permssions being set" do
|
50
|
+
let(:attributes) { {} }
|
51
|
+
it { is_expected.to eq ActionController::Parameters.new.permit! }
|
52
|
+
end
|
53
|
+
end
|
20
54
|
end
|
@@ -6,28 +6,28 @@ describe BatchEditsHelper, type: :helper do
|
|
6
6
|
|
7
7
|
context "with my works" do
|
8
8
|
it "shows the check all dropdown" do
|
9
|
-
allow(controller).to receive(:
|
9
|
+
allow(controller).to receive(:params).and_return(controller: "my/works")
|
10
10
|
expect(helper.render_check_all).to have_css("span.glyphicon-cog")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with my shares" do
|
15
15
|
it "shows the check all dropdown" do
|
16
|
-
allow(controller).to receive(:
|
16
|
+
allow(controller).to receive(:params).and_return(controller: "my/shares")
|
17
17
|
expect(helper.render_check_all).to have_css("span.glyphicon-cog")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
context "with my highlights" do
|
22
22
|
it "shows the check all dropdown" do
|
23
|
-
allow(controller).to receive(:
|
23
|
+
allow(controller).to receive(:params).and_return(controller: "my/shares")
|
24
24
|
expect(helper.render_check_all).to have_css("span.glyphicon-cog")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context "with my collections" do
|
29
29
|
it "does not show the check all dropdown" do
|
30
|
-
allow(controller).to receive(:
|
30
|
+
allow(controller).to receive(:params).and_return(controller: "my/collections")
|
31
31
|
expect(helper.render_check_all).to be_nil
|
32
32
|
end
|
33
33
|
end
|
@@ -94,7 +94,7 @@ RSpec.describe BlacklightHelper, type: :helper do
|
|
94
94
|
|
95
95
|
context "identifier_tesim" do
|
96
96
|
let(:field_name) { 'identifier_tesim' }
|
97
|
-
it { is_expected.to eq '<a href="/catalog?
|
97
|
+
it { is_expected.to eq '<a href="/catalog?q=%2265434567654345654%22&search_field=identifier">65434567654345654</a>' }
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -51,20 +51,46 @@ describe SufiaHelper, type: :helper do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#index_field_link' do
|
54
|
-
let(:args)
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
let(:args) do
|
55
|
+
{
|
56
|
+
config: { field_name: 'contributor' },
|
57
|
+
value: ['Fritz Lang', 'Mel Brooks']
|
58
|
+
}
|
58
59
|
end
|
60
|
+
|
59
61
|
subject { helper.index_field_link(args) }
|
60
|
-
|
62
|
+
|
63
|
+
it 'returns a link' do
|
61
64
|
expect(subject).to be_html_safe
|
62
|
-
expect(subject).to eq '<a href="/catalog?
|
63
|
-
+ '<a href="/catalog?
|
65
|
+
expect(subject).to eq '<a href="/catalog?q=%22Fritz+Lang%22&search_field=contributor">Fritz Lang</a>, ' \
|
66
|
+
+ '<a href="/catalog?q=%22Mel+Brooks%22&search_field=contributor">Mel Brooks</a>'
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
71
|
+
describe "#link_to_each_facet_field" do
|
72
|
+
subject { helper.link_to_each_facet_field(options) }
|
73
|
+
context "with helper_facet and default separator" do
|
74
|
+
let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym }, value: ["Imaging > Object Photography"] } }
|
75
|
+
it { is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">Imaging</a> > <a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Object+Photography\">Object Photography</a>") }
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with helper_facet and optional separator" do
|
79
|
+
let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, separator: " : " }, value: ["Imaging : Object Photography"] } }
|
80
|
+
it { is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">Imaging</a> : <a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Object+Photography\">Object Photography</a>") }
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with :output_separator" do
|
84
|
+
let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, output_separator: ' ~ ', separator: ":" }, value: ["Imaging : Object Photography"] } }
|
85
|
+
it { is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">Imaging</a> ~ <a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Object+Photography\">Object Photography</a>") }
|
86
|
+
end
|
87
|
+
|
88
|
+
context "with :no_spaces_around_separator" do
|
89
|
+
let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, output_separator: '~', separator: ":" }, value: ["Imaging : Object Photography"] } }
|
90
|
+
it { is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">Imaging</a>~<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Object+Photography\">Object Photography</a>") }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
68
94
|
describe "has_collection_search_parameters?" do
|
69
95
|
subject { helper }
|
70
96
|
context "when cq is set" do
|
@@ -253,4 +279,10 @@ describe SufiaHelper, type: :helper do
|
|
253
279
|
expect(helper.human_readable_date(value: ["2016-08-15T00:00:00Z"])).to eq("08/15/2016")
|
254
280
|
end
|
255
281
|
end
|
282
|
+
|
283
|
+
describe "#banner_image" do
|
284
|
+
it "returns the configured Sufia banner image" do
|
285
|
+
expect(helper.banner_image).to eq(Sufia.config.banner_image)
|
286
|
+
end
|
287
|
+
end
|
256
288
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Sufia::CollectionIndexer do
|
5
|
+
let(:collection) { build(:collection, id: "1234") }
|
6
|
+
|
7
|
+
subject { described_class.new(collection).generate_solr_document }
|
8
|
+
|
9
|
+
it "indexes thumbnail" do
|
10
|
+
expect(subject["thumbnail_path_ss"]).to start_with("/assets/collection")
|
11
|
+
end
|
12
|
+
end
|
@@ -34,7 +34,7 @@ describe "auto complete", ->
|
|
34
34
|
target.trigger(@typeEvent)
|
35
35
|
|
36
36
|
# move time along so that events have a chance to happen
|
37
|
-
jasmine.clock().tick(800)
|
37
|
+
jasmine.clock().tick(800)
|
38
38
|
|
39
39
|
# verify that the ajax call was made
|
40
40
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -50,7 +50,7 @@ describe "auto complete", ->
|
|
50
50
|
target.trigger(@typeEvent)
|
51
51
|
|
52
52
|
# move time along so that events have a chance to happen
|
53
|
-
jasmine.clock().tick(800)
|
53
|
+
jasmine.clock().tick(800)
|
54
54
|
|
55
55
|
# verify that the ajax call was made
|
56
56
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -74,7 +74,7 @@ describe "auto complete", ->
|
|
74
74
|
target.trigger(@typeEvent)
|
75
75
|
|
76
76
|
# move time along so that events have a chance to happen
|
77
|
-
jasmine.clock().tick(800)
|
77
|
+
jasmine.clock().tick(800)
|
78
78
|
|
79
79
|
# verify that the ajax call was made
|
80
80
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -90,7 +90,7 @@ describe "auto complete", ->
|
|
90
90
|
target.trigger(@typeEvent)
|
91
91
|
|
92
92
|
# move time along so that events have a chance to happen
|
93
|
-
jasmine.clock().tick(800)
|
93
|
+
jasmine.clock().tick(800)
|
94
94
|
|
95
95
|
# verify that the ajax call was made
|
96
96
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -115,7 +115,7 @@ describe "auto complete", ->
|
|
115
115
|
target.trigger(@typeEvent)
|
116
116
|
|
117
117
|
# move time along so that events have a chance to happen
|
118
|
-
jasmine.clock().tick(800)
|
118
|
+
jasmine.clock().tick(800)
|
119
119
|
|
120
120
|
# verify that the ajax call was made
|
121
121
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -131,7 +131,47 @@ describe "auto complete", ->
|
|
131
131
|
target.trigger(@typeEvent)
|
132
132
|
|
133
133
|
# move time along so that events have a chance to happen
|
134
|
-
jasmine.clock().tick(800)
|
134
|
+
jasmine.clock().tick(800)
|
135
|
+
|
136
|
+
# verify that the ajax call was made
|
137
|
+
expect(@spy_on_json).toHaveBeenCalled()
|
138
|
+
|
139
|
+
describe "works", ->
|
140
|
+
beforeEach ->
|
141
|
+
# setup two inputs for us to attach auto complete to
|
142
|
+
setFixtures '<input class="generic_work_work" value="" id="generic_work_based_near" type="text" data-autocomplete="work" data-autocomplete-url="foo">
|
143
|
+
<input class="generic_work_work" value="" type="text" data-autocomplete="work" data-autocomplete-url="foo">'
|
144
|
+
|
145
|
+
# run all Blacklight.onload functions
|
146
|
+
Blacklight.activate()
|
147
|
+
|
148
|
+
describe "first input", ->
|
149
|
+
|
150
|
+
# field triggers auto complete
|
151
|
+
it "auto completes on typing", ->
|
152
|
+
# send a key stroke to the target input to activate the auto complete
|
153
|
+
target = $($("input.generic_work_work")[0])
|
154
|
+
target.val('fre')
|
155
|
+
target.trigger(@typeEvent)
|
156
|
+
|
157
|
+
# move time along so that events have a chance to happen
|
158
|
+
jasmine.clock().tick(800)
|
159
|
+
|
160
|
+
# verify that the ajax call was made
|
161
|
+
expect(@spy_on_json).toHaveBeenCalled()
|
162
|
+
|
163
|
+
|
164
|
+
describe "second input", ->
|
165
|
+
|
166
|
+
# field triggers auto complete
|
167
|
+
it "auto completes on typing", ->
|
168
|
+
# send a key stroke to the target input to activate the auto complete
|
169
|
+
target = $($("input.generic_work_work")[1])
|
170
|
+
target.val('fre')
|
171
|
+
target.trigger(@typeEvent)
|
172
|
+
|
173
|
+
# move time along so that events have a chance to happen
|
174
|
+
jasmine.clock().tick(800)
|
135
175
|
|
136
176
|
# verify that the ajax call was made
|
137
177
|
expect(@spy_on_json).toHaveBeenCalled()
|
@@ -0,0 +1,491 @@
|
|
1
|
+
describe("VisibilityComponent", function() {
|
2
|
+
var control = require('sufia/save_work/visibility_component');
|
3
|
+
var target = null;
|
4
|
+
var element = null;
|
5
|
+
|
6
|
+
beforeEach(function() {
|
7
|
+
var fixture = setFixtures(visibilityForm(''));
|
8
|
+
element = fixture.find('.visibility');
|
9
|
+
target = new control.VisibilityComponent(element);
|
10
|
+
});
|
11
|
+
|
12
|
+
//limitByAdminSet() - Also tests restrictToVisibility(selected) which is where much of logic sits
|
13
|
+
describe("limitByAdminSet", function() {
|
14
|
+
describe("with no admin set selected", function() {
|
15
|
+
beforeEach(function() {
|
16
|
+
spyOn(target, 'enableAllOptions');
|
17
|
+
});
|
18
|
+
it("enables all visibility options", function() {
|
19
|
+
target.limitByAdminSet();
|
20
|
+
expect(target.enableAllOptions).toHaveBeenCalled();
|
21
|
+
});
|
22
|
+
});
|
23
|
+
describe("with selected admin set having no restrictions", function() {
|
24
|
+
beforeEach(function() {
|
25
|
+
var fixture = setFixtures(visibilityForm('<option selected="selected">No Restrictions AdminSet</option>'));
|
26
|
+
element = fixture.find('.visibility');
|
27
|
+
target = new control.VisibilityComponent(element);
|
28
|
+
spyOn(target, 'enableAllOptions');
|
29
|
+
});
|
30
|
+
it("enables all visibility options", function() {
|
31
|
+
target.limitByAdminSet();
|
32
|
+
expect(target.enableAllOptions).toHaveBeenCalled();
|
33
|
+
});
|
34
|
+
});
|
35
|
+
describe("with selected admin set having visibility restrictions only", function() {
|
36
|
+
beforeEach(function() {
|
37
|
+
var fixture = setFixtures(visibilityForm('<option data-visibility="authenticated" selected="selected">Institution-Only AdminSet</option>'));
|
38
|
+
element = fixture.find('.visibility');
|
39
|
+
target = new control.VisibilityComponent(element);
|
40
|
+
spyOn(target, 'applyRestrictions');
|
41
|
+
});
|
42
|
+
it("calls applyRestrictions with specified visibility", function() {
|
43
|
+
target.limitByAdminSet();
|
44
|
+
expect(target.applyRestrictions).toHaveBeenCalledWith('authenticated', undefined, undefined);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
describe("with selected admin set having release immediately restrictions (no visibility)", function() {
|
48
|
+
beforeEach(function() {
|
49
|
+
var fixture = setFixtures(visibilityForm('<option data-release-date="' + target.getToday() + '" data-release-before-date="false" selected="selected">Release Immediately AdminSet</option>'));
|
50
|
+
element = fixture.find('.visibility');
|
51
|
+
target = new control.VisibilityComponent(element);
|
52
|
+
spyOn(target, 'applyRestrictions');
|
53
|
+
});
|
54
|
+
it("calls applyRestrictions with specified date requirement", function() {
|
55
|
+
target.limitByAdminSet();
|
56
|
+
expect(target.applyRestrictions).toHaveBeenCalledWith(undefined, target.getToday(), false);
|
57
|
+
});
|
58
|
+
});
|
59
|
+
describe("with selected admin set having release publicly immediately restrictions", function() {
|
60
|
+
beforeEach(function() {
|
61
|
+
var fixture = setFixtures(visibilityForm('<option data-visibility="open" data-release-date="' + target.getToday() + '" data-release-before-date="false" selected="selected">Release Publicly Immediately AdminSet</option>'));
|
62
|
+
element = fixture.find('.visibility');
|
63
|
+
target = new control.VisibilityComponent(element);
|
64
|
+
spyOn(target, 'applyRestrictions');
|
65
|
+
});
|
66
|
+
it("calls applyRestrictions with specified date and visibility requirement", function() {
|
67
|
+
target.limitByAdminSet();
|
68
|
+
expect(target.applyRestrictions).toHaveBeenCalledWith("open", target.getToday(), false);
|
69
|
+
});
|
70
|
+
});
|
71
|
+
describe("with selected admin set having release on future date set", function() {
|
72
|
+
beforeEach(function() {
|
73
|
+
var fixture = setFixtures(visibilityForm('<option data-release-date="' + getOneYearFromToday() + '" data-release-before-date="false" selected="selected">Release in One Year AdminSet</option>'));
|
74
|
+
element = fixture.find('.visibility');
|
75
|
+
target = new control.VisibilityComponent(element);
|
76
|
+
spyOn(target, 'applyRestrictions');
|
77
|
+
});
|
78
|
+
it("calls applyRestrictions with specified date requirement", function() {
|
79
|
+
target.limitByAdminSet();
|
80
|
+
expect(target.applyRestrictions).toHaveBeenCalledWith(undefined, getOneYearFromToday(), false);
|
81
|
+
});
|
82
|
+
});
|
83
|
+
describe("with selected admin set having release to institution before one year set", function() {
|
84
|
+
beforeEach(function() {
|
85
|
+
var fixture = setFixtures(visibilityForm('<option data-visibility="authenticated" data-release-date="' + getOneYearFromToday() + '" data-release-before-date="true" selected="selected">Release in One Year to Institution AdminSet</option>'));
|
86
|
+
element = fixture.find('.visibility');
|
87
|
+
target = new control.VisibilityComponent(element);
|
88
|
+
spyOn(target, 'applyRestrictions');
|
89
|
+
});
|
90
|
+
it("calls applyRestrictions with specified date and visibility requirement", function() {
|
91
|
+
target.limitByAdminSet();
|
92
|
+
expect(target.applyRestrictions).toHaveBeenCalledWith("authenticated", getOneYearFromToday(), true);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
});
|
96
|
+
|
97
|
+
//applyRestrictions(visibility, release_date, release_before)
|
98
|
+
describe("applyRestrictions", function() {
|
99
|
+
describe("with visibility restrictions only (no release date requirements)", function() {
|
100
|
+
beforeEach(function() {
|
101
|
+
spyOn(target, 'enableReleaseNowOrEmbargo');
|
102
|
+
});
|
103
|
+
it("enable that visibility option OR embargo, and limit embargo to any future date", function() {
|
104
|
+
target.applyRestrictions("authenticated", undefined, undefined);
|
105
|
+
expect(target.enableReleaseNowOrEmbargo).toHaveBeenCalledWith("authenticated", undefined, undefined);
|
106
|
+
});
|
107
|
+
});
|
108
|
+
describe("with release date of today (immediately) and no visibility", function() {
|
109
|
+
beforeEach(function() {
|
110
|
+
spyOn(target, 'disableEmbargoAndLease');
|
111
|
+
});
|
112
|
+
it("disables embargo and lease options", function() {
|
113
|
+
target.applyRestrictions(undefined, target.getToday(), false);
|
114
|
+
expect(target.disableEmbargoAndLease).toHaveBeenCalled();
|
115
|
+
});
|
116
|
+
});
|
117
|
+
describe("with release date of today (immediately) and required visibility", function() {
|
118
|
+
beforeEach(function() {
|
119
|
+
spyOn(target, 'selectVisibility');
|
120
|
+
});
|
121
|
+
it("selects that visibility (disabling other options)", function() {
|
122
|
+
target.applyRestrictions("open", target.getToday(), false);
|
123
|
+
expect(target.selectVisibility).toHaveBeenCalledWith("open");
|
124
|
+
});
|
125
|
+
});
|
126
|
+
describe("with required visibility and embargo allowed (release before future date)", function() {
|
127
|
+
beforeEach(function() {
|
128
|
+
spyOn(target, 'enableReleaseNowOrEmbargo');
|
129
|
+
});
|
130
|
+
it("allows any date between now and future date", function() {
|
131
|
+
var futureDate = getOneYearFromToday();
|
132
|
+
target.applyRestrictions("open", futureDate, true);
|
133
|
+
expect(target.enableReleaseNowOrEmbargo).toHaveBeenCalledWith("open", futureDate, true);
|
134
|
+
});
|
135
|
+
});
|
136
|
+
describe("with required future release date, and any visibility allowed", function() {
|
137
|
+
beforeEach(function() {
|
138
|
+
spyOn(target, 'requireEmbargo');
|
139
|
+
});
|
140
|
+
it("require embargo until release_date and don't restrict visibility", function() {
|
141
|
+
var futureDate = getOneYearFromToday();
|
142
|
+
target.applyRestrictions(undefined, futureDate, false);
|
143
|
+
expect(target.requireEmbargo).toHaveBeenCalledWith(undefined, futureDate);
|
144
|
+
});
|
145
|
+
});
|
146
|
+
describe("with required future release date, and required visibility", function() {
|
147
|
+
beforeEach(function() {
|
148
|
+
spyOn(target, 'requireEmbargo');
|
149
|
+
});
|
150
|
+
it("require embargo until release_date and require visibility", function() {
|
151
|
+
var futureDate = getOneYearFromToday();
|
152
|
+
target.applyRestrictions("authenticated", futureDate, false);
|
153
|
+
expect(target.requireEmbargo).toHaveBeenCalledWith("authenticated", futureDate);
|
154
|
+
});
|
155
|
+
});
|
156
|
+
});
|
157
|
+
|
158
|
+
//selectVisibility(visibility)
|
159
|
+
describe("selectVisibility", function() {
|
160
|
+
describe("with 'open' passed in", function() {
|
161
|
+
it("selects the required open visibility, disabling all other options", function() {
|
162
|
+
target.selectVisibility("open");
|
163
|
+
expect(element.find("[type='radio'][value='open']")).toBeChecked();
|
164
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
165
|
+
expect(element.find("[type='radio'][value='authenticated']")).toBeDisabled();
|
166
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeDisabled();
|
167
|
+
expect(element.find("[type='radio'][value='restricted']")).toBeDisabled();
|
168
|
+
expect(element.find("[type='radio'][value='lease']")).toBeDisabled();
|
169
|
+
});
|
170
|
+
});
|
171
|
+
describe("with 'restricted' passed in", function() {
|
172
|
+
it("selects the required restricted visibility, disabling all other options", function() {
|
173
|
+
target.selectVisibility("restricted");
|
174
|
+
expect(element.find("[type='radio'][value='open']")).toBeDisabled();
|
175
|
+
expect(element.find("[type='radio'][value='authenticated']")).toBeDisabled();
|
176
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeDisabled();
|
177
|
+
expect(element.find("[type='radio'][value='restricted']")).toBeChecked();
|
178
|
+
expect(element.find("[type='radio'][value='restricted']")).not.toBeDisabled();
|
179
|
+
expect(element.find("[type='radio'][value='lease']")).toBeDisabled();
|
180
|
+
});
|
181
|
+
});
|
182
|
+
});
|
183
|
+
|
184
|
+
//enableReleaseNowOrEmbargo(visibility, release_date, release_before)
|
185
|
+
describe("enableReleaseNowOrEmbargo", function() {
|
186
|
+
describe("with visibility only", function() {
|
187
|
+
it("enable that visibility option OR embargo, restrict release_date to after today, and set visibility after embargo", function() {
|
188
|
+
target.enableReleaseNowOrEmbargo("open", undefined, undefined);
|
189
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
190
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
191
|
+
expect(target.getEmbargoDateInput()).toHaveProp("min", target.getToday());
|
192
|
+
expect(target.getEmbargoDateInput()).not.toBeDisabled();
|
193
|
+
expect(target.getVisibilityAfterEmbargoInput()).toHaveValue("open");
|
194
|
+
expect(target.getVisibilityAfterEmbargoInput()).toBeDisabled();
|
195
|
+
});
|
196
|
+
});
|
197
|
+
describe("with visibility and release_date range", function() {
|
198
|
+
it("enable that visibility OR embargo, restrict release_date to range, and set visibility after embargo", function() {
|
199
|
+
var futureDate = getOneYearFromToday();
|
200
|
+
target.enableReleaseNowOrEmbargo("authenticated", futureDate, true);
|
201
|
+
// enable immediate release or embargo with given visibility
|
202
|
+
expect(element.find("[type='radio'][value='authenticated']")).not.toBeDisabled();
|
203
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
204
|
+
// restrict embargo date range
|
205
|
+
expect(target.getEmbargoDateInput()).toHaveProp("min", target.getToday());
|
206
|
+
expect(target.getEmbargoDateInput()).toHaveProp("max", futureDate);
|
207
|
+
expect(target.getEmbargoDateInput()).not.toBeDisabled();
|
208
|
+
// require visibility after embargo
|
209
|
+
expect(target.getVisibilityAfterEmbargoInput()).toHaveValue("authenticated");
|
210
|
+
expect(target.getVisibilityAfterEmbargoInput()).toBeDisabled();
|
211
|
+
});
|
212
|
+
});
|
213
|
+
});
|
214
|
+
|
215
|
+
//disableEmbargoAndLease
|
216
|
+
describe("disableEmbargoAndLease", function() {
|
217
|
+
it("Disables embargo and lease options, enabling all others", function() {
|
218
|
+
target.disableEmbargoAndLease();
|
219
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
220
|
+
expect(element.find("[type='radio'][value='authenticated']")).not.toBeDisabled();
|
221
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeDisabled();
|
222
|
+
expect(element.find("[type='radio'][value='restricted']")).not.toBeDisabled();
|
223
|
+
expect(element.find("[type='radio'][value='lease']")).toBeDisabled();
|
224
|
+
});
|
225
|
+
});
|
226
|
+
|
227
|
+
//requireEmbargo(visibility, release_date)
|
228
|
+
describe("requireEmbargo", function() {
|
229
|
+
describe("with release_date only", function() {
|
230
|
+
it("select 'embargo', require that release_date, allow any visibility", function() {
|
231
|
+
target.requireEmbargo(undefined, "2017-01-01");
|
232
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeChecked();
|
233
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
234
|
+
expect(target.getEmbargoDateInput()).toHaveValue("2017-01-01");
|
235
|
+
expect(target.getEmbargoDateInput()).toBeDisabled();
|
236
|
+
expect(target.getVisibilityAfterEmbargoInput()).not.toBeDisabled();
|
237
|
+
});
|
238
|
+
});
|
239
|
+
describe("with release_date and visibility", function() {
|
240
|
+
it("select 'embargo', require that release_date, require visibility", function() {
|
241
|
+
target.requireEmbargo("open", "2017-01-01");
|
242
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeChecked();
|
243
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
244
|
+
expect(target.getEmbargoDateInput()).toHaveValue("2017-01-01");
|
245
|
+
expect(target.getEmbargoDateInput()).toBeDisabled();
|
246
|
+
expect(target.getVisibilityAfterEmbargoInput()).toHaveValue("open");
|
247
|
+
expect(target.getVisibilityAfterEmbargoInput()).toBeDisabled();
|
248
|
+
});
|
249
|
+
});
|
250
|
+
});
|
251
|
+
|
252
|
+
//enableVisibilityOptions(options)
|
253
|
+
describe("enableVisibilityOptions", function() {
|
254
|
+
describe("with array of options", function() {
|
255
|
+
it("enables listed radio buttons, and disables any unlisted", function() {
|
256
|
+
target.enableVisibilityOptions(["open","restricted"]);
|
257
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
258
|
+
expect(element.find("[type='radio'][value='authenticated']")).toBeDisabled();
|
259
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeDisabled();
|
260
|
+
expect(element.find("[type='radio'][value='restricted']")).not.toBeDisabled();
|
261
|
+
});
|
262
|
+
});
|
263
|
+
describe("with no options", function() {
|
264
|
+
it("disables all radio buttons", function() {
|
265
|
+
target.enableVisibilityOptions([]);
|
266
|
+
expect(element.find("[type='radio'][value='open']")).toBeDisabled();
|
267
|
+
expect(element.find("[type='radio'][value='authenticated']")).toBeDisabled();
|
268
|
+
expect(element.find("[type='radio'][value='embargo']")).toBeDisabled();
|
269
|
+
expect(element.find("[type='radio'][value='restricted']")).toBeDisabled();
|
270
|
+
});
|
271
|
+
});
|
272
|
+
});
|
273
|
+
|
274
|
+
//disableVisibilityOptions(options)
|
275
|
+
describe("disableVisibilityOptions", function() {
|
276
|
+
describe("with array of options", function() {
|
277
|
+
it("disables listed radio buttons, and enables any unlisted", function() {
|
278
|
+
target.disableVisibilityOptions(["open","restricted"]);
|
279
|
+
expect(element.find("[type='radio'][value='open']")).toBeDisabled();
|
280
|
+
expect(element.find("[type='radio'][value='authenticated']")).not.toBeDisabled();
|
281
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
282
|
+
expect(element.find("[type='radio'][value='restricted']")).toBeDisabled();
|
283
|
+
});
|
284
|
+
});
|
285
|
+
describe("with no options", function() {
|
286
|
+
it("enables all radio buttons", function() {
|
287
|
+
target.disableVisibilityOptions([]);
|
288
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
289
|
+
expect(element.find("[type='radio'][value='authenticated']")).not.toBeDisabled();
|
290
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
291
|
+
expect(element.find("[type='radio'][value='restricted']")).not.toBeDisabled();
|
292
|
+
});
|
293
|
+
});
|
294
|
+
});
|
295
|
+
|
296
|
+
//getMatcherForVisibilities(options)
|
297
|
+
describe("getMatcherForVisibilities", function() {
|
298
|
+
describe("with array of options", function() {
|
299
|
+
it("returns a jQuery matcher to match ONLY visibility radio buttons listed in options", function() {
|
300
|
+
expect(target.getMatcherForVisibilities(["one","two","three"])).toEqual("[type='radio'][value='one'],[type='radio'][value='two'],[type='radio'][value='three']");
|
301
|
+
});
|
302
|
+
});
|
303
|
+
describe("with no options", function() {
|
304
|
+
it("returns an empty string (matches none of the radio buttons)", function() {
|
305
|
+
expect(target.getMatcherForVisibilities([])).toEqual("");
|
306
|
+
});
|
307
|
+
});
|
308
|
+
});
|
309
|
+
|
310
|
+
//getMatcherForNotVisibilities(options)
|
311
|
+
describe("getMatcherForNotVisibilities", function() {
|
312
|
+
describe("with array of options", function() {
|
313
|
+
it("returns a jQuery matcher to match visibility radio buttons NOT listed in options", function() {
|
314
|
+
expect(target.getMatcherForNotVisibilities(["one","two","three"])).toEqual("[type='radio'][value!='one'][value!='two'][value!='three']");
|
315
|
+
});
|
316
|
+
});
|
317
|
+
describe("with no options", function() {
|
318
|
+
it("returns a jQuery matcher to match all visibility radio buttons", function() {
|
319
|
+
expect(target.getMatcherForNotVisibilities([])).toEqual("[type='radio']");
|
320
|
+
});
|
321
|
+
});
|
322
|
+
});
|
323
|
+
|
324
|
+
//restrictEmbargoDate(release_date, release_before)
|
325
|
+
describe("restrictEmbargoDate", function() {
|
326
|
+
describe("with no date specified", function() {
|
327
|
+
it("sets a minimum date of today", function() {
|
328
|
+
target.restrictEmbargoDate("",false);
|
329
|
+
expect(target.getEmbargoDateInput()).toHaveProp("min", target.getToday());
|
330
|
+
});
|
331
|
+
});
|
332
|
+
describe("with exact release_date specified", function() {
|
333
|
+
it("sets release_date and disables field", function() {
|
334
|
+
target.restrictEmbargoDate("2017-01-01",false);
|
335
|
+
var input = target.getEmbargoDateInput();
|
336
|
+
expect(input).toHaveValue("2017-01-01");
|
337
|
+
expect(input).toBeDisabled();
|
338
|
+
});
|
339
|
+
});
|
340
|
+
describe("with release_date specified and prior dates allowed", function() {
|
341
|
+
it("sets minimum date of today, maximum date of release_date and enables field", function() {
|
342
|
+
var futureDate = getOneYearFromToday();
|
343
|
+
target.restrictEmbargoDate(futureDate, true);
|
344
|
+
var input = target.getEmbargoDateInput();
|
345
|
+
expect(input).toHaveProp("min", target.getToday());
|
346
|
+
expect(input).toHaveProp("max", futureDate);
|
347
|
+
expect(input).not.toBeDisabled();
|
348
|
+
});
|
349
|
+
});
|
350
|
+
});
|
351
|
+
|
352
|
+
// selectVisibilityAfterEmbargo(visibility)
|
353
|
+
describe("selectVisibilityAfterEmbargo", function() {
|
354
|
+
describe("with 'open'", function() {
|
355
|
+
it("selects 'open' option and disables field", function() {
|
356
|
+
target.selectVisibilityAfterEmbargo("open");
|
357
|
+
var input = target.getVisibilityAfterEmbargoInput();
|
358
|
+
expect(input.find("option[value='open']")).toBeSelected();
|
359
|
+
expect(input).toBeDisabled();
|
360
|
+
});
|
361
|
+
});
|
362
|
+
describe("with no option", function() {
|
363
|
+
it("enables field", function() {
|
364
|
+
target.selectVisibilityAfterEmbargo("");
|
365
|
+
var input = target.getVisibilityAfterEmbargoInput();
|
366
|
+
expect(input).not.toBeDisabled();
|
367
|
+
});
|
368
|
+
});
|
369
|
+
});
|
370
|
+
|
371
|
+
// enableAllOptions()
|
372
|
+
describe("enableAllOptions", function() {
|
373
|
+
beforeEach(function() {
|
374
|
+
element.find("[type='radio'][value='open']").prop("disabled", true);
|
375
|
+
target.getEmbargoDateInput().prop("disabled", true);
|
376
|
+
target.getVisibilityAfterEmbargoInput().prop("disabled", true);
|
377
|
+
});
|
378
|
+
it("enables all visibility fields", function() {
|
379
|
+
target.enableAllOptions();
|
380
|
+
expect(element.find("[type='radio'][value='open']")).not.toBeDisabled();
|
381
|
+
expect(element.find("[type='radio'][value='authenticated']")).not.toBeDisabled();
|
382
|
+
expect(element.find("[type='radio'][value='embargo']")).not.toBeDisabled();
|
383
|
+
expect(element.find("[type='radio'][value='restricted']")).not.toBeDisabled();
|
384
|
+
expect(element.find("[type='radio'][value='lease']")).not.toBeDisabled();
|
385
|
+
expect(target.getEmbargoDateInput()).not.toBeDisabled();
|
386
|
+
expect(target.getVisibilityAfterEmbargoInput()).not.toBeDisabled();
|
387
|
+
});
|
388
|
+
});
|
389
|
+
|
390
|
+
// getEmbargoDateInput()
|
391
|
+
describe("getEmbargoDateInput", function() {
|
392
|
+
it("returns embargo date input", function() {
|
393
|
+
expect(target.getEmbargoDateInput()).toHaveProp("name", "generic_work[embargo_release_date]");
|
394
|
+
});
|
395
|
+
});
|
396
|
+
|
397
|
+
// getVisibilityAfterEmbargoInput()
|
398
|
+
describe("getVisibilityAfterEmbargoInput", function() {
|
399
|
+
it("returns visibility after embargo selectbox", function() {
|
400
|
+
expect(target.getVisibilityAfterEmbargoInput()).toHaveProp("name", "generic_work[visibility_after_embargo]");
|
401
|
+
});
|
402
|
+
});
|
403
|
+
|
404
|
+
// isToday(dateString)
|
405
|
+
describe("isToday", function() {
|
406
|
+
describe("with today's date", function() {
|
407
|
+
it("is true", function() {
|
408
|
+
expect(target.isToday(target.getToday())).toEqual(true);
|
409
|
+
});
|
410
|
+
});
|
411
|
+
describe("with past date", function() {
|
412
|
+
it("is false", function() {
|
413
|
+
expect(target.isToday("2016-12-31")).toEqual(false);
|
414
|
+
});
|
415
|
+
});
|
416
|
+
describe("with future date", function() {
|
417
|
+
it("is false", function() {
|
418
|
+
expect(target.isToday(getOneYearFromToday())).toEqual(false);
|
419
|
+
});
|
420
|
+
});
|
421
|
+
});
|
422
|
+
});
|
423
|
+
|
424
|
+
// Generate a form that includes AdminSet selectbox (with a passed in option)
|
425
|
+
// AND the visibility radio button options
|
426
|
+
function visibilityForm(admin_set_option) {
|
427
|
+
return '<form id="new_generic_work">' +
|
428
|
+
' <div>' +
|
429
|
+
' <select id="generic_work_admin_set_id">' +
|
430
|
+
' ' + admin_set_option +
|
431
|
+
' </select>' +
|
432
|
+
' </div>' +
|
433
|
+
' <div>' +
|
434
|
+
' <ul class="visibility">' +
|
435
|
+
' <li class="radio">' +
|
436
|
+
' <label>' +
|
437
|
+
' <input data-target="#collapsePublic" type="radio" value="open" name="generic_work[visibility]"/>Public' +
|
438
|
+
' <div class="collapse in" id="collapsePublic">' +
|
439
|
+
' <p>Public message that is collapsed by default</p>' +
|
440
|
+
' </div>' +
|
441
|
+
' </label>' +
|
442
|
+
' </li>' +
|
443
|
+
' <li class="radio">' +
|
444
|
+
' <label>' +
|
445
|
+
' <input type="radio" value="authenticated" name="generic_work[visibility]"/>Your Institution' +
|
446
|
+
' </label>' +
|
447
|
+
' </li>' +
|
448
|
+
' <li class="radio">' +
|
449
|
+
' <label>' +
|
450
|
+
' <input data-target="#collapseEmbargo" type="radio" value="embargo" name="generic_work[visibility]"/>Embargo' +
|
451
|
+
' <div class="collapse in" id="collapseEmbargo">' +
|
452
|
+
' <input type="date" id="generic_work_embargo_release_date" name="generic_work[embargo_release_date]"/>' +
|
453
|
+
' <select id="generic_work_visibility_after_embargo" name="generic_work[visibility_after_embargo]">' +
|
454
|
+
' <option value="open">Open Access</option>' +
|
455
|
+
' <option value="authenticated">Institution Name</option>' +
|
456
|
+
' </select>' +
|
457
|
+
' </div>' +
|
458
|
+
' </label>' +
|
459
|
+
' </li>' +
|
460
|
+
' <li class="radio">' +
|
461
|
+
' <label>' +
|
462
|
+
' <input type="radio" value="lease" name="generic_work[visibility]"/>Lease' +
|
463
|
+
' </label>' +
|
464
|
+
' </li>' +
|
465
|
+
' <li class="radio">' +
|
466
|
+
' <label>' +
|
467
|
+
' <input type="radio" value="restricted" name="generic_work[visibility]"/>Private' +
|
468
|
+
' </label>' +
|
469
|
+
' </li>' +
|
470
|
+
' </ul>' +
|
471
|
+
' </div>' +
|
472
|
+
'</form>';
|
473
|
+
}
|
474
|
+
|
475
|
+
|
476
|
+
// Get the date one year from today in YYYY-MM-DD format
|
477
|
+
function getOneYearFromToday() {
|
478
|
+
var today = new Date();
|
479
|
+
var dd = today.getDate();
|
480
|
+
var mm = today.getMonth() + 1; // January is month 0
|
481
|
+
var yyyy = today.getFullYear() + 1; // Add one year to this year
|
482
|
+
|
483
|
+
// prepend zeros as needed
|
484
|
+
if(dd < 10) {
|
485
|
+
dd = '0' + dd;
|
486
|
+
}
|
487
|
+
if(mm < 10) {
|
488
|
+
mm = '0' + mm;
|
489
|
+
}
|
490
|
+
return yyyy + '-' + mm + '-' + dd;
|
491
|
+
}
|