sufia 6.0.0.rc2 → 6.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/History.md +14 -0
- data/LICENSE +15 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia/batch_edit.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +8 -12
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +67 -0
- data/app/assets/stylesheets/sufia/_settings.scss +1 -0
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/assets/stylesheets/sufia/_tinymce.scss +14 -0
- data/app/controllers/batch_controller.rb +11 -2
- data/app/controllers/concerns/sufia/breadcrumbs.rb +2 -3
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/controller.rb +1 -7
- data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +3 -8
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +2 -3
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +27 -14
- data/app/controllers/concerns/sufia/homepage_controller.rb +3 -2
- data/app/controllers/content_blocks_controller.rb +17 -1
- data/app/controllers/downloads_controller.rb +0 -1
- data/app/controllers/my/shares_controller.rb +1 -0
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +3 -8
- data/app/forms/sufia/forms/generic_file_edit_form.rb +1 -8
- data/app/helpers/content_block_helper.rb +30 -10
- data/app/helpers/generic_file_helper.rb +4 -4
- data/app/helpers/sufia/dashboard_helper_behavior.rb +2 -2
- data/app/helpers/sufia/sufia_helper_behavior.rb +4 -4
- data/app/helpers/trophy_helper.rb +3 -3
- data/app/jobs/content_delete_event_job.rb +1 -2
- data/app/jobs/content_deposit_event_job.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -1
- data/app/jobs/content_new_version_event_job.rb +1 -1
- data/app/jobs/content_restored_version_event_job.rb +1 -1
- data/app/jobs/content_update_event_job.rb +1 -1
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -9
- data/app/models/content_block.rb +20 -0
- data/app/models/featured_work_list.rb +4 -0
- data/app/presenters/sufia/collection_presenter.rb +14 -2
- data/app/presenters/sufia/generic_file_presenter.rb +16 -0
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/views/batch/_metadata.html.erb +4 -4
- data/app/views/batch_edits/edit.html.erb +1 -1
- data/app/views/collections/_action_menu.html.erb +4 -5
- data/app/views/collections/_show_descriptions.html.erb +1 -5
- data/app/views/collections/_show_document_list.html.erb +0 -2
- data/app/views/collections/_show_document_list_menu.html.erb +5 -6
- data/app/views/collections/_show_document_list_row.html.erb +9 -9
- data/app/views/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/show.html.erb +3 -3
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_saved_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_updated_flash.html.erb +1 -1
- data/app/views/generic_files/_browse_everything.html.erb +4 -4
- data/app/views/generic_files/_media_display.html.erb +9 -9
- data/app/views/generic_files/_permission_form.html.erb +1 -1
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +2 -2
- data/app/views/generic_files/_show_details.html.erb +1 -1
- data/app/views/generic_files/_versioning.html.erb +9 -5
- data/app/views/generic_files/jq_upload.json.jbuilder +1 -1
- data/app/views/generic_files/new.html.erb +2 -3
- data/app/views/generic_files/show.html.erb +13 -16
- data/app/views/generic_files/upload/_alerts.html.erb +2 -2
- data/app/views/generic_files/upload/_form_fields.html.erb +1 -1
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
- data/app/views/homepage/_featured.html.erb +2 -4
- data/app/views/homepage/_featured_researcher.html.erb +1 -1
- data/app/views/homepage/_featured_works.html.erb +5 -3
- data/app/views/homepage/_home_content.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/homepage/_sortable_featured.html.erb +1 -2
- data/app/views/my/_action_menu.html.erb +8 -8
- data/app/views/my/_collection_action_menu.html.erb +4 -4
- data/app/views/my/_index_partials/_list_collections.html.erb +9 -12
- data/app/views/my/_index_partials/_list_files.html.erb +9 -9
- data/app/views/my/index.html.erb +0 -1
- data/app/views/records/_rights_modal.html.erb +1 -0
- data/app/views/users/_contributions.html.erb +2 -3
- data/app/views/users/_edit_primary.html.erb +68 -0
- data/app/views/users/_edit_secondary.html.erb +1 -0
- data/app/views/users/_trophy_edit.html.erb +1 -3
- data/app/views/users/edit.html.erb +4 -78
- data/config/initializers/simple_form.rb +167 -0
- data/config/initializers/simple_form_bootstrap.rb +137 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/locales/sufia.en.yml +7 -4
- data/config/routes.rb +1 -1
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/sufia/single_use_error.rb +1 -1
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +5 -5
- data/spec/controllers/batch_controller_spec.rb +15 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/content_blocks_controller_spec.rb +23 -3
- data/spec/controllers/downloads_controller_spec.rb +5 -5
- data/spec/controllers/generic_files_controller_spec.rb +12 -12
- data/spec/controllers/homepage_controller_spec.rb +19 -6
- data/spec/controllers/my/files_controller_spec.rb +8 -10
- data/spec/controllers/my/shares_controller_spec.rb +34 -23
- data/spec/controllers/single_use_links_controller_spec.rb +2 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +19 -20
- data/spec/controllers/users_controller_spec.rb +8 -8
- data/spec/factories/generic_files.rb +4 -4
- data/spec/factories/users.rb +2 -3
- data/spec/features/browse_dashboard_files_spec.rb +8 -8
- data/spec/features/collection_spec.rb +15 -8
- data/spec/features/edit_file_spec.rb +26 -0
- data/spec/features/single_use_links_spec.rb +3 -3
- data/spec/forms/generic_file_edit_form_spec.rb +8 -1
- data/spec/helpers/content_block_helper_spec.rb +10 -0
- data/spec/helpers/dashboard_helper_spec.rb +42 -0
- data/spec/helpers/sufia_helper_spec.rb +34 -7
- data/spec/helpers/trophy_helper_spec.rb +6 -6
- data/spec/inputs/select_with_help_input_spec.rb +16 -0
- data/spec/jobs/audit_job_spec.rb +1 -1
- data/spec/jobs/characterize_job_spec.rb +2 -7
- data/spec/jobs/create_derivatives_job_spec.rb +27 -38
- data/spec/jobs/import_url_job_spec.rb +2 -2
- data/spec/jobs/ingest_local_file_job_spec.rb +6 -8
- data/spec/lib/sufia/id_service_spec.rb +0 -7
- data/spec/lib/sufia/messages_spec.rb +16 -13
- data/spec/models/ability_spec.rb +3 -0
- data/spec/models/checksum_audit_log_spec.rb +1 -1
- data/spec/models/content_block_spec.rb +41 -0
- data/spec/models/featured_work_list_spec.rb +23 -9
- data/spec/models/file_content_datastream_spec.rb +4 -4
- data/spec/models/file_usage_spec.rb +1 -1
- data/spec/models/fits_datastream_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +31 -15
- data/spec/models/single_use_link_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +8 -5
- data/spec/models/user_spec.rb +3 -3
- data/spec/presenters/sufia/collection_presenter_spec.rb +34 -0
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +41 -1
- data/spec/presenters/sufia/version_list_presenter_spec.rb +12 -2
- data/spec/services/generic_file_audit_service_spec.rb +3 -3
- data/spec/services/noid_spec.rb +4 -11
- data/spec/services/repository_audit_service_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixture_helpers.rb +2 -3
- data/spec/support/selectors.rb +7 -7
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/views/batch/edit.html.erb_spec.rb +14 -17
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +29 -7
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +69 -151
- data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +29 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +12 -8
- data/sufia-models/app/jobs/batch_update_job.rb +2 -2
- data/sufia-models/app/jobs/import_url_job.rb +5 -3
- data/sufia-models/app/jobs/ingest_local_file_job.rb +46 -0
- data/sufia-models/app/jobs/resolrize_job.rb +1 -8
- data/sufia-models/app/models/batch.rb +0 -7
- data/sufia-models/app/models/concerns/sufia/ability.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/{collection.rb → collection_behavior.rb} +1 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +3 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +1 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +7 -7
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +16 -11
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +1 -14
- data/sufia-models/app/models/concerns/sufia/user.rb +5 -0
- data/sufia-models/app/models/file_usage.rb +1 -1
- data/sufia-models/app/models/file_view_stat.rb +1 -1
- data/sufia-models/app/models/sufia/collection.rb +5 -0
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +1 -1
- data/sufia-models/app/services/sufia/id_service.rb +1 -2
- data/sufia-models/app/services/sufia/noid.rb +4 -24
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +6 -1
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +2 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +46 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +9 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +18 -0
- data/sufia-models/lib/sufia/messages.rb +11 -12
- data/sufia-models/lib/sufia/models/engine.rb +2 -1
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +9 -5
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +5 -5
- data/sufia.gemspec +15 -15
- data/tasks/sufia-dev.rake +0 -16
- metadata +86 -64
- data/LICENSE.md +0 -14
- data/app/jobs/ingest_local_file_job.rb +0 -39
- data/sufia-models/app/models/collection.rb +0 -3
- data/sufia-models/app/services/sufia/indexing_service.rb +0 -15
@@ -89,7 +89,7 @@ describe CollectionsController do
|
|
89
89
|
|
90
90
|
it "should set collection on members" do
|
91
91
|
put :update, id: collection, collection: {members:"add"}, batch_document_ids: [@asset3.id, @asset1.id, @asset2.id]
|
92
|
-
expect(response).to redirect_to routes.url_helpers.collection_path(collection
|
92
|
+
expect(response).to redirect_to routes.url_helpers.collection_path(collection)
|
93
93
|
expect(assigns[:collection].members).to match_array [@asset2, @asset3, @asset1]
|
94
94
|
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
95
95
|
expect(asset_results["response"]["numFound"]).to eq 1
|
@@ -6,10 +6,15 @@ describe ContentBlocksController, :type => :controller do
|
|
6
6
|
before { request.env["HTTP_REFERER"] = "whence_i_came" }
|
7
7
|
|
8
8
|
context "when not logged in" do
|
9
|
-
it "should redirect to
|
9
|
+
it "UPDATE should redirect to sign_in path" do
|
10
10
|
patch :update, id: content_block, content_block: { value: 'foo' }
|
11
11
|
expect(response).to redirect_to main_app.new_user_session_path
|
12
12
|
end
|
13
|
+
|
14
|
+
it "CREATE should redirect to sign_in path" do
|
15
|
+
post :create, content_block: { name: 'NNN', value: 'VVV' }
|
16
|
+
expect(response).to redirect_to main_app.new_user_session_path
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
context "when logged in" do
|
@@ -19,18 +24,33 @@ describe ContentBlocksController, :type => :controller do
|
|
19
24
|
context "as a user in the admin group" do
|
20
25
|
before { expect(user).to receive(:groups).and_return( ['admin', 'registered']) }
|
21
26
|
|
22
|
-
it "should save" do
|
27
|
+
it "UPDATE should save" do
|
23
28
|
patch :update, id: content_block, content_block: { value: 'foo' }
|
24
29
|
expect(response).to redirect_to "whence_i_came"
|
25
30
|
expect(assigns[:content_block].value).to eq 'foo'
|
26
31
|
end
|
32
|
+
|
33
|
+
it "CREATE should save" do
|
34
|
+
expect {
|
35
|
+
post :create, content_block: { name: 'NNN', value: 'VVV', external_key: 'key' }
|
36
|
+
}.to change { ContentBlock.count}.by(1)
|
37
|
+
expect(response).to redirect_to "whence_i_came"
|
38
|
+
expect(assigns[:content_block].name).to eq 'NNN'
|
39
|
+
expect(assigns[:content_block].value).to eq 'VVV'
|
40
|
+
expect(assigns[:content_block].external_key).to eq 'key'
|
41
|
+
end
|
27
42
|
end
|
28
43
|
|
29
44
|
context "as a user without permission" do
|
30
|
-
it "should redirect to root path" do
|
45
|
+
it "UPDATE should redirect to root path" do
|
31
46
|
patch :update, id: content_block, content_block: { value: 'foo' }
|
32
47
|
expect(response).to redirect_to root_path
|
33
48
|
end
|
49
|
+
|
50
|
+
it "CREATE should redirect to root path" do
|
51
|
+
post :create, content_block: { name: 'NNN', value: 'VVV' }
|
52
|
+
expect(response).to redirect_to root_path
|
53
|
+
end
|
34
54
|
end
|
35
55
|
end
|
36
56
|
end
|
@@ -5,10 +5,10 @@ describe DownloadsController, :type => :controller do
|
|
5
5
|
describe "with a file" do
|
6
6
|
let(:depositor) { FactoryGirl.find_or_create(:archivist) }
|
7
7
|
let(:file) do
|
8
|
-
GenericFile.
|
8
|
+
GenericFile.create do |f|
|
9
9
|
f.apply_depositor_metadata(depositor.user_key)
|
10
|
-
f.
|
11
|
-
f.
|
10
|
+
f.label = 'world.png'
|
11
|
+
f.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png', mime_type: 'image/png')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -27,7 +27,7 @@ describe DownloadsController, :type => :controller do
|
|
27
27
|
let(:expected_content) { expected_datastream.content }
|
28
28
|
|
29
29
|
it "should default to returning configured default download" do
|
30
|
-
expect(DownloadsController.
|
30
|
+
expect(DownloadsController.default_file_path).to eq "content"
|
31
31
|
expect(controller).to receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
|
32
32
|
get "show", id: file
|
33
33
|
expect(response).to be_success
|
@@ -42,7 +42,7 @@ describe DownloadsController, :type => :controller do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should return requested datastreams" do
|
45
|
-
get "show", id: file,
|
45
|
+
get "show", id: file, file: "characterization"
|
46
46
|
expect(response).to be_success
|
47
47
|
expect(response.body).to eq expected_content
|
48
48
|
end
|
@@ -42,16 +42,15 @@ describe GenericFilesController do
|
|
42
42
|
context "when everything is perfect" do
|
43
43
|
render_views
|
44
44
|
it "spawns a content deposit event job" do
|
45
|
-
expect_any_instance_of(Sufia::GenericFile::Actor).to receive(:create_content).with(file, 'world.png', 'content').and_return(true)
|
45
|
+
expect_any_instance_of(Sufia::GenericFile::Actor).to receive(:create_content).with(file, 'world.png', 'content', 'image/png').and_return(true)
|
46
46
|
xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: {group: { public: 'read' } }, terms_of_service: '1'
|
47
47
|
expect(response.body).to eq '[{"name":null,"size":"","url":"/files/test123","thumbnail_url":"test123","delete_url":"deleteme","delete_type":"DELETE"}]'
|
48
48
|
expect(flash[:error]).to be_nil
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should create and save a file asset from the given params" do
|
52
|
-
|
53
|
-
|
54
|
-
allow(Date).to receive(:today).and_return(date_today)
|
52
|
+
date_today = DateTime.now
|
53
|
+
allow(DateTime).to receive(:now).and_return(date_today)
|
55
54
|
expect {
|
56
55
|
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id,
|
57
56
|
permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
@@ -65,8 +64,8 @@ describe GenericFilesController do
|
|
65
64
|
file.rewind
|
66
65
|
expect(saved_file.content.content).to eq (file.read)
|
67
66
|
# Confirming that date_uploaded and date_modified were set
|
68
|
-
expect(saved_file.date_uploaded).to eq date_today
|
69
|
-
expect(saved_file.date_modified).to eq date_today
|
67
|
+
expect(saved_file.date_uploaded).to eq date_today.new_offset(0)
|
68
|
+
expect(saved_file.date_modified).to eq date_today.new_offset(0)
|
70
69
|
end
|
71
70
|
|
72
71
|
it "should record what user created the first version of content" do
|
@@ -214,7 +213,7 @@ describe GenericFilesController do
|
|
214
213
|
describe "audit" do
|
215
214
|
let(:generic_file) do
|
216
215
|
GenericFile.create do |gf|
|
217
|
-
gf.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
216
|
+
gf.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
218
217
|
gf.apply_depositor_metadata(user)
|
219
218
|
end
|
220
219
|
end
|
@@ -293,7 +292,7 @@ describe GenericFilesController do
|
|
293
292
|
allow(controller.request).to receive(:referer).and_return('foo')
|
294
293
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
295
294
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
296
|
-
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(generic_file
|
295
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(generic_file))
|
297
296
|
get :stats, id: generic_file
|
298
297
|
expect(response).to be_success
|
299
298
|
expect(response).to render_template(:stats)
|
@@ -336,7 +335,7 @@ describe GenericFilesController do
|
|
336
335
|
allow(controller.request).to receive(:referer).and_return('foo')
|
337
336
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
338
337
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
339
|
-
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(generic_file
|
338
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(generic_file))
|
340
339
|
get :edit, id: generic_file
|
341
340
|
|
342
341
|
expect(response).to be_success
|
@@ -408,8 +407,8 @@ describe GenericFilesController do
|
|
408
407
|
|
409
408
|
before do
|
410
409
|
allow_any_instance_of(GenericFile).to receive(:characterize)
|
411
|
-
actor1.create_content(fixture_file_upload(file1), file1, 'content')
|
412
|
-
actor2.create_content(fixture_file_upload(file2), file2, 'content')
|
410
|
+
actor1.create_content(fixture_file_upload(file1), file1, 'content', file1_type)
|
411
|
+
actor2.create_content(fixture_file_upload(file2), file2, 'content', file2_type)
|
413
412
|
end
|
414
413
|
|
415
414
|
describe "restoring a previous version" do
|
@@ -498,6 +497,7 @@ describe GenericFilesController do
|
|
498
497
|
expect(response).to be_successful
|
499
498
|
expect(response).to render_template('edit')
|
500
499
|
expect(assigns[:generic_file]).to eq generic_file
|
500
|
+
expect(flash[:error]).to include 'Update was unsuccessful.'
|
501
501
|
end
|
502
502
|
end
|
503
503
|
end
|
@@ -506,7 +506,7 @@ describe GenericFilesController do
|
|
506
506
|
let(:generic_file) do
|
507
507
|
GenericFile.create(id: 'test5') do |f|
|
508
508
|
f.apply_depositor_metadata('archivist1@example.com')
|
509
|
-
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
509
|
+
f.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
510
510
|
# grant public read access explicitly
|
511
511
|
f.read_groups = ['public']
|
512
512
|
end
|
@@ -18,12 +18,25 @@ describe HomepageController, :type => :controller do
|
|
18
18
|
sign_in user
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
context 'with existing featured researcher' do
|
22
|
+
let!(:bilbo) { ContentBlock.create!(name: ContentBlock::RESEARCHER, value: 'Biblo Baggins', created_at: 2.hours.ago) }
|
23
|
+
let!(:frodo) { ContentBlock.create!(name: ContentBlock::RESEARCHER, value: 'Frodo Baggins', created_at: Time.now) }
|
24
|
+
|
25
|
+
it 'finds the featured researcher' do
|
26
|
+
get :index
|
27
|
+
expect(response).to be_success
|
28
|
+
expect(assigns(:featured_researcher)).to eq frodo
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with no featured researcher' do
|
33
|
+
it "should set featured researcher" do
|
34
|
+
get :index
|
35
|
+
expect(response).to be_success
|
36
|
+
assigns(:featured_researcher).tap do |researcher|
|
37
|
+
expect(researcher).to be_kind_of ContentBlock
|
38
|
+
expect(researcher.name).to eq 'featured_researcher'
|
39
|
+
end
|
27
40
|
end
|
28
41
|
end
|
29
42
|
|
@@ -19,7 +19,6 @@ describe My::FilesController, :type => :controller do
|
|
19
19
|
|
20
20
|
let(:user) { FactoryGirl.find_or_create(:archivist) }
|
21
21
|
|
22
|
-
|
23
22
|
before do
|
24
23
|
sign_in user
|
25
24
|
@my_file = FactoryGirl.create(:generic_file, depositor: user)
|
@@ -34,7 +33,7 @@ describe My::FilesController, :type => :controller do
|
|
34
33
|
expect(response).to be_successful
|
35
34
|
end
|
36
35
|
|
37
|
-
it "should paginate" do
|
36
|
+
it "should paginate" do
|
38
37
|
FactoryGirl.create(:generic_file)
|
39
38
|
FactoryGirl.create(:generic_file)
|
40
39
|
get :index, per_page: 2
|
@@ -59,21 +58,20 @@ describe My::FilesController, :type => :controller do
|
|
59
58
|
|
60
59
|
describe "batch processing" do
|
61
60
|
include Sufia::Messages
|
62
|
-
let (:
|
63
|
-
let (:
|
61
|
+
let (:batch_id) {"batch_id"}
|
62
|
+
let (:batch_id2) {"batch_id2"}
|
64
63
|
let (:batch) {double}
|
65
64
|
|
66
65
|
before do
|
67
|
-
allow(batch).to receive(:
|
68
|
-
User.batchuser().send_message(user, single_success(
|
69
|
-
User.batchuser().send_message(user, multiple_success(
|
66
|
+
allow(batch).to receive(:id).and_return(batch_id)
|
67
|
+
User.batchuser().send_message(user, single_success(batch_id, batch), success_subject, sanitize_text = false)
|
68
|
+
User.batchuser().send_message(user, multiple_success(batch_id2, [batch]), success_subject, sanitize_text = false)
|
70
69
|
get :index
|
71
70
|
end
|
72
71
|
it "gets batches that are complete" do
|
73
72
|
expect(assigns(:batches).count).to eq(2)
|
74
|
-
expect(assigns(:batches)).to include("ss-"+
|
75
|
-
expect(assigns(:batches)).to include("ss-"+
|
73
|
+
expect(assigns(:batches)).to include("ss-"+batch_id)
|
74
|
+
expect(assigns(:batches)).to include("ss-"+batch_id2)
|
76
75
|
end
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|
@@ -2,29 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe My::SharesController, :type => :controller do
|
4
4
|
describe "logged in user" do
|
5
|
+
let(:user) { FactoryGirl.find_or_create(:archivist) }
|
6
|
+
|
5
7
|
before (:each) do
|
6
|
-
|
7
|
-
sign_in @user
|
8
|
+
sign_in user
|
8
9
|
end
|
9
10
|
|
10
11
|
describe "#index" do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
r.
|
19
|
-
r.edit_users += [@user.user_key]
|
12
|
+
let(:other_user) { FactoryGirl.create(:user) }
|
13
|
+
|
14
|
+
let!(:my_file) { FactoryGirl.create(:generic_file, depositor: user) }
|
15
|
+
let!(:unshared_file) { FactoryGirl.create(:generic_file, depositor: other_user) }
|
16
|
+
|
17
|
+
let!(:shared_with_me) { FactoryGirl.create(:generic_file).tap do |r|
|
18
|
+
r.apply_depositor_metadata other_user
|
19
|
+
r.edit_users += [user.user_key]
|
20
20
|
r.save!
|
21
21
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
}
|
23
|
+
|
24
|
+
let!(:shared_with_someone_else) { FactoryGirl.create(:generic_file).tap do |r|
|
25
|
+
r.apply_depositor_metadata user
|
26
|
+
r.edit_users += [other_user.user_key]
|
25
27
|
r.save!
|
26
28
|
end
|
27
|
-
|
29
|
+
}
|
30
|
+
|
31
|
+
let!(:my_collection) { Collection.new(title: "My collection").tap do |c|
|
32
|
+
c.apply_depositor_metadata(user.user_key)
|
33
|
+
c.save!
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
28
37
|
|
29
38
|
it "should respond with success" do
|
30
39
|
get :index
|
@@ -33,13 +42,13 @@ describe My::SharesController, :type => :controller do
|
|
33
42
|
|
34
43
|
it "should paginate" do
|
35
44
|
FactoryGirl.create(:generic_file).tap do |r|
|
36
|
-
r.apply_depositor_metadata
|
37
|
-
r.edit_users += [
|
45
|
+
r.apply_depositor_metadata other_user
|
46
|
+
r.edit_users += [user.user_key]
|
38
47
|
r.save!
|
39
48
|
end
|
40
49
|
FactoryGirl.create(:generic_file).tap do |r|
|
41
|
-
r.apply_depositor_metadata
|
42
|
-
r.edit_users += [
|
50
|
+
r.apply_depositor_metadata other_user
|
51
|
+
r.edit_users += [user.user_key]
|
43
52
|
r.save!
|
44
53
|
end
|
45
54
|
get :index, per_page: 2
|
@@ -51,12 +60,14 @@ describe My::SharesController, :type => :controller do
|
|
51
60
|
it "shows the correct documents" do
|
52
61
|
get :index
|
53
62
|
# shows documents shared with me
|
54
|
-
expect(assigns[:document_list].map(&:id)).to include(
|
63
|
+
expect(assigns[:document_list].map(&:id)).to include(shared_with_me.id)
|
55
64
|
# doesn't show normal files
|
56
|
-
expect(assigns[:document_list].map(&:id)).to_not include(
|
57
|
-
expect(assigns[:document_list].map(&:id)).to_not include(
|
65
|
+
expect(assigns[:document_list].map(&:id)).to_not include(my_file.id)
|
66
|
+
expect(assigns[:document_list].map(&:id)).to_not include(unshared_file.id)
|
58
67
|
# doesn't show files shared with other users
|
59
|
-
expect(assigns[:document_list].map(&:id)).to_not include(
|
68
|
+
expect(assigns[:document_list].map(&:id)).to_not include(shared_with_someone_else.id)
|
69
|
+
# doesn't show my collections
|
70
|
+
expect(assigns[:document_list].map(&:id)).to_not include my_collection.id
|
60
71
|
end
|
61
72
|
end
|
62
73
|
end
|
@@ -4,10 +4,9 @@ describe SingleUseLinksController, :type => :controller do
|
|
4
4
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
5
5
|
|
6
6
|
let(:file) do
|
7
|
-
GenericFile.
|
8
|
-
file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
7
|
+
GenericFile.create do |file|
|
8
|
+
file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
9
9
|
file.apply_depositor_metadata(user)
|
10
|
-
file.save
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SingleUseLinksViewerController do
|
4
4
|
let(:file) do
|
5
|
-
GenericFile.
|
6
|
-
file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
5
|
+
GenericFile.create do |file|
|
6
|
+
file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png', mime_type: 'image/png')
|
7
|
+
file.label = 'world.png'
|
7
8
|
file.apply_depositor_metadata('mjg')
|
8
|
-
file.save!
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -34,20 +34,16 @@ describe SingleUseLinksViewerController do
|
|
34
34
|
get :download, id: download_link_hash
|
35
35
|
expect(response.body).to eq expected_content
|
36
36
|
expect(response).to be_success
|
37
|
+
expect { SingleUseLink.find_by_downloadKey!(download_link_hash) }.to raise_error ActiveRecord::RecordNotFound
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
expect(response).to be_success
|
42
|
-
get :download, id: download_link_hash
|
43
|
-
expect(response).to render_template('error/single_use_error')
|
44
|
-
end
|
40
|
+
context "and the key is not found" do
|
41
|
+
before { SingleUseLink.find_by_downloadKey!(download_link_hash).destroy }
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
expect(response).to render_template('error/single_use_error')
|
43
|
+
it "returns 404 if the key is not present" do
|
44
|
+
get :download, id: download_link_hash
|
45
|
+
expect(response).to render_template('error/single_use_error')
|
46
|
+
end
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
@@ -56,15 +52,18 @@ describe SingleUseLinksViewerController do
|
|
56
52
|
get 'show', id: show_link_hash
|
57
53
|
expect(response).to be_success
|
58
54
|
expect(assigns[:asset].id).to eq file.id
|
55
|
+
expect { SingleUseLink.find_by_downloadKey!(show_link_hash) }.to raise_error ActiveRecord::RecordNotFound
|
59
56
|
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
context "and the key is not found" do
|
59
|
+
before { SingleUseLink.find_by_downloadKey!(show_link_hash).destroy }
|
60
|
+
it "returns 404 if the key is not present" do
|
61
|
+
get :show, id: show_link_hash
|
62
|
+
expect(response).to render_template('error/single_use_error')
|
63
|
+
end
|
66
64
|
end
|
67
|
-
|
65
|
+
|
66
|
+
it "returns 404 on attempt to get show path with download hash" do
|
68
67
|
get :show, id: download_link_hash
|
69
68
|
expect(response).to render_template('error/single_use_error')
|
70
69
|
end
|
@@ -25,9 +25,9 @@ describe UsersController, :type => :controller do
|
|
25
25
|
let(:file1) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
26
26
|
let(:file2) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
27
27
|
let(:file3) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
28
|
-
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.
|
29
|
-
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.
|
30
|
-
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.
|
28
|
+
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.id) }
|
29
|
+
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.id) }
|
30
|
+
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.id) }
|
31
31
|
|
32
32
|
it "show the user profile if user exists" do
|
33
33
|
get :show, id: user.user_key
|
@@ -114,9 +114,9 @@ describe UsersController, :type => :controller do
|
|
114
114
|
let(:file1) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
115
115
|
let(:file2) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
116
116
|
let(:file3) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
117
|
-
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.
|
118
|
-
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.
|
119
|
-
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.
|
117
|
+
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.id) }
|
118
|
+
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.id) }
|
119
|
+
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.id) }
|
120
120
|
|
121
121
|
it "show the user profile if user exists" do
|
122
122
|
get :edit, id: user.user_key
|
@@ -217,11 +217,11 @@ describe UsersController, :type => :controller do
|
|
217
217
|
context "when removing a trophy" do
|
218
218
|
let(:file) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
219
219
|
before do
|
220
|
-
user.trophies.create!(generic_file_id: file.
|
220
|
+
user.trophies.create!(generic_file_id: file.id)
|
221
221
|
end
|
222
222
|
it "should remove a trophy" do
|
223
223
|
expect {
|
224
|
-
post :update, id: user.user_key, 'remove_trophy_'+file.
|
224
|
+
post :update, id: user.user_key, 'remove_trophy_'+file.id => 'yes'
|
225
225
|
}.to change { user.trophies.count }.by(-1)
|
226
226
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
227
227
|
expect(flash[:notice]).to include("Your profile has been updated")
|