curation_concerns 1.4.0 → 1.5.0
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/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -2
- data/app/actors/curation_concerns/actors/file_actor.rb +2 -3
- data/app/assets/javascripts/curation_concerns/file_manager.es6 +32 -1
- data/app/assets/javascripts/curation_concerns/file_manager/member.es6 +6 -0
- data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -2
- data/app/assets/stylesheets/curation_concerns/modules/file_manager.scss +14 -0
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +3 -3
- data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +2 -2
- data/app/indexers/curation_concerns/admin_set_indexer.rb +13 -0
- data/app/indexers/curation_concerns/file_set_indexer.rb +5 -0
- data/app/indexers/curation_concerns/work_indexer.rb +3 -0
- data/app/models/admin_set.rb +3 -0
- data/app/models/concerns/curation_concerns/admin_set_behavior.rb +29 -0
- data/app/models/concerns/curation_concerns/file_set/characterization.rb +2 -1
- data/app/models/concerns/curation_concerns/in_admin_set.rb +9 -0
- data/app/models/concerns/curation_concerns/publishable.rb +19 -0
- data/app/models/concerns/curation_concerns/solr_behavior/characterization.rb +106 -0
- data/app/models/concerns/curation_concerns/solr_document_behavior.rb +5 -0
- data/app/models/concerns/curation_concerns/work_behavior.rb +2 -0
- data/app/models/curation_concerns/state_workflow.rb +13 -0
- data/app/models/vocab/fedora_resource_status.rb +6 -0
- data/app/presenters/curation_concerns/characterization_behavior.rb +84 -0
- data/app/presenters/curation_concerns/file_set_presenter.rb +1 -0
- data/app/presenters/curation_concerns/work_show_presenter.rb +1 -1
- data/app/search_builders/curation_concerns/admin_set_search_builder.rb +22 -0
- data/app/services/curation_concerns/admin_set_service.rb +26 -0
- data/app/services/curation_concerns/indexes_thumbnails.rb +1 -0
- data/app/services/curation_concerns/license_service.rb +8 -0
- data/app/services/curation_concerns/qa_select_service.rb +33 -0
- data/app/services/curation_concerns/rights_statements.rb +8 -0
- data/app/services/rights_service.rb +9 -2
- data/app/views/collections/_button_create_collection.html.erb +1 -1
- data/app/views/collections/_button_for_update_collection.html.erb +1 -1
- data/app/views/curation_concerns/base/_file_manager_actions.html.erb +1 -0
- data/app/views/curation_concerns/base/_file_manager_member.html.erb +24 -23
- data/app/views/curation_concerns/base/_file_manager_member_resource_options.html.erb +6 -0
- data/app/views/curation_concerns/base/_file_manager_resource_form.html.erb +5 -0
- data/app/views/curation_concerns/base/_form_rights.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +18 -9
- data/app/views/curation_concerns/file_sets/media_display/_image.html.erb +18 -13
- data/app/views/curation_concerns/file_sets/media_display/_office_document.html.erb +18 -13
- data/app/views/curation_concerns/file_sets/media_display/_pdf.html.erb +18 -13
- data/config/locales/curation_concerns.en.yml +6 -0
- data/curation_concerns.gemspec +2 -2
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/generators/curation_concerns/install_generator.rb +6 -9
- data/lib/generators/curation_concerns/templates/config/authorities/{rights.yml → licenses.yml} +0 -0
- data/lib/generators/curation_concerns/templates/config/authorities/rights_statements.yml +37 -0
- data/spec/abilities/admin_set_abilities_spec.rb +15 -0
- data/spec/actors/curation_concerns/file_actor_spec.rb +1 -2
- data/spec/controllers/catalog_controller_spec.rb +9 -11
- data/spec/controllers/curation_concerns/classify_concerns_controller_spec.rb +2 -2
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +39 -33
- data/spec/controllers/curation_concerns/file_sets_controller_json_spec.rb +10 -10
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +54 -35
- data/spec/controllers/curation_concerns/generic_works_controller_json_spec.rb +6 -6
- data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +30 -35
- data/spec/controllers/curation_concerns/operations_controller_spec.rb +2 -2
- data/spec/controllers/curation_concerns/permissions_controller_spec.rb +2 -2
- data/spec/controllers/curation_concerns/single_use_links_controller_spec.rb +10 -10
- data/spec/controllers/curation_concerns/single_use_links_viewer_controller_spec.rb +7 -12
- data/spec/controllers/downloads_controller_spec.rb +15 -19
- data/spec/controllers/embargoes_controller_spec.rb +6 -6
- data/spec/controllers/leases_controller_spec.rb +6 -6
- data/spec/factories/admin_sets.rb +9 -0
- data/spec/indexers/file_set_indexer_spec.rb +11 -2
- data/spec/indexers/work_indexer_spec.rb +41 -20
- data/spec/models/admin_set_spec.rb +78 -0
- data/spec/models/curation_concerns/file_set/characterization_spec.rb +1 -1
- data/spec/models/file_set_spec.rb +4 -1
- data/spec/models/generic_work_spec.rb +24 -1
- data/spec/models/solr_document_spec.rb +30 -0
- data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +131 -6
- data/spec/renderers/curation_concerns/renderers/attribute_renderer_spec.rb +1 -4
- data/spec/search_builders/curation_concerns/admin_set_search_builder_spec.rb +17 -0
- data/spec/services/curation_concerns/admin_set_service_spec.rb +37 -0
- data/spec/services/curation_concerns/license_service_spec.rb +36 -0
- data/spec/services/curation_concerns/rights_statements_spec.rb +11 -0
- data/spec/services/rights_service_spec.rb +2 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/backport_test.rb +14 -0
- data/spec/support/curation_concerns/factory_helpers.rb +3 -1
- data/spec/test_app_templates/Gemfile.extra +0 -2
- data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +13 -1
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +8 -8
- metadata +40 -7
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
<% if CurationConcerns.config.display_media_download_link %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<div>
|
|
3
|
+
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
|
|
4
|
+
<%= image_tag thumbnail_url(file_set),
|
|
5
|
+
class: "representative-media",
|
|
6
|
+
alt: "",
|
|
7
|
+
role: "presentation" %>
|
|
8
|
+
<%= link_to main_app.download_path(file_set),
|
|
9
|
+
target: "_new",
|
|
10
|
+
class: "btn btn-default" do %>
|
|
11
|
+
<%= t('curation_concerns.show.downloadable_content.office_link') %>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
10
14
|
<% else %>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
<div>
|
|
16
|
+
<%= image_tag thumbnail_url(file_set),
|
|
17
|
+
class: "representative-media",
|
|
18
|
+
alt: "",
|
|
19
|
+
role: "presentation" %>
|
|
20
|
+
</div>
|
|
16
21
|
<% end %>
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
<% if CurationConcerns.config.display_media_download_link %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<div>
|
|
3
|
+
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
|
|
4
|
+
<%= image_tag thumbnail_url(file_set),
|
|
5
|
+
class: "representative-media",
|
|
6
|
+
alt: "",
|
|
7
|
+
role: "presentation" %>
|
|
8
|
+
<%= link_to main_app.download_path(file_set),
|
|
9
|
+
target: "_new",
|
|
10
|
+
class: "btn btn-default" do %>
|
|
11
|
+
<%= t('curation_concerns.show.downloadable_content.pdf_link') %>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
10
14
|
<% else %>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
<div>
|
|
16
|
+
<%= image_tag thumbnail_url(file_set),
|
|
17
|
+
class: "representative-media",
|
|
18
|
+
alt: "",
|
|
19
|
+
role: "presentation" %>
|
|
20
|
+
</div>
|
|
16
21
|
<% end %>
|
|
@@ -16,6 +16,12 @@ en:
|
|
|
16
16
|
show:
|
|
17
17
|
related_files:
|
|
18
18
|
heading: 'Members'
|
|
19
|
+
downloadable_content:
|
|
20
|
+
heading: 'Downloadable Content'
|
|
21
|
+
default_link: 'Download file'
|
|
22
|
+
image_link: 'Download image'
|
|
23
|
+
office_link: 'Download file'
|
|
24
|
+
pdf_link: 'Download PDF'
|
|
19
25
|
search:
|
|
20
26
|
form:
|
|
21
27
|
q:
|
data/curation_concerns.gemspec
CHANGED
|
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
21
|
spec.add_dependency 'hydra-head', '>= 10.0.0', '< 11'
|
|
22
|
-
spec.add_dependency 'active-fedora', '>=
|
|
22
|
+
spec.add_dependency 'active-fedora', '>= 10.3.0.rc1'
|
|
23
23
|
spec.add_dependency 'blacklight', '~> 6.3'
|
|
24
|
-
spec.add_dependency 'breadcrumbs_on_rails', '>=
|
|
24
|
+
spec.add_dependency 'breadcrumbs_on_rails', '>= 3.0.1', '< 4'
|
|
25
25
|
spec.add_dependency 'jquery-ui-rails'
|
|
26
26
|
spec.add_dependency 'simple_form', '~> 3.1'
|
|
27
27
|
spec.add_dependency 'hydra-editor', '>= 2', '< 4'
|
|
@@ -15,9 +15,8 @@ module CurationConcerns
|
|
|
15
15
|
5. Adds CurationConcerns abilities into the Ability class
|
|
16
16
|
6. Copies the catalog controller into the local app
|
|
17
17
|
7. Adds CurationConcerns::SolrDocumentBehavior to app/models/solr_document.rb
|
|
18
|
-
8. Adds
|
|
19
|
-
9.
|
|
20
|
-
10. Copies modified simple_form initializers
|
|
18
|
+
8. Adds local authority files to the application
|
|
19
|
+
9. Copies modified simple_form initializers
|
|
21
20
|
'
|
|
22
21
|
|
|
23
22
|
def run_required_generators
|
|
@@ -93,12 +92,10 @@ module CurationConcerns
|
|
|
93
92
|
copy_file 'curation_concerns_helper.rb', 'app/helpers/curation_concerns_helper.rb'
|
|
94
93
|
end
|
|
95
94
|
|
|
96
|
-
def
|
|
97
|
-
copy_file "config/authorities/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def resource_types_config
|
|
101
|
-
copy_file "config/authorities/resource_types.yml", "config/authorities/resource_types.yml"
|
|
95
|
+
def local_authorities
|
|
96
|
+
copy_file "config/authorities/licenses.yml"
|
|
97
|
+
copy_file "config/authorities/rights_statements.yml"
|
|
98
|
+
copy_file "config/authorities/resource_types.yml"
|
|
102
99
|
end
|
|
103
100
|
|
|
104
101
|
def simple_form_initializers
|
data/lib/generators/curation_concerns/templates/config/authorities/{rights.yml → licenses.yml}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
terms:
|
|
2
|
+
- id: http://rightsstatements.org/vocab/InC/1.0/
|
|
3
|
+
term: "In Copyright"
|
|
4
|
+
active: true
|
|
5
|
+
- id: http://rightsstatements.org/vocab/InC-OW-EU/1.0/
|
|
6
|
+
term: "In Copyright - EU Orphan Work"
|
|
7
|
+
active: true
|
|
8
|
+
- id: http://rightsstatements.org/vocab/InC-EDU/1.0/
|
|
9
|
+
term: "In Copyright - Educational Use Permitted"
|
|
10
|
+
active: true
|
|
11
|
+
- id: http://rightsstatements.org/vocab/InC-NC/1.0/
|
|
12
|
+
term: "In Copyright - Non-Commercial Use Permitted"
|
|
13
|
+
active: true
|
|
14
|
+
- id: http://rightsstatements.org/vocab/InC-RUU/1.0/
|
|
15
|
+
term: "In Copyright - Rights-holder(s) Unlocatable or Unidentifiable"
|
|
16
|
+
active: true
|
|
17
|
+
- id: http://rightsstatements.org/vocab/NoC-CR/1.0/
|
|
18
|
+
term: "No Copyright - Contractual Restrictions"
|
|
19
|
+
active: true
|
|
20
|
+
- id: http://rightsstatements.org/vocab/NoC-NC/1.0/
|
|
21
|
+
term: "No Copyright - Non-Commercial Use Only "
|
|
22
|
+
active: true
|
|
23
|
+
- id: http://rightsstatements.org/vocab/NoC-OKLR/1.0/
|
|
24
|
+
term: "No Copyright - Other Known Legal Restrictions"
|
|
25
|
+
active: true
|
|
26
|
+
- id: http://rightsstatements.org/vocab/NoC-US/1.0/
|
|
27
|
+
term: "No Copyright - United States"
|
|
28
|
+
active: true
|
|
29
|
+
- id: http://rightsstatements.org/vocab/CNE/1.0/
|
|
30
|
+
term: "Copyright Not Evaluated"
|
|
31
|
+
active: true
|
|
32
|
+
- id: http://rightsstatements.org/vocab/UND/1.0/
|
|
33
|
+
term: "Copyright Undetermined"
|
|
34
|
+
active: true
|
|
35
|
+
- id: http://rightsstatements.org/vocab/NKC/1.0/
|
|
36
|
+
term: "No Known Copyright"
|
|
37
|
+
active: true
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cancan/matchers'
|
|
3
|
+
|
|
4
|
+
describe 'User Abilities' do
|
|
5
|
+
subject { ability }
|
|
6
|
+
let(:ability) { Ability.new(current_user) }
|
|
7
|
+
let(:user) { create(:user) }
|
|
8
|
+
let(:current_user) { user }
|
|
9
|
+
let(:admin_set) { create(:admin_set, edit_users: [user]) }
|
|
10
|
+
|
|
11
|
+
it "allows the edit_users to edit and read" do
|
|
12
|
+
is_expected.to be_able_to(:read, admin_set)
|
|
13
|
+
is_expected.to be_able_to(:edit, admin_set)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -30,8 +30,7 @@ describe CurationConcerns::Actors::FileActor do
|
|
|
30
30
|
|
|
31
31
|
it 'reverts to a previous version of a file' do
|
|
32
32
|
expect(CurationConcerns::VersioningService).to receive(:create).with(previous_version, user)
|
|
33
|
-
expect(
|
|
34
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set, file_path)
|
|
33
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, previous_version.id)
|
|
35
34
|
actor.revert_to(revision_id)
|
|
36
35
|
end
|
|
37
36
|
end
|
|
@@ -35,18 +35,16 @@ describe CatalogController do
|
|
|
35
35
|
|
|
36
36
|
context 'Searching all works' do
|
|
37
37
|
it 'returns all the works' do
|
|
38
|
-
get 'index', 'f' => { 'generic_type_sim' => 'Work' }
|
|
38
|
+
get 'index', params: { 'f' => { 'generic_type_sim' => 'Work' } }
|
|
39
39
|
expect(response).to be_successful
|
|
40
40
|
expect(assigns(:document_list).count).to eq 2
|
|
41
|
-
|
|
42
|
-
expect(assigns(:document_list).map(&:id)).to include(work_id)
|
|
43
|
-
end
|
|
41
|
+
expect(assigns(:document_list).map(&:id)).to include(work1.id, work2.id)
|
|
44
42
|
end
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
context 'Searching all collections' do
|
|
48
46
|
it 'returns all the works' do
|
|
49
|
-
get 'index', 'f' => { 'generic_type_sim' => 'Collection' }
|
|
47
|
+
get 'index', params: { 'f' => { 'generic_type_sim' => 'Collection' } }
|
|
50
48
|
expect(response).to be_successful
|
|
51
49
|
expect(assigns(:document_list).map(&:id)).to eq [collection.id]
|
|
52
50
|
end
|
|
@@ -54,7 +52,7 @@ describe CatalogController do
|
|
|
54
52
|
|
|
55
53
|
context 'searching just my works' do
|
|
56
54
|
it 'returns just my works' do
|
|
57
|
-
get 'index', works: 'mine', 'f' => { 'generic_type_sim' => 'Work' }
|
|
55
|
+
get 'index', params: { works: 'mine', 'f' => { 'generic_type_sim' => 'Work' } }
|
|
58
56
|
expect(response).to be_successful
|
|
59
57
|
expect(assigns(:document_list).map(&:id)).to eq [work1.id]
|
|
60
58
|
end
|
|
@@ -62,7 +60,7 @@ describe CatalogController do
|
|
|
62
60
|
|
|
63
61
|
context 'searching for one kind of work' do
|
|
64
62
|
it 'returns just the specified type' do
|
|
65
|
-
get 'index', 'f' => { 'human_readable_type_sim' => 'Generic Work' }
|
|
63
|
+
get 'index', params: { 'f' => { 'human_readable_type_sim' => 'Generic Work' } }
|
|
66
64
|
expect(response).to be_successful
|
|
67
65
|
expect(assigns(:document_list).map(&:id)).to include(work1.id, work2.id)
|
|
68
66
|
end
|
|
@@ -72,7 +70,7 @@ describe CatalogController do
|
|
|
72
70
|
let!(:work) { FactoryGirl.create(:generic_work, user: user, title: ["All my #{srand}"]) }
|
|
73
71
|
render_views
|
|
74
72
|
it 'returns json' do
|
|
75
|
-
|
|
73
|
+
get :index, xhr: true, params: { format: :json, q: work.title.first }
|
|
76
74
|
json = JSON.parse(response.body)
|
|
77
75
|
# Grab the doc corresponding to work and inspect the json
|
|
78
76
|
work_json = json['docs'].first
|
|
@@ -95,17 +93,17 @@ describe CatalogController do
|
|
|
95
93
|
|
|
96
94
|
context 'searching all works' do
|
|
97
95
|
it "returns other users' private works" do
|
|
98
|
-
get 'index', 'f' => { 'generic_type_sim' => 'Work' }
|
|
96
|
+
get 'index', params: { 'f' => { 'generic_type_sim' => 'Work' } }
|
|
99
97
|
expect(response).to be_successful
|
|
100
98
|
expect(assigns(:document_list).map(&:id)).to include(work1.id)
|
|
101
99
|
end
|
|
102
100
|
it "returns other users' embargoed works" do
|
|
103
|
-
get 'index', 'f' => { 'generic_type_sim' => 'Work' }
|
|
101
|
+
get 'index', params: { 'f' => { 'generic_type_sim' => 'Work' } }
|
|
104
102
|
expect(response).to be_successful
|
|
105
103
|
expect(assigns(:document_list).map(&:id)).to include(work2.id)
|
|
106
104
|
end
|
|
107
105
|
it "returns other users' private collections" do
|
|
108
|
-
get 'index', 'f' => { 'generic_type_sim' => 'Collection' }
|
|
106
|
+
get 'index', params: { 'f' => { 'generic_type_sim' => 'Collection' } }
|
|
109
107
|
expect(response).to be_successful
|
|
110
108
|
expect(assigns(:document_list).map(&:id)).to include(collection.id)
|
|
111
109
|
end
|
|
@@ -19,7 +19,7 @@ describe CurationConcerns::ClassifyConcernsController do
|
|
|
19
19
|
describe '#create' do
|
|
20
20
|
context 'without logging in' do
|
|
21
21
|
it 'redirect to login page if user is not logged in' do
|
|
22
|
-
post :create, classify: { curation_concern_type: 'GenericWork' }
|
|
22
|
+
post :create, params: { classify: { curation_concern_type: 'GenericWork' } }
|
|
23
23
|
expect(response).to redirect_to(main_app.user_session_path)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -34,7 +34,7 @@ describe CurationConcerns::ClassifyConcernsController do
|
|
|
34
34
|
let(:new_curation_concern_generic_work_path) { '/stub/path' }
|
|
35
35
|
|
|
36
36
|
it 'requires authentication' do
|
|
37
|
-
post :create, classify_concern: { curation_concern_type: 'GenericWork' }
|
|
37
|
+
post :create, params: { classify_concern: { curation_concern_type: 'GenericWork' } }
|
|
38
38
|
expect(response).to redirect_to(main_app.new_curation_concerns_generic_work_path)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -25,9 +25,7 @@ describe CollectionsController do
|
|
|
25
25
|
let(:collection) { create(:collection, title: ['Collection Title'], user: user) }
|
|
26
26
|
|
|
27
27
|
describe '#new' do
|
|
28
|
-
before
|
|
29
|
-
sign_in user
|
|
30
|
-
end
|
|
28
|
+
before { sign_in user }
|
|
31
29
|
|
|
32
30
|
it 'assigns @collection' do
|
|
33
31
|
get :new
|
|
@@ -36,20 +34,18 @@ describe CollectionsController do
|
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
describe '#create' do
|
|
39
|
-
before
|
|
40
|
-
sign_in user
|
|
41
|
-
end
|
|
37
|
+
before { sign_in user }
|
|
42
38
|
|
|
43
39
|
it 'creates a Collection' do
|
|
44
40
|
expect do
|
|
45
|
-
post :create, collection: collection_attrs.merge(visibility: 'open')
|
|
41
|
+
post :create, params: { collection: collection_attrs.merge(visibility: 'open') }
|
|
46
42
|
end.to change { Collection.count }.by(1)
|
|
47
43
|
expect(assigns[:collection].visibility).to eq 'open'
|
|
48
44
|
end
|
|
49
45
|
|
|
50
46
|
it 'removes blank strings from params before creating Collection' do
|
|
51
47
|
expect do
|
|
52
|
-
post :create, collection: collection_attrs.merge(creator: [''])
|
|
48
|
+
post :create, params: { collection: collection_attrs.merge(creator: ['']) }
|
|
53
49
|
end.to change { Collection.count }.by(1)
|
|
54
50
|
expect(assigns[:collection].title).to eq ['My First Collection']
|
|
55
51
|
expect(assigns[:collection].creator).to eq([])
|
|
@@ -58,8 +54,9 @@ describe CollectionsController do
|
|
|
58
54
|
it 'creates a Collection with files I can access' do
|
|
59
55
|
[asset1, asset2].map(&:save) # bogus_depositor_asset is already saved
|
|
60
56
|
expect do
|
|
61
|
-
post :create, collection: collection_attrs,
|
|
62
|
-
|
|
57
|
+
post :create, params: { collection: collection_attrs,
|
|
58
|
+
batch_document_ids: [asset1.id, asset2.id, bogus_depositor_asset.id]
|
|
59
|
+
}
|
|
63
60
|
end.to change { Collection.count }.by(1)
|
|
64
61
|
collection = assigns(:collection)
|
|
65
62
|
expect(collection.members).to match_array [asset1, asset2]
|
|
@@ -67,7 +64,7 @@ describe CollectionsController do
|
|
|
67
64
|
|
|
68
65
|
it 'adds docs to the collection if a batch id is provided and add the collection id to the documents in the collection' do
|
|
69
66
|
asset1.save
|
|
70
|
-
post :create, batch_document_ids: [asset1.id], collection: collection_attrs
|
|
67
|
+
post :create, params: { batch_document_ids: [asset1.id], collection: collection_attrs }
|
|
71
68
|
expect(assigns[:collection].members).to eq [asset1]
|
|
72
69
|
|
|
73
70
|
asset_results = ActiveFedora::SolrService.instance.conn.get 'select', params: { fq: ["id:\"#{asset1.id}\""], fl: ['id'] }
|
|
@@ -106,9 +103,10 @@ describe CollectionsController do
|
|
|
106
103
|
xit 'appends members to the collection in order, allowing duplicates' do
|
|
107
104
|
# TODO: Using size until count is fixed https://github.com/projecthydra-labs/activefedora-aggregation/issues/78
|
|
108
105
|
expect {
|
|
109
|
-
put :update, id: collection,
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
put :update, params: { id: collection,
|
|
107
|
+
collection: { members: 'add' },
|
|
108
|
+
batch_document_ids: [asset2.id, asset1.id]
|
|
109
|
+
}
|
|
112
110
|
}.to change { collection.reload.members.size }.by(2)
|
|
113
111
|
expect(response).to redirect_to routes.url_helpers.collection_path(collection)
|
|
114
112
|
expect(assigns[:collection].members).to eq [asset1, asset2, asset2, asset1]
|
|
@@ -122,9 +120,10 @@ describe CollectionsController do
|
|
|
122
120
|
|
|
123
121
|
it "adds members to the collection" do
|
|
124
122
|
expect {
|
|
125
|
-
put :update, id: collection,
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
put :update, params: { id: collection,
|
|
124
|
+
collection: { members: 'add' },
|
|
125
|
+
batch_document_ids: [asset4.id]
|
|
126
|
+
}
|
|
128
127
|
}.to change { collection.reload.members.size }.by(1)
|
|
129
128
|
expect(response).to redirect_to routes.url_helpers.collection_path(collection)
|
|
130
129
|
expect(assigns[:collection].members).to match_array [asset1, asset2, asset4]
|
|
@@ -139,9 +138,10 @@ describe CollectionsController do
|
|
|
139
138
|
it "removes members from the collection" do
|
|
140
139
|
# TODO: Using size until count is fixed https://github.com/projecthydra-labs/activefedora-aggregation/issues/78
|
|
141
140
|
expect {
|
|
142
|
-
put :update, id: collection,
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
put :update, params: { id: collection,
|
|
142
|
+
collection: { members: 'remove' },
|
|
143
|
+
batch_document_ids: [asset2]
|
|
144
|
+
}
|
|
145
145
|
}.to change { collection.reload.members.size }.by(-1)
|
|
146
146
|
asset_results = ActiveFedora::SolrService.instance.conn.get 'select', params: { fq: ["id:\"#{asset2.id}\""], fl: ['id'] }
|
|
147
147
|
expect(asset_results['response']['numFound']).to eq 1
|
|
@@ -155,19 +155,24 @@ describe CollectionsController do
|
|
|
155
155
|
let(:asset1) { create(:generic_work, user: user) }
|
|
156
156
|
let(:asset2) { create(:generic_work, user: user) }
|
|
157
157
|
let(:asset3) { create(:generic_work, user: user) }
|
|
158
|
-
before do
|
|
159
|
-
collection.members = [asset1, asset2, asset3]
|
|
160
|
-
collection.save!
|
|
161
|
-
end
|
|
162
158
|
let(:collection2) do
|
|
163
159
|
Collection.create(title: ['Some Collection']) do |col|
|
|
164
160
|
col.apply_depositor_metadata(user.user_key)
|
|
165
161
|
end
|
|
166
162
|
end
|
|
163
|
+
before do
|
|
164
|
+
collection.members = [asset1, asset2, asset3]
|
|
165
|
+
collection.save!
|
|
166
|
+
end
|
|
167
167
|
|
|
168
168
|
it 'moves the members' do
|
|
169
|
-
put :update,
|
|
170
|
-
|
|
169
|
+
put :update,
|
|
170
|
+
params: {
|
|
171
|
+
id: collection,
|
|
172
|
+
collection: { members: 'move' },
|
|
173
|
+
destination_collection_id: collection2,
|
|
174
|
+
batch_document_ids: [asset2, asset3]
|
|
175
|
+
}
|
|
171
176
|
expect(collection.reload.members).to eq [asset1]
|
|
172
177
|
expect(collection2.reload.members).to match_array [asset2, asset3]
|
|
173
178
|
end
|
|
@@ -175,14 +180,14 @@ describe CollectionsController do
|
|
|
175
180
|
|
|
176
181
|
context 'updating a collections metadata' do
|
|
177
182
|
it 'saves the metadata' do
|
|
178
|
-
put :update, id: collection, collection: { creator: ['Emily'], visibility: 'open' }
|
|
183
|
+
put :update, params: { id: collection, collection: { creator: ['Emily'], visibility: 'open' } }
|
|
179
184
|
collection.reload
|
|
180
185
|
expect(collection.creator).to eq ['Emily']
|
|
181
186
|
expect(collection.visibility).to eq 'open'
|
|
182
187
|
end
|
|
183
188
|
|
|
184
189
|
it 'removes blank strings from params before updating Collection metadata' do
|
|
185
|
-
put :update, id: collection, collection: collection_attrs.merge(creator: [''])
|
|
190
|
+
put :update, params: { id: collection, collection: collection_attrs.merge(creator: ['']) }
|
|
186
191
|
expect(assigns[:collection].title).to eq ['My First Collection']
|
|
187
192
|
expect(assigns[:collection].creator).to eq([])
|
|
188
193
|
end
|
|
@@ -202,7 +207,7 @@ describe CollectionsController do
|
|
|
202
207
|
end
|
|
203
208
|
|
|
204
209
|
it 'returns the collection and its members' do
|
|
205
|
-
get :show, id: collection
|
|
210
|
+
get :show, params: { id: collection }
|
|
206
211
|
expect(response).to be_successful
|
|
207
212
|
expect(assigns[:presenter]).to be_kind_of CurationConcerns::CollectionPresenter
|
|
208
213
|
expect(assigns[:presenter].to_s).to eq 'Collection Title'
|
|
@@ -211,15 +216,16 @@ describe CollectionsController do
|
|
|
211
216
|
|
|
212
217
|
context 'when the q parameter is passed' do
|
|
213
218
|
it 'loads the collection (paying no attention to the q param)' do
|
|
214
|
-
get :show, id: collection, q: 'no matches'
|
|
219
|
+
get :show, params: { id: collection, q: 'no matches' }
|
|
215
220
|
expect(response).to be_successful
|
|
216
221
|
expect(assigns[:presenter]).to be_kind_of CurationConcerns::CollectionPresenter
|
|
217
222
|
expect(assigns[:presenter].to_s).to eq 'Collection Title'
|
|
218
223
|
end
|
|
219
224
|
end
|
|
225
|
+
|
|
220
226
|
context 'when the page parameter is passed' do
|
|
221
227
|
it 'loads the collection (paying no attention to the page param)' do
|
|
222
|
-
get :show, id: collection, page: '2'
|
|
228
|
+
get :show, params: { id: collection, page: '2' }
|
|
223
229
|
expect(response).to be_successful
|
|
224
230
|
expect(assigns[:presenter]).to be_kind_of CurationConcerns::CollectionPresenter
|
|
225
231
|
expect(assigns[:presenter].to_s).to eq 'Collection Title'
|
|
@@ -233,7 +239,7 @@ describe CollectionsController do
|
|
|
233
239
|
collection.save
|
|
234
240
|
end
|
|
235
241
|
it 'forces me to log in' do
|
|
236
|
-
get :show, id: collection
|
|
242
|
+
get :show, params: { id: collection }
|
|
237
243
|
expect(response).to redirect_to(main_app.new_user_session_path)
|
|
238
244
|
end
|
|
239
245
|
end
|
|
@@ -243,7 +249,7 @@ describe CollectionsController do
|
|
|
243
249
|
before { sign_in user }
|
|
244
250
|
|
|
245
251
|
it 'does not show flash' do
|
|
246
|
-
get :edit, id: collection
|
|
252
|
+
get :edit, params: { id: collection }
|
|
247
253
|
expect(flash[:notice]).to be_nil
|
|
248
254
|
end
|
|
249
255
|
end
|