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
|
@@ -15,7 +15,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
15
15
|
|
|
16
16
|
context "JSON" do
|
|
17
17
|
let(:resource) { file_set }
|
|
18
|
-
let(:resource_request) { get :show, id: resource, format: :json }
|
|
18
|
+
let(:resource_request) { get :show, params: { id: resource, format: :json } }
|
|
19
19
|
let(:actor) { controller.send(:actor) }
|
|
20
20
|
subject { response }
|
|
21
21
|
describe "unauthorized" do
|
|
@@ -35,7 +35,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
describe 'not found' do
|
|
38
|
-
before { get :show, id: "non-existent-pid", format: :json }
|
|
38
|
+
before { get :show, params: { id: "non-existent-pid", format: :json } }
|
|
39
39
|
# Respond with forbidden to protect against object enumeration attack
|
|
40
40
|
it { is_expected.to respond_forbidden }
|
|
41
41
|
end
|
|
@@ -56,7 +56,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
56
56
|
allow_any_instance_of(FileSet).to receive(:persisted?).and_return(true)
|
|
57
57
|
allow_any_instance_of(FileSet).to receive(:to_param).and_return('999')
|
|
58
58
|
|
|
59
|
-
post :create, file_set: { title: ['a title'], files: [file] }, parent_id: parent.id, format: :json
|
|
59
|
+
post :create, params: { file_set: { title: ['a title'], files: [file] }, parent_id: parent.id, format: :json }
|
|
60
60
|
|
|
61
61
|
expect(assigns[:file_set]).to be_instance_of ::FileSet # this object is used by the jbuilder template
|
|
62
62
|
expect(controller).to render_template('curation_concerns/file_sets/jq_upload')
|
|
@@ -67,24 +67,24 @@ describe CurationConcerns::FileSetsController do
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
describe 'failed create: no file' do
|
|
70
|
-
before { post :create, file_set: { title: ["foo"] }, parent_id: parent.id, format: :json }
|
|
70
|
+
before { post :create, params: { file_set: { title: ["foo"] }, parent_id: parent.id, format: :json } }
|
|
71
71
|
it { is_expected.to respond_bad_request(message: 'Error! No file to save') }
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
describe 'failed create: bad file' do
|
|
75
|
-
before { post :create, file_set: { files: ['not a file'] }, parent_id: parent.id, format: :json }
|
|
75
|
+
before { post :create, params: { file_set: { files: ['not a file'] }, parent_id: parent.id, format: :json } }
|
|
76
76
|
it { is_expected.to respond_bad_request(message: 'Error! No file for upload', description: 'unknown file') }
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
describe 'failed create: empty file' do
|
|
80
|
-
before { post :create, file_set: { files: [empty_file] }, parent_id: parent.id, format: :json }
|
|
80
|
+
before { post :create, params: { file_set: { files: [empty_file] }, parent_id: parent.id, format: :json } }
|
|
81
81
|
it { is_expected.to respond_unprocessable_entity(errors: { files: "#{empty_file.original_filename} has no content! (Zero length file)" }, description: I18n.t('curation_concerns.api.unprocessable_entity.empty_file')) }
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
describe 'failed create: solr error' do
|
|
85
85
|
before do
|
|
86
86
|
allow(controller).to receive(:process_file).and_raise(RSolr::Error::Http.new(controller.request, response))
|
|
87
|
-
post :create, file_set: { files: [file] }, parent_id: parent.id, format: :json
|
|
87
|
+
post :create, params: { file_set: { files: [file] }, parent_id: parent.id, format: :json }
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it { is_expected.to respond_internal_error(message: 'Error occurred while creating a FileSet.') }
|
|
@@ -112,7 +112,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
112
112
|
else
|
|
113
113
|
expect(actor).to receive(:update_metadata).with(ActionController::Parameters.new(expected_params).permit!).and_return(true)
|
|
114
114
|
end
|
|
115
|
-
put :update, id: resource, file_set: { title: ['updated title'] }, format: :json
|
|
115
|
+
put :update, params: { id: resource, file_set: { title: ['updated title'] }, format: :json }
|
|
116
116
|
expect(assigns[:file_set]).to be_instance_of ::FileSet # this object is used by the jbuilder template
|
|
117
117
|
expect(response.status).to eq 200
|
|
118
118
|
expect(controller).to render_template('curation_concerns/file_sets/show')
|
|
@@ -124,7 +124,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
124
124
|
describe "integration update" do
|
|
125
125
|
render_views
|
|
126
126
|
it "works" do
|
|
127
|
-
put :update, id: resource.id, file_set: { title: ['test'] }, format: :json
|
|
127
|
+
put :update, params: { id: resource.id, file_set: { title: ['test'] }, format: :json }
|
|
128
128
|
expect(response.status).to eq 200
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -135,7 +135,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
135
135
|
controller.curation_concern.errors.add(:some_field, "This is not valid. Fix it.")
|
|
136
136
|
false
|
|
137
137
|
end
|
|
138
|
-
post :update, id: resource, file_set: { title: nil, depositor: nil }, format: :json
|
|
138
|
+
post :update, params: { id: resource, file_set: { title: nil, depositor: nil }, format: :json }
|
|
139
139
|
}
|
|
140
140
|
it "returns 422 and the errors" do
|
|
141
141
|
expect(response).to respond_unprocessable_entity(errors: { some_field: ["This is not valid. Fix it."] })
|
|
@@ -9,9 +9,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
9
9
|
before { sign_in user }
|
|
10
10
|
|
|
11
11
|
describe '#create' do
|
|
12
|
-
before
|
|
13
|
-
FileSet.destroy_all
|
|
14
|
-
end
|
|
12
|
+
before { FileSet.destroy_all }
|
|
15
13
|
|
|
16
14
|
context 'on the happy path' do
|
|
17
15
|
let(:date_today) { DateTime.now }
|
|
@@ -39,10 +37,13 @@ describe CurationConcerns::FileSetsController do
|
|
|
39
37
|
expect(actor).to receive(:create_content).with(ActionDispatch::Http::UploadedFile).and_return(true)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
post :create, xhr: true, params: { parent_id: parent,
|
|
41
|
+
file_set: {
|
|
42
|
+
files: [file],
|
|
43
|
+
title: ['test title'],
|
|
44
|
+
visibility: 'restricted'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
46
47
|
expect(response).to be_success
|
|
47
48
|
expect(flash[:error]).to be_nil
|
|
48
49
|
end
|
|
@@ -51,8 +52,11 @@ describe CurationConcerns::FileSetsController do
|
|
|
51
52
|
context "on something that isn't a file" do
|
|
52
53
|
# Note: This is a duplicate of coverage in file_sets_controller_json_spec.rb
|
|
53
54
|
it 'renders error' do
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
post :create, xhr: true, params: { parent_id: parent,
|
|
56
|
+
file_set: { files: ['hello'] },
|
|
57
|
+
permission: { group: { 'public' => 'read' } },
|
|
58
|
+
terms_of_service: '1'
|
|
59
|
+
}
|
|
56
60
|
expect(response.status).to eq 400
|
|
57
61
|
msg = JSON.parse(response.body)['message']
|
|
58
62
|
expect(msg).to match(/no file for upload/i)
|
|
@@ -82,8 +86,12 @@ describe CurationConcerns::FileSetsController do
|
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
it 'errors out of create after on continuous rsolr error' do
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
post :create, xhr: true, params: {
|
|
90
|
+
parent_id: parent,
|
|
91
|
+
file_set: { files: [file] },
|
|
92
|
+
permission: { group: { 'public' => 'read' } },
|
|
93
|
+
terms_of_service: '1'
|
|
94
|
+
}
|
|
87
95
|
expect(response.body).to include('Error occurred while creating a FileSet.')
|
|
88
96
|
end
|
|
89
97
|
end
|
|
@@ -95,8 +103,12 @@ describe CurationConcerns::FileSetsController do
|
|
|
95
103
|
end
|
|
96
104
|
|
|
97
105
|
it 'errors out of create after on continuous rsolr error' do
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
post :create, xhr: true, params: {
|
|
107
|
+
parent_id: parent,
|
|
108
|
+
file_set: { files: [file] },
|
|
109
|
+
permission: { group: { 'public' => 'read' } },
|
|
110
|
+
terms_of_service: '1'
|
|
111
|
+
}
|
|
100
112
|
expect(response.body).to include('Error creating file image.png')
|
|
101
113
|
end
|
|
102
114
|
end
|
|
@@ -114,7 +126,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
114
126
|
|
|
115
127
|
it 'deletes the file' do
|
|
116
128
|
expect(FileSet.find(file_set.id)).to be_kind_of FileSet
|
|
117
|
-
delete :destroy, id: file_set
|
|
129
|
+
delete :destroy, params: { id: file_set }
|
|
118
130
|
expect { FileSet.find(file_set.id) }.to raise_error Ldp::Gone
|
|
119
131
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(parent)
|
|
120
132
|
end
|
|
@@ -137,16 +149,20 @@ describe CurationConcerns::FileSetsController do
|
|
|
137
149
|
|
|
138
150
|
context 'updating metadata' do
|
|
139
151
|
it 'is successful and update attributes' do
|
|
140
|
-
post :update,
|
|
141
|
-
|
|
152
|
+
post :update, params: {
|
|
153
|
+
id: file_set,
|
|
154
|
+
file_set: { title: ['new_title'], keyword: [''], permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }] }
|
|
155
|
+
}
|
|
142
156
|
expect(response).to redirect_to main_app.curation_concerns_file_set_path(file_set)
|
|
143
157
|
expect(assigns[:file_set].title).to eq(['new_title'])
|
|
144
158
|
end
|
|
145
159
|
|
|
146
160
|
it 'goes back to edit on an error' do
|
|
147
161
|
allow_any_instance_of(FileSet).to receive(:valid?).and_return(false)
|
|
148
|
-
post :update,
|
|
149
|
-
|
|
162
|
+
post :update, params: {
|
|
163
|
+
id: file_set,
|
|
164
|
+
file_set: { title: ['new_title'], keyword: [''], permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }] }
|
|
165
|
+
}
|
|
150
166
|
expect(response.status).to eq 422
|
|
151
167
|
expect(response).to render_template('edit')
|
|
152
168
|
expect(assigns[:groups]).to be_kind_of Array
|
|
@@ -157,19 +173,22 @@ describe CurationConcerns::FileSetsController do
|
|
|
157
173
|
context 'updating visibility' do
|
|
158
174
|
it 'applies public' do
|
|
159
175
|
new_visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
|
160
|
-
post :update, id: file_set, file_set: { visibility: new_visibility, embargo_release_date: '' }
|
|
176
|
+
post :update, params: { id: file_set, file_set: { visibility: new_visibility, embargo_release_date: '' } }
|
|
161
177
|
expect(file_set.reload.visibility).to eq new_visibility
|
|
162
178
|
end
|
|
163
179
|
|
|
164
180
|
it 'applies embargo' do
|
|
165
|
-
post :update,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
post :update, params: {
|
|
182
|
+
id: file_set,
|
|
183
|
+
file_set: {
|
|
184
|
+
visibility: 'embargo',
|
|
185
|
+
visibility_during_embargo: 'restricted',
|
|
186
|
+
embargo_release_date: '2099-09-05',
|
|
187
|
+
visibility_after_embargo: 'open',
|
|
188
|
+
visibility_during_lease: 'open',
|
|
189
|
+
lease_expiration_date: '2099-09-05',
|
|
190
|
+
visibility_after_lease: 'restricted'
|
|
191
|
+
}
|
|
173
192
|
}
|
|
174
193
|
file_set.reload
|
|
175
194
|
expect(file_set).to be_under_embargo
|
|
@@ -181,7 +200,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
181
200
|
context 'updating file content' do
|
|
182
201
|
it 'is successful' do
|
|
183
202
|
expect(IngestFileJob).to receive(:perform_later)
|
|
184
|
-
post :update, id: file_set, file_set: { files: [file] }
|
|
203
|
+
post :update, params: { id: file_set, file_set: { files: [file] } }
|
|
185
204
|
expect(response).to redirect_to main_app.curation_concerns_file_set_path(file_set)
|
|
186
205
|
end
|
|
187
206
|
end
|
|
@@ -200,7 +219,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
200
219
|
it 'is successful' do
|
|
201
220
|
expect(file_set.latest_content_version.label).to eq('version2')
|
|
202
221
|
expect(file_set.original_file.content).to eq("This is a test fixture for curation_concerns: <%= @id %>.\n")
|
|
203
|
-
post :update, id: file_set, revision: 'version1'
|
|
222
|
+
post :update, params: { id: file_set, revision: 'version1' }
|
|
204
223
|
expect(response).to redirect_to main_app.curation_concerns_file_set_path(file_set)
|
|
205
224
|
reloaded = file_set.reload.original_file
|
|
206
225
|
expect(reloaded.versions.last.label).to eq 'version3'
|
|
@@ -218,7 +237,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
218
237
|
|
|
219
238
|
describe '#edit' do
|
|
220
239
|
it 'gives me the unauthorized page' do
|
|
221
|
-
get :edit, id: public_file_set
|
|
240
|
+
get :edit, params: { id: public_file_set }
|
|
222
241
|
expect(response.code).to eq '401'
|
|
223
242
|
expect(response).to render_template(:unauthorized)
|
|
224
243
|
end
|
|
@@ -226,7 +245,7 @@ describe CurationConcerns::FileSetsController do
|
|
|
226
245
|
|
|
227
246
|
describe '#show' do
|
|
228
247
|
it 'allows access to the file' do
|
|
229
|
-
get :show, id: public_file_set
|
|
248
|
+
get :show, params: { id: public_file_set }
|
|
230
249
|
expect(response).to be_success
|
|
231
250
|
end
|
|
232
251
|
end
|
|
@@ -238,27 +257,27 @@ describe CurationConcerns::FileSetsController do
|
|
|
238
257
|
|
|
239
258
|
describe '#edit' do
|
|
240
259
|
it 'requires login' do
|
|
241
|
-
get :edit, id: public_file_set
|
|
260
|
+
get :edit, params: { id: public_file_set }
|
|
242
261
|
expect(response).to fail_redirect_and_flash(main_app.new_user_session_path, 'You are not authorized to access this page.')
|
|
243
262
|
end
|
|
244
263
|
end
|
|
245
264
|
|
|
246
265
|
describe '#show' do
|
|
247
266
|
it 'denies access to private files' do
|
|
248
|
-
get :show, id: private_file_set
|
|
267
|
+
get :show, params: { id: private_file_set }
|
|
249
268
|
expect(response).to fail_redirect_and_flash(main_app.new_user_session_path, 'You are not authorized to access this page.')
|
|
250
269
|
end
|
|
251
270
|
|
|
252
271
|
it 'allows access to public files' do
|
|
253
272
|
expect(controller).to receive(:additional_response_formats).with(ActionController::MimeResponds::Collector)
|
|
254
|
-
get :show, id: public_file_set
|
|
273
|
+
get :show, params: { id: public_file_set }
|
|
255
274
|
expect(response).to be_success
|
|
256
275
|
end
|
|
257
276
|
end
|
|
258
277
|
|
|
259
278
|
describe '#new' do
|
|
260
279
|
it 'does not let the user submit' do
|
|
261
|
-
get :new, parent_id: parent
|
|
280
|
+
get :new, params: { parent_id: parent }
|
|
262
281
|
expect(response).to fail_redirect_and_flash(main_app.new_user_session_path, 'You are not authorized to access this page.')
|
|
263
282
|
end
|
|
264
283
|
end
|
|
@@ -8,7 +8,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
8
8
|
|
|
9
9
|
context "JSON" do
|
|
10
10
|
let(:resource) { create(:private_generic_work, user: user) }
|
|
11
|
-
let(:resource_request) { get :show, id: resource, format: :json }
|
|
11
|
+
let(:resource_request) { get :show, params: { id: resource, format: :json } }
|
|
12
12
|
subject { response }
|
|
13
13
|
|
|
14
14
|
describe "unauthorized" do
|
|
@@ -28,12 +28,12 @@ describe CurationConcerns::GenericWorksController do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
describe 'not found' do
|
|
31
|
-
before { get :show, id: "non-existent-pid", format: :json }
|
|
31
|
+
before { get :show, params: { id: "non-existent-pid", format: :json } }
|
|
32
32
|
it { is_expected.to respond_not_found }
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe 'created' do
|
|
36
|
-
before { post :create, generic_work: { title: ['a title'] }, format: :json }
|
|
36
|
+
before { post :create, params: { generic_work: { title: ['a title'] }, format: :json } }
|
|
37
37
|
it "returns 201, renders show template sets location header" do
|
|
38
38
|
# Ensure that @curation_concern is set for jbuilder template to use
|
|
39
39
|
expect(assigns[:curation_concern]).to be_instance_of GenericWork
|
|
@@ -45,7 +45,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
describe 'failed create' do
|
|
48
|
-
before { post :create, generic_work: {}, format: :json }
|
|
48
|
+
before { post :create, params: { generic_work: {}, format: :json } }
|
|
49
49
|
it "returns 422 and the errors" do
|
|
50
50
|
created_resource = assigns[:curation_concern]
|
|
51
51
|
expect(response).to respond_unprocessable_entity(errors: created_resource.errors.messages.as_json)
|
|
@@ -63,7 +63,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe 'updated' do
|
|
66
|
-
before { put :update, id: resource, generic_work: { title: ['updated title'] }, format: :json }
|
|
66
|
+
before { put :update, params: { id: resource, generic_work: { title: ['updated title'] }, format: :json } }
|
|
67
67
|
it "returns 200, renders show template sets location header" do
|
|
68
68
|
# Ensure that @curation_concern is set for jbuilder template to use
|
|
69
69
|
expect(assigns[:curation_concern]).to be_instance_of GenericWork
|
|
@@ -76,7 +76,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
76
76
|
|
|
77
77
|
describe 'failed update' do
|
|
78
78
|
before do
|
|
79
|
-
post :update, id: resource, generic_work: { title: [''] }, format: :json
|
|
79
|
+
post :update, params: { id: resource, generic_work: { title: [''] }, format: :json }
|
|
80
80
|
end
|
|
81
81
|
it "returns 422 and the errors" do
|
|
82
82
|
expect(response).to respond_unprocessable_entity(errors: { title: ["Your work must have a title."] })
|
|
@@ -10,7 +10,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
10
10
|
context 'my own private work' do
|
|
11
11
|
let(:work) { create(:private_generic_work, user: user) }
|
|
12
12
|
it 'shows me the page' do
|
|
13
|
-
get :show, id: work
|
|
13
|
+
get :show, params: { id: work }
|
|
14
14
|
expect(response).to be_success
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -18,8 +18,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
18
18
|
render_views
|
|
19
19
|
it "renders a breadcrumb" do
|
|
20
20
|
parent = create(:generic_work, title: ['Parent Work'], user: user, ordered_members: [work])
|
|
21
|
-
get :show, id: work, parent_id: parent
|
|
22
|
-
|
|
21
|
+
get :show, params: { id: work, parent_id: parent }
|
|
23
22
|
expect(response.body).to have_content "Parent Work"
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -28,7 +27,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
28
27
|
context 'someone elses private work' do
|
|
29
28
|
let(:work) { create(:private_generic_work) }
|
|
30
29
|
it 'shows unauthorized message' do
|
|
31
|
-
get :show, id: work
|
|
30
|
+
get :show, params: { id: work }
|
|
32
31
|
expect(response.code).to eq '401'
|
|
33
32
|
expect(response).to render_template(:unauthorized)
|
|
34
33
|
end
|
|
@@ -39,7 +38,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
39
38
|
context "html" do
|
|
40
39
|
it 'shows me the page' do
|
|
41
40
|
expect(controller). to receive(:additional_response_formats).with(ActionController::MimeResponds::Collector)
|
|
42
|
-
get :show, id: work
|
|
41
|
+
get :show, params: { id: work }
|
|
43
42
|
expect(response).to be_success
|
|
44
43
|
end
|
|
45
44
|
end
|
|
@@ -52,7 +51,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
it 'renders an turtle file' do
|
|
55
|
-
get :show, id: '99999999', format: :ttl
|
|
54
|
+
get :show, params: { id: '99999999', format: :ttl }
|
|
56
55
|
expect(response).to be_successful
|
|
57
56
|
expect(response.body).to eq "ttl graph"
|
|
58
57
|
expect(response.content_type).to eq 'text/turtle'
|
|
@@ -64,7 +63,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
64
63
|
before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
|
|
65
64
|
let(:work) { create(:private_generic_work) }
|
|
66
65
|
it 'someone elses private work should show me the page' do
|
|
67
|
-
get :show, id: work
|
|
66
|
+
get :show, params: { id: work }
|
|
68
67
|
expect(response).to be_success
|
|
69
68
|
end
|
|
70
69
|
end
|
|
@@ -72,8 +71,8 @@ describe CurationConcerns::GenericWorksController do
|
|
|
72
71
|
context 'when a ObjectNotFoundError is raised' do
|
|
73
72
|
it 'returns 404 page' do
|
|
74
73
|
allow(controller).to receive(:show).and_raise(ActiveFedora::ObjectNotFoundError)
|
|
75
|
-
expect(controller).to receive(:render_404) { controller.render
|
|
76
|
-
get :show, id: 'abc123'
|
|
74
|
+
expect(controller).to receive(:render_404) { controller.render body: nil }
|
|
75
|
+
get :show, params: { id: 'abc123' }
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
78
|
end
|
|
@@ -99,7 +98,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
99
98
|
let(:work) { stub_model(GenericWork) }
|
|
100
99
|
it 'creates a work' do
|
|
101
100
|
allow(controller).to receive(:curation_concern).and_return(work)
|
|
102
|
-
post :create, generic_work: { title: ['a title'] }
|
|
101
|
+
post :create, params: { generic_work: { title: ['a title'] } }
|
|
103
102
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(work)
|
|
104
103
|
end
|
|
105
104
|
end
|
|
@@ -107,7 +106,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
107
106
|
context 'when create fails' do
|
|
108
107
|
let(:create_status) { false }
|
|
109
108
|
it 'draws the form again' do
|
|
110
|
-
post :create, generic_work: { title: ['a title'] }
|
|
109
|
+
post :create, params: { generic_work: { title: ['a title'] } }
|
|
111
110
|
expect(response.status).to eq 422
|
|
112
111
|
expect(assigns[:form]).to be_kind_of CurationConcerns::GenericWorkForm
|
|
113
112
|
expect(response).to render_template 'new'
|
|
@@ -118,7 +117,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
118
117
|
before { allow(controller.current_ability).to receive(:can?).and_return(false) }
|
|
119
118
|
|
|
120
119
|
it 'shows the unauthorized message' do
|
|
121
|
-
post :create, generic_work: { title: ['a title'] }
|
|
120
|
+
post :create, params: { generic_work: { title: ['a title'] } }
|
|
122
121
|
expect(response.code).to eq '401'
|
|
123
122
|
expect(response).to render_template(:unauthorized)
|
|
124
123
|
end
|
|
@@ -129,7 +128,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
129
128
|
context 'my own private work' do
|
|
130
129
|
let(:work) { create(:private_generic_work, user: user) }
|
|
131
130
|
it 'shows me the page' do
|
|
132
|
-
get :edit, id: work
|
|
131
|
+
get :edit, params: { id: work }
|
|
133
132
|
expect(assigns[:form]).to be_kind_of CurationConcerns::GenericWorkForm
|
|
134
133
|
expect(response).to be_success
|
|
135
134
|
end
|
|
@@ -139,7 +138,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
139
138
|
routes { Rails.application.class.routes }
|
|
140
139
|
let(:work) { create(:private_generic_work) }
|
|
141
140
|
it 'shows the unauthorized message' do
|
|
142
|
-
get :edit, id: work
|
|
141
|
+
get :edit, params: { id: work }
|
|
143
142
|
expect(response.code).to eq '401'
|
|
144
143
|
expect(response).to render_template(:unauthorized)
|
|
145
144
|
end
|
|
@@ -148,7 +147,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
148
147
|
context 'someone elses public work' do
|
|
149
148
|
let(:work) { create(:public_generic_work) }
|
|
150
149
|
it 'shows the unauthorized message' do
|
|
151
|
-
get :edit, id: work
|
|
150
|
+
get :edit, params: { id: work }
|
|
152
151
|
expect(response.code).to eq '401'
|
|
153
152
|
expect(response).to render_template(:unauthorized)
|
|
154
153
|
end
|
|
@@ -158,7 +157,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
158
157
|
before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
|
|
159
158
|
let(:work) { create(:private_generic_work) }
|
|
160
159
|
it 'someone elses private work should show me the page' do
|
|
161
|
-
get :edit, id: work
|
|
160
|
+
get :edit, params: { id: work }
|
|
162
161
|
expect(response).to be_success
|
|
163
162
|
end
|
|
164
163
|
end
|
|
@@ -166,20 +165,20 @@ describe CurationConcerns::GenericWorksController do
|
|
|
166
165
|
|
|
167
166
|
describe '#update' do
|
|
168
167
|
let(:work) { create(:private_generic_work, user: user) }
|
|
168
|
+
let(:visibility_changed) { false }
|
|
169
|
+
let(:actor) { double(update: true) }
|
|
169
170
|
before do
|
|
170
171
|
allow(CurationConcerns::CurationConcern).to receive(:actor).and_return(actor)
|
|
171
172
|
allow_any_instance_of(GenericWork).to receive(:visibility_changed?).and_return(visibility_changed)
|
|
172
173
|
end
|
|
173
|
-
let(:visibility_changed) { false }
|
|
174
|
-
let(:actor) { double(update: true) }
|
|
175
174
|
|
|
176
175
|
it 'updates the work' do
|
|
177
|
-
patch :update, id: work, generic_work: {}
|
|
176
|
+
patch :update, params: { id: work, generic_work: {} }
|
|
178
177
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(work)
|
|
179
178
|
end
|
|
180
179
|
|
|
181
180
|
it "can update file membership" do
|
|
182
|
-
patch :update, id: work, generic_work: { ordered_member_ids: ['foo_123'] }
|
|
181
|
+
patch :update, params: { id: work, generic_work: { ordered_member_ids: ['foo_123'] } }
|
|
183
182
|
expected_params = { ordered_member_ids: ['foo_123'] }
|
|
184
183
|
if Rails.version < '5.0.0'
|
|
185
184
|
expect(actor).to have_received(:update).with(expected_params)
|
|
@@ -196,14 +195,14 @@ describe CurationConcerns::GenericWorksController do
|
|
|
196
195
|
let(:work) { create(:work_with_one_file, user: user) }
|
|
197
196
|
|
|
198
197
|
it 'prompts to change the files access' do
|
|
199
|
-
patch :update, id: work, generic_work: {}
|
|
198
|
+
patch :update, params: { id: work, generic_work: {} }
|
|
200
199
|
expect(response).to redirect_to main_app.confirm_curation_concerns_permission_path(controller.curation_concern)
|
|
201
200
|
end
|
|
202
201
|
end
|
|
203
202
|
|
|
204
203
|
context 'without children' do
|
|
205
204
|
it "doesn't prompt to change the files access" do
|
|
206
|
-
patch :update, id: work, generic_work: {}
|
|
205
|
+
patch :update, params: { id: work, generic_work: {} }
|
|
207
206
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(work)
|
|
208
207
|
end
|
|
209
208
|
end
|
|
@@ -213,7 +212,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
213
212
|
let(:actor) { double(update: false) }
|
|
214
213
|
|
|
215
214
|
it 'renders the form' do
|
|
216
|
-
patch :update, id: work, generic_work: {}
|
|
215
|
+
patch :update, params: { id: work, generic_work: {} }
|
|
217
216
|
expect(assigns[:form]).to be_kind_of CurationConcerns::GenericWorkForm
|
|
218
217
|
expect(response).to render_template('edit')
|
|
219
218
|
end
|
|
@@ -222,7 +221,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
222
221
|
context 'someone elses public work' do
|
|
223
222
|
let(:work) { create(:public_generic_work) }
|
|
224
223
|
it 'shows the unauthorized message' do
|
|
225
|
-
get :update, id: work
|
|
224
|
+
get :update, params: { id: work }
|
|
226
225
|
expect(response.code).to eq '401'
|
|
227
226
|
expect(response).to render_template(:unauthorized)
|
|
228
227
|
end
|
|
@@ -232,7 +231,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
232
231
|
before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
|
|
233
232
|
let(:work) { create(:private_generic_work) }
|
|
234
233
|
it 'someone elses private work should update the work' do
|
|
235
|
-
patch :update, id: work, generic_work: {}
|
|
234
|
+
patch :update, params: { id: work, generic_work: {} }
|
|
236
235
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(work)
|
|
237
236
|
end
|
|
238
237
|
end
|
|
@@ -243,7 +242,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
243
242
|
let(:parent_collection) { create(:collection) }
|
|
244
243
|
|
|
245
244
|
it 'deletes the work' do
|
|
246
|
-
delete :destroy, id: work_to_be_deleted
|
|
245
|
+
delete :destroy, params: { id: work_to_be_deleted }
|
|
247
246
|
expect(response).to redirect_to main_app.search_catalog_path
|
|
248
247
|
expect(GenericWork).not_to exist(work_to_be_deleted.id)
|
|
249
248
|
end
|
|
@@ -254,7 +253,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
254
253
|
parent_collection.save!
|
|
255
254
|
end
|
|
256
255
|
it 'deletes the work and updates the parent collection' do
|
|
257
|
-
delete :destroy, id: work_to_be_deleted
|
|
256
|
+
delete :destroy, params: { id: work_to_be_deleted }
|
|
258
257
|
expect(GenericWork).not_to exist(work_to_be_deleted.id)
|
|
259
258
|
expect(response).to redirect_to main_app.search_catalog_path
|
|
260
259
|
expect(parent_collection.reload.members).to eq []
|
|
@@ -264,13 +263,13 @@ describe CurationConcerns::GenericWorksController do
|
|
|
264
263
|
it "invokes the after_destroy callback" do
|
|
265
264
|
expect(CurationConcerns.config.callback).to receive(:run)
|
|
266
265
|
.with(:after_destroy, work_to_be_deleted.id, user)
|
|
267
|
-
delete :destroy, id: work_to_be_deleted
|
|
266
|
+
delete :destroy, params: { id: work_to_be_deleted }
|
|
268
267
|
end
|
|
269
268
|
|
|
270
269
|
context 'someone elses public work' do
|
|
271
270
|
let(:work_to_be_deleted) { create(:private_generic_work) }
|
|
272
271
|
it 'shows unauthorized message' do
|
|
273
|
-
delete :destroy, id: work_to_be_deleted
|
|
272
|
+
delete :destroy, params: { id: work_to_be_deleted }
|
|
274
273
|
expect(response.code).to eq '401'
|
|
275
274
|
expect(response).to render_template(:unauthorized)
|
|
276
275
|
end
|
|
@@ -280,7 +279,7 @@ describe CurationConcerns::GenericWorksController do
|
|
|
280
279
|
let(:work_to_be_deleted) { create(:private_generic_work) }
|
|
281
280
|
before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
|
|
282
281
|
it 'someone elses private work should delete the work' do
|
|
283
|
-
delete :destroy, id: work_to_be_deleted
|
|
282
|
+
delete :destroy, params: { id: work_to_be_deleted }
|
|
284
283
|
expect(GenericWork).not_to exist(work_to_be_deleted.id)
|
|
285
284
|
end
|
|
286
285
|
end
|
|
@@ -288,12 +287,8 @@ describe CurationConcerns::GenericWorksController do
|
|
|
288
287
|
|
|
289
288
|
describe '#file_manager' do
|
|
290
289
|
let(:work) { create(:private_generic_work, user: user) }
|
|
291
|
-
before do
|
|
292
|
-
sign_in user
|
|
293
|
-
end
|
|
294
290
|
it "is successful" do
|
|
295
|
-
get :file_manager, id: work.id
|
|
296
|
-
|
|
291
|
+
get :file_manager, params: { id: work.id }
|
|
297
292
|
expect(response).to be_success
|
|
298
293
|
expect(assigns(:presenter)).not_to be_blank
|
|
299
294
|
end
|