curation_concerns 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +1 -2
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/curation_concerns/curation_concerns.js +2 -0
- data/app/assets/javascripts/curation_concerns/uploader.js +4 -4
- data/app/assets/stylesheets/curation_concerns/_modules.scss +1 -0
- data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -0
- data/app/assets/stylesheets/curation_concerns/modules/icons.scss +11 -0
- data/app/controllers/concerns/curation_concerns/api.rb +1 -12
- data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +20 -6
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +44 -25
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +32 -23
- data/app/controllers/concerns/curation_concerns/parent_container.rb +0 -11
- data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +1 -1
- data/app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb +7 -1
- data/app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb +19 -7
- data/app/controllers/curation_concerns/permissions_controller.rb +1 -1
- data/app/forms/curation_concerns/forms/collection_edit_form.rb +6 -2
- data/app/forms/curation_concerns/forms/work_form.rb +14 -3
- data/app/forms/curation_concerns/upload_set_form.rb +43 -0
- data/app/helpers/curation_concerns/ability_helper.rb +12 -18
- data/app/helpers/curation_concerns/file_set_helper.rb +1 -1
- data/app/helpers/curation_concerns/main_app_helpers.rb +1 -0
- data/app/helpers/curation_concerns/permissions_helper.rb +20 -0
- data/app/helpers/curation_concerns/url_helper.rb +3 -11
- data/app/inputs/multi_value_with_help_input.rb +8 -0
- data/app/inputs/select_with_help_input.rb +3 -0
- data/app/inputs/select_with_modal_help_input.rb +36 -0
- data/app/inputs/with_help_icon.rb +34 -0
- data/app/presenters/curation_concerns/collection_presenter.rb +9 -0
- data/app/presenters/curation_concerns/file_set_presenter.rb +2 -1
- data/app/presenters/curation_concerns/presents_attributes.rb +16 -0
- data/app/presenters/curation_concerns/work_show_presenter.rb +3 -2
- data/app/renderers/curation_concerns/attribute_renderer.rb +22 -4
- data/app/renderers/curation_concerns/configured_microdata.rb +40 -0
- data/app/services/curation_concerns/parent_service.rb +1 -1
- data/app/views/catalog/_action_menu_partials/_default.html.erb +2 -2
- data/app/views/collections/_form.html.erb +8 -9
- data/app/views/collections/_sort_and_per_page.html.erb +25 -23
- data/app/views/collections/show.html.erb +1 -1
- data/app/views/curation_concerns/base/_attributes.html.erb +1 -1
- data/app/views/curation_concerns/base/_form.html.erb +6 -7
- data/app/views/curation_concerns/base/_form_permission.html.erb +3 -0
- data/app/views/curation_concerns/base/_multiple_upload.html.erb +3 -0
- data/app/views/curation_concerns/base/_show_actions.html.erb +2 -2
- data/app/views/curation_concerns/base/_versioning.html.erb +1 -1
- data/app/views/curation_concerns/base/_visibility.html.erb +17 -0
- data/app/views/curation_concerns/base/show.html.erb +1 -1
- data/app/views/curation_concerns/classify_concerns/new.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/_actions.html.erb +2 -2
- data/app/views/curation_concerns/file_sets/_form.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/_rights_modal.html.erb +41 -0
- data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +4 -1
- data/app/views/curation_concerns/file_sets/media_display/_image.html.erb +9 -8
- data/app/views/curation_concerns/file_sets/media_display/_office_document.html.erb +9 -7
- data/app/views/curation_concerns/file_sets/media_display/_pdf.html.erb +7 -5
- data/app/views/curation_concerns/file_sets/show.html.erb +2 -2
- data/app/views/curation_concerns/file_sets/upload/_alerts.html.erb +3 -3
- data/app/views/curation_concerns/file_sets/upload/_form.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/upload/_script_templates.html.erb +1 -1
- data/app/views/curation_concerns/permissions/confirm.html.erb +1 -1
- data/app/views/curation_concerns/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/embargoes/edit.html.erb +4 -4
- data/app/views/layouts/curation_concerns.html.erb +1 -1
- data/app/views/leases/edit.html.erb +3 -3
- data/app/views/shared/_add_works.html.erb +6 -3
- data/app/views/upload_sets/_base_metadata.html.erb +12 -0
- data/app/views/upload_sets/_metadata.html.erb +3 -13
- data/app/views/upload_sets/edit.html.erb +1 -1
- data/config/locales/curation_concerns.en.yml +46 -0
- data/curation_concerns.gemspec +5 -4
- data/lib/curation_concerns/engine.rb +5 -0
- data/lib/curation_concerns/form_builder.rb +16 -0
- data/lib/curation_concerns/rails/routes.rb +7 -5
- data/lib/generators/curation_concerns/install_generator.rb +1 -1
- data/lib/generators/curation_concerns/work/work_generator.rb +1 -1
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +26 -16
- data/spec/controllers/curation_concerns/file_sets_controller_json_spec.rb +14 -4
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +3 -3
- data/spec/controllers/curation_concerns/generic_works_controller_json_spec.rb +4 -4
- data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +21 -0
- data/spec/controllers/curation_concerns/single_use_links_controller_spec.rb +2 -2
- data/spec/controllers/curation_concerns/single_use_links_viewer_controller_spec.rb +1 -1
- data/spec/controllers/upload_sets_controller_spec.rb +20 -27
- data/spec/factories/file_sets.rb +1 -0
- data/spec/factories/generic_works.rb +1 -0
- data/spec/factories/users.rb +0 -12
- data/spec/features/collection_spec.rb +1 -3
- data/spec/forms/collection_edit_form_spec.rb +16 -1
- data/spec/forms/upload_set_form_spec.rb +55 -0
- data/spec/forms/work_form_spec.rb +68 -3
- data/spec/helpers/curation_concerns/ability_helper_spec.rb +45 -0
- data/spec/helpers/curation_concerns/permissions_helper_spec.rb +12 -0
- data/spec/helpers/url_helper_spec.rb +0 -3
- data/spec/indexers/collection_indexer_spec.rb +5 -0
- data/spec/indexers/{file_set_indexing_service_spec.rb → file_set_indexer_spec.rb} +40 -2
- data/spec/indexers/{generic_work_indexing_service_spec.rb → work_indexer_spec.rb} +1 -1
- data/spec/inputs/multi_value_with_help_input_spec.rb +32 -0
- data/spec/inputs/select_with_help_input_spec.rb +43 -0
- data/spec/inputs/select_with_modal_help_input_spec.rb +21 -0
- data/spec/jobs/import_url_job_spec.rb +33 -1
- data/spec/jobs/ingest_file_job_spec.rb +29 -16
- data/spec/jobs/upload_set_update_job_spec.rb +24 -11
- data/spec/lib/curation_concerns/messages_spec.rb +2 -2
- data/spec/lib/curation_concerns/name_spec.rb +20 -0
- data/spec/lib/curation_concerns/null_logger_spec.rb +10 -0
- data/spec/models/curation_concerns/collection_behavior_spec.rb +41 -10
- data/spec/models/curation_concerns/work_behavior_spec.rb +1 -13
- data/spec/models/file_set_spec.rb +19 -4
- data/spec/models/generic_work_spec.rb +7 -2
- data/spec/models/quick_classification_query_spec.rb +35 -0
- data/spec/models/upload_set_spec.rb +5 -7
- data/spec/presenters/curation_concerns/collection_presenter_spec.rb +20 -0
- data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +10 -3
- data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +13 -1
- data/spec/renderers/curation_concerns/attribute_renderer_spec.rb +41 -8
- data/spec/routing/curation_concerns/routes_spec.rb +2 -2
- data/spec/routing/route_spec.rb +1 -1
- data/spec/services/file_set_audit_service_spec.rb +46 -4
- data/spec/spec_helper.rb +5 -7
- data/spec/views/collections/_sort_and_per_page.html.erb_spec.rb +32 -0
- data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +8 -1
- data/spec/views/curation_concerns/base/show.html.erb_spec.rb +36 -2
- data/spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb +3 -2
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +56 -0
- data/spec/views/curation_concerns/single_use_links_viewer/show.html.erb_spec.rb +19 -0
- data/spec/views/shared/_add_content.html.erb_spec.rb +3 -3
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +1 -1
- data/spec/views/upload_sets/_metadata.html.erb_spec.rb +28 -0
- metadata +80 -50
- data/app/assets/stylesheets/curation_concerns/help_requests.scss +0 -3
- data/app/controllers/concerns/curation_concerns/without_namespace.rb +0 -16
- data/app/controllers/registrations_controller.rb +0 -19
- data/app/controllers/sessions_controller.rb +0 -4
- data/app/views/curation_concerns/file_sets/_multiple_upload.html.erb +0 -3
- data/spec/fixtures/Example.ogg +0 -0
- data/spec/fixtures/charter.docx +0 -0
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/curation_concerns_generic_stub.txt +0 -1
- data/spec/fixtures/empty_file.txt +0 -0
- data/spec/fixtures/files/image.png +0 -0
- data/spec/fixtures/image.jp2 +0 -0
- data/spec/fixtures/image.jpg +0 -0
- data/spec/fixtures/piano_note.wav +0 -0
- data/spec/fixtures/sample_mpeg4.mp4 +0 -0
- data/spec/fixtures/small_file.txt +0 -1
- data/spec/fixtures/spoken-text.m4a +0 -0
- data/spec/fixtures/test.pdf +0 -0
- data/spec/fixtures/test4.pdf +0 -0
- data/spec/fixtures/test5.mp3 +0 -0
- data/spec/fixtures/world.png +0 -0
@@ -24,6 +24,7 @@ describe CurationConcerns::FileSetsController do
|
|
24
24
|
end
|
25
25
|
it { is_expected.to respond_unauthorized }
|
26
26
|
end
|
27
|
+
|
27
28
|
describe "forbidden" do
|
28
29
|
before do
|
29
30
|
sign_in create(:user)
|
@@ -31,14 +32,15 @@ describe CurationConcerns::FileSetsController do
|
|
31
32
|
end
|
32
33
|
it { is_expected.to respond_forbidden }
|
33
34
|
end
|
35
|
+
|
34
36
|
describe 'not found' do
|
35
37
|
before { get :show, id: "non-existent-pid", format: :json }
|
36
|
-
it { is_expected.to respond_not_found(description: '
|
38
|
+
it { is_expected.to respond_not_found(description: 'Could not find a resource that matches your request.') }
|
37
39
|
end
|
38
40
|
|
39
41
|
describe 'created' do
|
40
42
|
it "returns 201, renders jq_upload json template and sets location header" do
|
41
|
-
expect(controller.send(:actor)).to receive(:create_metadata).with(
|
43
|
+
expect(controller.send(:actor)).to receive(:create_metadata).with(parent, hash_including(:files, title: ['a title']))
|
42
44
|
expect(controller.send(:actor)).to receive(:create_content).with(file).and_return(true)
|
43
45
|
|
44
46
|
allow_any_instance_of(FileSet).to receive(:persisted?).and_return(true)
|
@@ -53,25 +55,31 @@ describe CurationConcerns::FileSetsController do
|
|
53
55
|
expect(response.location).to eq main_app.curation_concerns_file_set_path(created_resource)
|
54
56
|
end
|
55
57
|
end
|
58
|
+
|
56
59
|
describe 'failed create: no file' do
|
57
60
|
before { post :create, file_set: { title: ["foo"] }, parent_id: parent.id, format: :json }
|
58
61
|
it { is_expected.to respond_bad_request(message: 'Error! No file to save') }
|
59
62
|
end
|
63
|
+
|
60
64
|
describe 'failed create: bad file' do
|
61
65
|
before { post :create, file_set: { files: ['not a file'] }, parent_id: parent.id, format: :json }
|
62
66
|
it { is_expected.to respond_bad_request(message: 'Error! No file for upload', description: 'unknown file') }
|
63
67
|
end
|
68
|
+
|
64
69
|
describe 'failed create: empty file' do
|
65
70
|
before { post :create, file_set: { files: [empty_file] }, parent_id: parent.id, format: :json }
|
66
71
|
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')) }
|
67
72
|
end
|
73
|
+
|
68
74
|
describe 'failed create: solr error' do
|
69
75
|
before do
|
70
76
|
allow(controller).to receive(:process_file).and_raise(RSolr::Error::Http.new(controller.request, response))
|
71
77
|
post :create, file_set: { files: [file] }, parent_id: parent.id, format: :json
|
72
78
|
end
|
73
|
-
|
79
|
+
|
80
|
+
it { is_expected.to respond_internal_error(message: 'Error occurred while creating a FileSet.') }
|
74
81
|
end
|
82
|
+
|
75
83
|
describe 'found' do
|
76
84
|
before { resource_request }
|
77
85
|
it "returns json of the work" do
|
@@ -80,6 +88,7 @@ describe CurationConcerns::FileSetsController do
|
|
80
88
|
expect(response.code).to eq "200"
|
81
89
|
end
|
82
90
|
end
|
91
|
+
|
83
92
|
describe 'updated' do
|
84
93
|
before { put :update, id: resource, file_set: { title: ['updated title'] }, format: :json }
|
85
94
|
it "returns json of updated work and sets location header" do
|
@@ -90,6 +99,7 @@ describe CurationConcerns::FileSetsController do
|
|
90
99
|
expect(response.location).to eq main_app.curation_concerns_file_set_path(created_resource)
|
91
100
|
end
|
92
101
|
end
|
102
|
+
|
93
103
|
describe 'failed update' do
|
94
104
|
before {
|
95
105
|
expect(controller).to receive(:update_metadata) do
|
@@ -99,7 +109,7 @@ describe CurationConcerns::FileSetsController do
|
|
99
109
|
post :update, id: resource, file_set: { title: nil, depositor: nil }, format: :json
|
100
110
|
}
|
101
111
|
it "returns 422 and the errors" do
|
102
|
-
expect(response).to respond_unprocessable_entity(errors: {
|
112
|
+
expect(response).to respond_unprocessable_entity(errors: { some_field: ["This is not valid. Fix it."] })
|
103
113
|
end
|
104
114
|
end
|
105
115
|
end
|
@@ -21,7 +21,7 @@ describe CurationConcerns::FileSetsController do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'calls the actor to create metadata and content' do
|
24
|
-
expect(controller.send(:actor)).to receive(:create_metadata).with(
|
24
|
+
expect(controller.send(:actor)).to receive(:create_metadata).with(parent, files: [file], title: ['test title'], visibility: 'restricted')
|
25
25
|
expect(controller.send(:actor)).to receive(:create_content).with(file).and_return(true)
|
26
26
|
xhr :post, :create, parent_id: parent,
|
27
27
|
file_set: { files: [file],
|
@@ -68,7 +68,7 @@ describe CurationConcerns::FileSetsController do
|
|
68
68
|
it 'errors out of create after on continuous rsolr error' do
|
69
69
|
xhr :post, :create, parent_id: parent, file_set: { files: [file] },
|
70
70
|
permission: { group: { 'public' => 'read' } }, terms_of_service: '1'
|
71
|
-
expect(response.body).to include('Error occurred while creating
|
71
|
+
expect(response.body).to include('Error occurred while creating a FileSet.')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -121,6 +121,7 @@ describe CurationConcerns::FileSetsController do
|
|
121
121
|
{ title: ['new_title'], tag: [''], permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }] }
|
122
122
|
expect(response.status).to eq 422
|
123
123
|
expect(response).to render_template('edit')
|
124
|
+
expect(assigns[:groups]).to be_kind_of Array
|
124
125
|
expect(assigns[:file_set]).to eq file_set
|
125
126
|
end
|
126
127
|
|
@@ -221,7 +222,6 @@ describe CurationConcerns::FileSetsController do
|
|
221
222
|
end
|
222
223
|
|
223
224
|
it 'allows access to public files' do
|
224
|
-
expect(controller).to receive(:additional_response_formats).with(ActionController::MimeResponds::Collector)
|
225
225
|
get :show, id: public_file_set
|
226
226
|
expect(response).to be_success
|
227
227
|
end
|
@@ -36,7 +36,7 @@ describe CurationConcerns::GenericWorksController do
|
|
36
36
|
before { post :create, 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
|
-
expect(assigns[:curation_concern]).to be_instance_of
|
39
|
+
expect(assigns[:curation_concern]).to be_instance_of GenericWork
|
40
40
|
expect(controller).to render_template('curation_concerns/base/show')
|
41
41
|
expect(response.code).to eq "201"
|
42
42
|
created_resource = assigns[:curation_concern]
|
@@ -56,7 +56,7 @@ describe CurationConcerns::GenericWorksController do
|
|
56
56
|
before { resource_request }
|
57
57
|
it "returns json of the work" do
|
58
58
|
# Ensure that @curation_concern is set for jbuilder template to use
|
59
|
-
expect(assigns[:curation_concern]).to be_instance_of
|
59
|
+
expect(assigns[:curation_concern]).to be_instance_of GenericWork
|
60
60
|
expect(controller).to render_template('curation_concerns/base/show')
|
61
61
|
expect(response.code).to eq "200"
|
62
62
|
end
|
@@ -66,7 +66,7 @@ describe CurationConcerns::GenericWorksController do
|
|
66
66
|
before { put :update, 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
|
-
expect(assigns[:curation_concern]).to be_instance_of
|
69
|
+
expect(assigns[:curation_concern]).to be_instance_of GenericWork
|
70
70
|
expect(controller).to render_template('curation_concerns/base/show')
|
71
71
|
expect(response.code).to eq "200"
|
72
72
|
created_resource = assigns[:curation_concern]
|
@@ -78,7 +78,7 @@ describe CurationConcerns::GenericWorksController do
|
|
78
78
|
before { post :update, id: resource, generic_work: { title: [] }, format: :json }
|
79
79
|
|
80
80
|
it "returns 422 and the errors" do
|
81
|
-
expect(response).to respond_unprocessable_entity(errors: {
|
81
|
+
expect(response).to respond_unprocessable_entity(errors: { title: ["Your work must have a title."] })
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
@@ -27,6 +27,7 @@ describe CurationConcerns::GenericWorksController do
|
|
27
27
|
context 'someone elses public work' do
|
28
28
|
let(:a_work) { create(:public_generic_work) }
|
29
29
|
it 'shows me the page' do
|
30
|
+
expect(controller). to receive(:additional_response_formats).with(ActionController::MimeResponds::Collector)
|
30
31
|
get :show, id: a_work
|
31
32
|
expect(response).to be_success
|
32
33
|
end
|
@@ -40,12 +41,22 @@ describe CurationConcerns::GenericWorksController do
|
|
40
41
|
expect(response).to be_success
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
45
|
+
context 'when a ObjectNotFoundError is raised' do
|
46
|
+
it 'returns 404 page' do
|
47
|
+
allow(controller).to receive(:show).and_raise(ActiveFedora::ObjectNotFoundError)
|
48
|
+
get :show, id: 'abc123'
|
49
|
+
expect(response.status).to eq 404
|
50
|
+
expect(response.body).to match(/The page you were looking for doesn't exist/)
|
51
|
+
end
|
52
|
+
end
|
43
53
|
end
|
44
54
|
|
45
55
|
describe '#new' do
|
46
56
|
context 'my work' do
|
47
57
|
it 'shows me the page' do
|
48
58
|
get :new
|
59
|
+
expect(assigns[:form]).to be_kind_of CurationConcerns::GenericWorkForm
|
49
60
|
expect(response).to be_success
|
50
61
|
end
|
51
62
|
end
|
@@ -58,6 +69,16 @@ describe CurationConcerns::GenericWorksController do
|
|
58
69
|
end.to change { GenericWork.count }.by(1)
|
59
70
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(assigns[:curation_concern])
|
60
71
|
end
|
72
|
+
|
73
|
+
context 'when not authorized' do
|
74
|
+
before { allow(controller.current_ability).to receive(:can?).and_return(false) }
|
75
|
+
|
76
|
+
it 'shows the unauthorized message' do
|
77
|
+
post :create, generic_work: { title: ['a title'] }
|
78
|
+
expect(response.code).to eq '401'
|
79
|
+
expect(response).to render_template(:unauthorized)
|
80
|
+
end
|
81
|
+
end
|
61
82
|
end
|
62
83
|
|
63
84
|
describe '#edit' do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CurationConcerns::SingleUseLinksController, type: :controller do
|
4
4
|
routes { CurationConcerns::Engine.routes }
|
5
|
-
let(:user) {
|
5
|
+
let(:user) { create(:user) }
|
6
6
|
|
7
7
|
let(:file) do
|
8
8
|
FileSet.create do |file|
|
@@ -38,7 +38,7 @@ describe CurationConcerns::SingleUseLinksController, type: :controller do
|
|
38
38
|
|
39
39
|
describe "logged in user without edit permission" do
|
40
40
|
before do
|
41
|
-
@other_user =
|
41
|
+
@other_user = create(:user)
|
42
42
|
file.read_users << @other_user
|
43
43
|
file.save
|
44
44
|
sign_in @other_user
|
@@ -32,7 +32,7 @@ describe CurationConcerns::SingleUseLinksViewerController do
|
|
32
32
|
let(:expected_content) { ActiveFedora::Base.find(file.id).original_file.content }
|
33
33
|
|
34
34
|
it "and_return http success" do
|
35
|
-
expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: '
|
35
|
+
expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: 'attachment', type: 'image/png')
|
36
36
|
get :download, id: download_link_hash
|
37
37
|
expect(response.body).to eq expected_content
|
38
38
|
expect(response).to be_success
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe UploadSetsController do
|
4
|
-
let(:user) {
|
5
|
-
let(:other_user) {
|
4
|
+
let(:user) { create(:user) }
|
5
|
+
let(:other_user) { create(:user) }
|
6
6
|
before do
|
7
7
|
sign_in user
|
8
8
|
allow_any_instance_of(User).to receive(:groups).and_return([])
|
@@ -14,7 +14,7 @@ describe UploadSetsController do
|
|
14
14
|
it "enqueues a upload_set job and redirects to generic_works list with a flash message" do
|
15
15
|
expect(UploadSetUpdateJob).to receive(:perform_later).with(user.user_key, upload_set.id, { '1' => 'foo' },
|
16
16
|
{ tag: [] }, 'open').once
|
17
|
-
post :update, id: upload_set.id, title: { '1' => 'foo' }, visibility: 'open',
|
17
|
+
post :update, id: upload_set.id, title: { '1' => 'foo' }, visibility: 'open', upload_set: { tag: [""] }
|
18
18
|
expect(response).to redirect_to routes.url_helpers.curation_concerns_generic_works_path
|
19
19
|
expect(flash[:notice]).to include("Your files are being processed")
|
20
20
|
end
|
@@ -22,55 +22,48 @@ describe UploadSetsController do
|
|
22
22
|
|
23
23
|
describe "when user has edit permissions on a file" do
|
24
24
|
# TODO: all these tests could move to upload_set_update_job_spec.rb
|
25
|
-
let!(:
|
25
|
+
let!(:work) { create(:generic_work, user: user, upload_set: upload_set) }
|
26
26
|
|
27
27
|
it "they can set public read access" do
|
28
|
-
post :update, id: upload_set, visibility: "open",
|
29
|
-
expect(
|
28
|
+
post :update, id: upload_set, visibility: "open", upload_set: { tag: [""] }
|
29
|
+
expect(work.reload.read_groups).to eq ['public']
|
30
30
|
end
|
31
31
|
|
32
32
|
it "they can set metadata like title" do
|
33
|
-
post :update, id: upload_set,
|
34
|
-
|
35
|
-
expect(
|
33
|
+
post :update, id: upload_set, upload_set: { tag: ["footag", "bartag"] }, title: { work.id => ["New Title"] }
|
34
|
+
work.reload
|
35
|
+
expect(work.title).to eq ["New Title"]
|
36
36
|
# TODO: is order important?
|
37
|
-
expect(
|
37
|
+
expect(work.tag).to include("footag", "bartag")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "they cannot set any tags" do
|
41
|
-
post :update, id: upload_set,
|
42
|
-
expect(
|
41
|
+
post :update, id: upload_set, upload_set: { tag: [""] }
|
42
|
+
expect(work.reload.tag).to be_empty
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "when user does not have edit permissions on a file" do
|
47
47
|
# TODO: all these tests could move to upload_set_update_job_spec.rb
|
48
|
-
let(:
|
49
|
-
FileSet.new(upload_set: upload_set, title: ['Original Title']) do |f|
|
50
|
-
f.apply_depositor_metadata('someone_else')
|
51
|
-
f.save!
|
52
|
-
end
|
53
|
-
end
|
48
|
+
let!(:work) { create(:generic_work, title: ['Original Title'], upload_set: upload_set) }
|
54
49
|
|
55
50
|
it "they cannot modify the object" do
|
56
|
-
post :update, id: upload_set,
|
57
|
-
|
58
|
-
|
59
|
-
expect(
|
51
|
+
post :update, id: upload_set, upload_set: { "tag" => [""] },
|
52
|
+
title: { work.id => "Title Won't Change" }
|
53
|
+
work.reload
|
54
|
+
expect(work.title).to eq ["Original Title"]
|
60
55
|
end
|
61
56
|
end
|
62
57
|
end
|
63
58
|
|
64
59
|
describe "#edit" do
|
65
60
|
let(:us1) { UploadSet.create }
|
66
|
-
let!(:file) { FileSet.create(upload_set: us1, label: 'f1') { |f| f.apply_depositor_metadata(user) } }
|
67
|
-
let!(:file2) { FileSet.create(upload_set: us1, label: 'f2') { |f| f.apply_depositor_metadata(user) } }
|
68
61
|
|
69
62
|
it "sets up attributes for the form" do
|
70
63
|
get :edit, id: us1
|
71
|
-
expect(assigns[:form]).
|
72
|
-
expect(assigns[:form].
|
73
|
-
expect(
|
64
|
+
expect(assigns[:form]).to be_kind_of CurationConcerns::UploadSetForm
|
65
|
+
expect(assigns[:form].model).to eq us1
|
66
|
+
expect(response).to be_success
|
74
67
|
end
|
75
68
|
end
|
76
69
|
end
|
data/spec/factories/file_sets.rb
CHANGED
@@ -26,6 +26,7 @@ FactoryGirl.define do
|
|
26
26
|
factory :work_with_files do
|
27
27
|
before(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
|
28
28
|
end
|
29
|
+
|
29
30
|
factory :work_with_ordered_files do
|
30
31
|
before(:create) do |work, evaluator|
|
31
32
|
work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
|
data/spec/factories/users.rb
CHANGED
@@ -10,17 +10,5 @@ FactoryGirl.define do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
factory :jill do
|
15
|
-
email 'jilluser@example.com'
|
16
|
-
end
|
17
|
-
|
18
|
-
factory :archivist, aliases: [:user_with_fixtures] do
|
19
|
-
email 'archivist1@example.com'
|
20
|
-
end
|
21
|
-
|
22
|
-
factory :curator do
|
23
|
-
email 'curator1@example.com'
|
24
|
-
end
|
25
13
|
end
|
26
14
|
end
|
@@ -21,10 +21,8 @@ describe 'collection' do
|
|
21
21
|
let(:user_key) { user.user_key }
|
22
22
|
let(:generic_works) do
|
23
23
|
(0..12).map do |x|
|
24
|
-
GenericWork.
|
25
|
-
f.title = ["title #{x}"]
|
24
|
+
GenericWork.create!(title: ["title #{x}"]) do |f|
|
26
25
|
f.apply_depositor_metadata('user1@example.com')
|
27
|
-
f.save!
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -9,10 +9,23 @@ describe CurationConcerns::Forms::CollectionEditForm do
|
|
9
9
|
it do
|
10
10
|
is_expected.to eq [:resource_type, :title, :creator, :contributor, :description,
|
11
11
|
:tag, :rights, :publisher, :date_created, :subject, :language,
|
12
|
-
:identifier, :based_near, :related_url, :visibility]
|
12
|
+
:representative_id, :thumbnail_id, :identifier, :based_near, :related_url, :visibility]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe "#human_readable_type" do
|
17
|
+
subject { form.human_readable_type }
|
18
|
+
it { is_expected.to eq 'Collection' }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#member_ids" do
|
22
|
+
before do
|
23
|
+
allow(collection).to receive(:member_ids).and_return(['9999'])
|
24
|
+
end
|
25
|
+
subject { form.member_ids }
|
26
|
+
it { is_expected.to eq ['9999'] }
|
27
|
+
end
|
28
|
+
|
16
29
|
describe ".build_permitted_params" do
|
17
30
|
subject { described_class.build_permitted_params }
|
18
31
|
it { is_expected.to eq [{ resource_type: [] },
|
@@ -26,6 +39,8 @@ describe CurationConcerns::Forms::CollectionEditForm do
|
|
26
39
|
{ date_created: [] },
|
27
40
|
{ subject: [] },
|
28
41
|
{ language: [] },
|
42
|
+
:representative_id,
|
43
|
+
:thumbnail_id,
|
29
44
|
{ identifier: [] },
|
30
45
|
{ based_near: [] },
|
31
46
|
{ related_url: [] },
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurationConcerns::UploadSetForm do
|
4
|
+
let(:form) { described_class.new(upload_set, ability) }
|
5
|
+
let(:user) { build(:user) }
|
6
|
+
let(:ability) { Ability.new(user) }
|
7
|
+
let(:upload_set) { UploadSet.create }
|
8
|
+
let!(:work1) { create(:work, upload_set: upload_set) }
|
9
|
+
let!(:work2) { create(:work, upload_set: upload_set) }
|
10
|
+
|
11
|
+
describe "#to_param" do
|
12
|
+
subject { form.to_param }
|
13
|
+
it { is_expected.to eq upload_set.id }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#terms" do
|
17
|
+
subject { form.terms }
|
18
|
+
it { is_expected.to eq [:title,
|
19
|
+
:creator,
|
20
|
+
:contributor,
|
21
|
+
:description,
|
22
|
+
:tag,
|
23
|
+
:rights,
|
24
|
+
:publisher,
|
25
|
+
:date_created,
|
26
|
+
:subject,
|
27
|
+
:language,
|
28
|
+
:identifier,
|
29
|
+
:based_near,
|
30
|
+
:related_url,
|
31
|
+
:representative_id,
|
32
|
+
:thumbnail_id,
|
33
|
+
:files,
|
34
|
+
:visibility_during_embargo,
|
35
|
+
:embargo_release_date,
|
36
|
+
:visibility_after_embargo,
|
37
|
+
:visibility_during_lease,
|
38
|
+
:lease_expiration_date,
|
39
|
+
:visibility_after_lease,
|
40
|
+
:visibility] }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "works" do
|
44
|
+
let!(:work1) { create(:work_with_one_file, upload_set: upload_set, title: ['B title']) }
|
45
|
+
let!(:work2) { create(:work_with_one_file, upload_set: upload_set, title: ['A title']) }
|
46
|
+
subject { form.works }
|
47
|
+
it { is_expected.to eq [work2, work1] }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "creator" do
|
51
|
+
let(:user) { build(:user, email: 'bob@example.com') }
|
52
|
+
subject { form.creator }
|
53
|
+
it { is_expected.to eq ['bob@example.com'] }
|
54
|
+
end
|
55
|
+
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe CurationConcerns::Forms::WorkForm do
|
4
4
|
before do
|
5
5
|
class PirateShip < ActiveFedora::Base
|
6
|
+
include CurationConcerns::RequiredMetadata
|
6
7
|
include CurationConcerns::BasicMetadata
|
7
8
|
include CurationConcerns::HasRepresentative
|
8
9
|
end
|
@@ -17,17 +18,25 @@ describe CurationConcerns::Forms::WorkForm do
|
|
17
18
|
Object.send(:remove_const, :PirateShip)
|
18
19
|
end
|
19
20
|
|
20
|
-
let(:curation_concern) { create(:
|
21
|
-
let(:title) { curation_concern.file_sets.first.title.first }
|
22
|
-
let(:file_id) { curation_concern.file_sets.first.id }
|
21
|
+
let(:curation_concern) { create(:work) }
|
23
22
|
let(:ability) { nil }
|
24
23
|
let(:form) { PirateShipForm.new(curation_concern, ability) }
|
25
24
|
|
26
25
|
describe "#select_files" do
|
26
|
+
let(:curation_concern) { create(:work_with_one_file) }
|
27
|
+
let(:title) { curation_concern.file_sets.first.title.first }
|
28
|
+
let(:file_id) { curation_concern.file_sets.first.id }
|
29
|
+
|
27
30
|
subject { form.select_files }
|
28
31
|
it { is_expected.to eq(title => file_id) }
|
29
32
|
end
|
30
33
|
|
34
|
+
describe "#[]" do
|
35
|
+
it 'has one element' do
|
36
|
+
expect(form['description']).to eq ['']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
describe '.model_attributes' do
|
32
41
|
let(:params) { ActionController::Parameters.new(
|
33
42
|
title: ['foo'],
|
@@ -36,6 +45,7 @@ describe CurationConcerns::Forms::WorkForm do
|
|
36
45
|
admin_set_id: '123',
|
37
46
|
representative_id: '456',
|
38
47
|
thumbnail_id: '789',
|
48
|
+
tag: ['derp'],
|
39
49
|
rights: 'http://creativecommons.org/licenses/by/3.0/us/')
|
40
50
|
}
|
41
51
|
subject { PirateShipForm.model_attributes(params) }
|
@@ -45,10 +55,65 @@ describe CurationConcerns::Forms::WorkForm do
|
|
45
55
|
expect(subject['description']).to be_empty
|
46
56
|
expect(subject['visibility']).to eq 'open'
|
47
57
|
expect(subject['rights']).to eq ['http://creativecommons.org/licenses/by/3.0/us/']
|
58
|
+
expect(subject['tag']).to eq ['derp']
|
48
59
|
end
|
49
60
|
|
50
61
|
it 'excludes non-permitted params' do
|
51
62
|
expect(subject).not_to have_key 'admin_set_id'
|
52
63
|
end
|
53
64
|
end
|
65
|
+
|
66
|
+
describe "initialized fields" do
|
67
|
+
context "for :description" do
|
68
|
+
subject { form[:description] }
|
69
|
+
it { is_expected.to eq [''] }
|
70
|
+
end
|
71
|
+
|
72
|
+
context "for :embargo_release_date" do
|
73
|
+
subject { form[:embargo_release_date] }
|
74
|
+
it { is_expected.to be nil }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#human_readable_type' do
|
79
|
+
subject { form.human_readable_type }
|
80
|
+
it { is_expected.to eq 'Generic Work' }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#open_access?" do
|
84
|
+
subject { form.open_access? }
|
85
|
+
it { is_expected.to be false }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#authenticated_only_access?" do
|
89
|
+
subject { form.authenticated_only_access? }
|
90
|
+
it { is_expected.to be false }
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#open_access_with_embargo_release_date?" do
|
94
|
+
subject { form.open_access_with_embargo_release_date? }
|
95
|
+
it { is_expected.to be false }
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#private_access?" do
|
99
|
+
subject { form.private_access? }
|
100
|
+
it { is_expected.to be true }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#member_ids" do
|
104
|
+
subject { form.member_ids }
|
105
|
+
it { is_expected.to eq curation_concern.member_ids }
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#embargo_release_date" do
|
109
|
+
let(:curation_concern) { create(:work, embargo_release_date: 5.days.from_now) }
|
110
|
+
subject { form.embargo_release_date }
|
111
|
+
it { is_expected.to eq curation_concern.embargo_release_date }
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#lease_expiration_date" do
|
115
|
+
let(:curation_concern) { create(:work, lease_expiration_date: 2.days.from_now) }
|
116
|
+
subject { form.lease_expiration_date }
|
117
|
+
it { is_expected.to eq curation_concern.lease_expiration_date }
|
118
|
+
end
|
54
119
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurationConcerns::AbilityHelper do
|
4
|
+
describe "#visibility_badge" do
|
5
|
+
subject { helper.visibility_badge visibility }
|
6
|
+
{
|
7
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC =>
|
8
|
+
"<span class=\"label label-success\">Open Access</span>",
|
9
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED =>
|
10
|
+
"<span class=\"label label-info\">%s</span>",
|
11
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE =>
|
12
|
+
"<span class=\"label label-danger\">Private</span>",
|
13
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO =>
|
14
|
+
"<span class=\"label label-warning\">Embargo</span>",
|
15
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE =>
|
16
|
+
"<span class=\"label label-warning\">Lease</span>"
|
17
|
+
}.each do |value, output|
|
18
|
+
context value do
|
19
|
+
let(:visibility) { value }
|
20
|
+
it { expect(subject).to eql(output % t('curation_concerns.institution_name')) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe "#visibility_options" do
|
25
|
+
let(:public_opt) { ['Open Access', Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC] }
|
26
|
+
let(:authenticated_opt) { [t('curation_concerns.institution_name'), Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED] }
|
27
|
+
let(:private_opt) { ['Private', Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE] }
|
28
|
+
subject { helper.visibility_options(option) }
|
29
|
+
context 'all options' do
|
30
|
+
let(:options) { [public_opt, authenticated_opt, private_opt] }
|
31
|
+
let(:option) { nil }
|
32
|
+
it { is_expected.to eql(options) }
|
33
|
+
end
|
34
|
+
context 'restricting options' do
|
35
|
+
let(:options) { [private_opt, authenticated_opt] }
|
36
|
+
let(:option) { :restrict }
|
37
|
+
it { is_expected.to eql(options) }
|
38
|
+
end
|
39
|
+
context 'loosening options' do
|
40
|
+
let(:options) { [public_opt, authenticated_opt] }
|
41
|
+
let(:option) { :loosen }
|
42
|
+
it { is_expected.to eql(options) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurationConcerns::PermissionsHelper do
|
4
|
+
describe "#help_link" do
|
5
|
+
subject { helper.help_link 'curation_concerns/base/visibility', 'Visibility', 'Usage information for visibility' }
|
6
|
+
|
7
|
+
it "draws help_icon" do
|
8
|
+
expect(subject).to match(/data-content="<p>This setting will determine who can view your file/)
|
9
|
+
expect(subject).to have_selector 'a i.help-icon'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -4,11 +4,16 @@ describe CurationConcerns::CollectionIndexer do
|
|
4
4
|
let(:indexer) { described_class.new(collection) }
|
5
5
|
let(:collection) { build(:collection) }
|
6
6
|
|
7
|
+
before { allow(collection).to receive(:bytes).and_return(1000) }
|
7
8
|
describe "#generate_solr_document" do
|
8
9
|
subject { indexer.generate_solr_document }
|
9
10
|
|
10
11
|
it "has generic type" do
|
11
12
|
expect(subject.fetch('generic_type_sim')).to eq ["Collection"]
|
12
13
|
end
|
14
|
+
|
15
|
+
it "has bytes" do
|
16
|
+
expect(subject.fetch('bytes_is')).to eq(1000)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|