sufia 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +146 -0
- data/.travis.yml +4 -7
- data/Gemfile +2 -0
- data/History.md +29 -1
- data/README.md +25 -9
- data/SUFIA_VERSION +1 -1
- data/app/assets/stylesheets/sufia/_collections.scss +15 -0
- data/app/assets/stylesheets/sufia/_file-listing.scss +7 -0
- data/app/assets/stylesheets/sufia/_home-page.scss +10 -0
- data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +3 -5
- data/app/controllers/admin/stats_controller.rb +1 -76
- data/app/controllers/api/items_controller.rb +4 -6
- data/app/controllers/api/zotero_controller.rb +5 -5
- data/app/controllers/authorities_controller.rb +5 -1
- data/app/controllers/batch_edits_controller.rb +3 -3
- data/app/controllers/concerns/sufia/admin/depositor_stats.rb +41 -0
- data/app/controllers/concerns/sufia/admin/stats_behavior.rb +94 -0
- data/app/controllers/concerns/sufia/batch_controller_behavior.rb +16 -18
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +54 -56
- data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -6
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +39 -39
- data/app/controllers/concerns/sufia/controller.rb +10 -10
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +17 -18
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +9 -12
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +6 -7
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +39 -40
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +109 -110
- data/app/controllers/concerns/sufia/homepage_controller.rb +8 -8
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +13 -10
- data/app/controllers/concerns/sufia/single_use_links_controller_behavior.rb +11 -14
- data/app/controllers/concerns/sufia/single_use_links_viewer_controller_behavior.rb +27 -21
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +17 -17
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +54 -54
- data/app/controllers/contact_form_controller.rb +1 -1
- data/app/controllers/content_blocks_controller.rb +11 -12
- data/app/controllers/directory_controller.rb +2 -3
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/featured_works_controller.rb +2 -4
- data/app/controllers/homepage_controller.rb +1 -2
- data/app/controllers/mailbox_controller.rb +12 -32
- data/app/controllers/my/collections_controller.rb +3 -4
- data/app/controllers/my/files_controller.rb +4 -6
- data/app/controllers/my/highlights_controller.rb +4 -6
- data/app/controllers/my/shares_controller.rb +3 -5
- data/app/controllers/pages_controller.rb +1 -3
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +0 -1
- data/app/controllers/static_controller.rb +1 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +2 -2
- data/app/helpers/batch_edits_helper.rb +1 -3
- data/app/helpers/content_block_helper.rb +7 -8
- data/app/helpers/generic_file_helper.rb +23 -24
- data/app/helpers/sufia/blacklight_override.rb +6 -7
- data/app/helpers/sufia/dashboard_helper_behavior.rb +4 -7
- data/app/helpers/sufia/permissions_helper.rb +3 -4
- data/app/helpers/sufia/sufia_helper_behavior.rb +30 -29
- data/app/helpers/trophy_helper.rb +15 -15
- data/app/inputs/select_with_modal_help_input.rb +3 -3
- data/app/inputs/with_help_icon.rb +4 -4
- data/app/jobs/content_delete_event_job.rb +0 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -2
- data/app/jobs/event_job.rb +0 -1
- data/app/jobs/user_unfollow_event_job.rb +1 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -2
- data/app/models/contact_form.rb +6 -6
- data/app/models/content_block.rb +1 -2
- data/app/models/featured_work_list.rb +3 -5
- data/app/models/user_mailbox.rb +44 -0
- data/app/presenters/sufia/collection_presenter.rb +6 -8
- data/app/presenters/sufia/generic_file_presenter.rb +2 -2
- data/app/presenters/sufia/presenter_renderer.rb +2 -2
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/presenters/sufia/version_presenter.rb +3 -6
- data/app/search_builders/deposit_search_builder.rb +19 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +1 -2
- data/app/search_builders/sufia/search_builder.rb +1 -3
- data/app/uploaders/tinymce_asset_uploader.rb +0 -2
- data/app/views/_controls.html.erb +5 -5
- data/app/views/admin/stats/_deposits.html.erb +19 -0
- data/app/views/admin/stats/index.html.erb +2 -0
- data/app/views/batch_edits/edit.html.erb +2 -2
- data/app/views/collections/_edit_actions.html.erb +3 -3
- data/app/views/collections/_form_for_select_collection.html.erb +2 -2
- data/app/views/collections/_sort_and_per_page.html.erb +12 -9
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/edit.html.erb +5 -5
- data/app/views/collections/show.html.erb +7 -6
- data/app/views/homepage/_announcement.html.erb +5 -0
- data/app/views/homepage/_home.html.erb +1 -0
- data/app/views/my/_sort_and_per_page.html.erb +14 -10
- data/app/views/my/index.html.erb +1 -1
- data/app/views/pages/show.html.erb +0 -2
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +2 -2
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/simple_form_bootstrap.rb +1 -1
- data/config/locales/sufia.en.yml +4 -0
- data/config/routes.rb +2 -3
- data/lib/generators/sufia/admin_stat_generator.rb +0 -3
- data/lib/generators/sufia/install_generator.rb +8 -9
- data/lib/generators/sufia/templates/catalog_controller.rb +2 -3
- data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +1 -0
- data/lib/generators/sufia/upgrade400_generator.rb +9 -9
- data/lib/generators/sufia/upgrade600_generator.rb +1 -4
- data/lib/sufia.rb +2 -2
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/arkivo/create_subscription_job.rb +30 -30
- data/lib/sufia/arkivo/metadata_munger.rb +7 -7
- data/lib/sufia/arkivo/schema_validator.rb +1 -1
- data/lib/sufia/single_use_error.rb +0 -1
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero/config.rb +13 -13
- data/spec/actors/generic_file/actor_spec.rb +17 -18
- data/spec/controllers/admin_stats_controller_spec.rb +56 -5
- data/spec/controllers/api/zotero_controller_spec.rb +10 -9
- data/spec/controllers/authorities_controller_spec.rb +8 -8
- data/spec/controllers/batch_controller_spec.rb +19 -20
- data/spec/controllers/batch_edits_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +7 -9
- data/spec/controllers/collections_controller_spec.rb +30 -32
- data/spec/controllers/content_blocks_controller_spec.rb +4 -4
- data/spec/controllers/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/depositors_controller_spec.rb +8 -8
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +4 -4
- data/spec/controllers/featured_works_controller_spec.rb +11 -12
- data/spec/controllers/generic_files_controller_spec.rb +154 -125
- data/spec/controllers/homepage_controller_spec.rb +22 -15
- data/spec/controllers/mailbox_controller_spec.rb +20 -36
- data/spec/controllers/my/collections_controller_spec.rb +4 -5
- data/spec/controllers/my/files_controller_spec.rb +10 -11
- data/spec/controllers/my/highlights_controller_spec.rb +4 -5
- data/spec/controllers/my/shares_controller_spec.rb +12 -14
- data/spec/controllers/my_controller_spec.rb +1 -3
- data/spec/controllers/pages_controller_spec.rb +4 -4
- data/spec/controllers/single_use_links_controller_spec.rb +1 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -2
- data/spec/controllers/static_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +8 -9
- data/spec/controllers/transfers_controller_spec.rb +19 -19
- data/spec/controllers/users_controller_spec.rb +33 -35
- data/spec/factories/api_items.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/generic_files.rb +3 -3
- data/spec/factories/users.rb +7 -8
- data/spec/features/browse_dashboard_files_spec.rb +14 -18
- data/spec/features/browse_files_spec.rb +3 -4
- data/spec/features/catalog_search_spec.rb +3 -5
- data/spec/features/cloud_upload_spec.rb +2 -2
- data/spec/features/collection_spec.rb +21 -21
- data/spec/features/contact_form_spec.rb +10 -11
- data/spec/features/display_dashboard_spec.rb +5 -9
- data/spec/features/edit_file_spec.rb +8 -9
- data/spec/features/featured_item_spec.rb +1 -1
- data/spec/features/ingest_upload_files_spec.rb +5 -5
- data/spec/features/notifications_spec.rb +2 -6
- data/spec/features/ownership_transfer_spec.rb +2 -2
- data/spec/features/proxy_spec.rb +2 -2
- data/spec/features/search_spec.rb +3 -4
- data/spec/features/single_use_links_spec.rb +1 -1
- data/spec/features/users_spec.rb +4 -5
- data/spec/forms/collection_edit_form_spec.rb +2 -2
- data/spec/forms/generic_file_edit_form_spec.rb +6 -7
- data/spec/helpers/batch_edits_helper_spec.rb +9 -13
- data/spec/helpers/content_block_helper_spec.rb +3 -3
- data/spec/helpers/dashboard_helper_spec.rb +19 -24
- data/spec/helpers/generic_file_helper_spec.rb +5 -7
- data/spec/helpers/sufia_helper_spec.rb +43 -54
- data/spec/helpers/trophy_helper_spec.rb +5 -5
- data/spec/inputs/multi_value_with_help_input_spec.rb +1 -2
- data/spec/inputs/select_with_help_input_spec.rb +19 -15
- data/spec/javascripts/jasmine_spec.rb +4 -5
- data/spec/javascripts/support/jasmine_helper.rb +9 -9
- data/spec/jobs/active_fedora_id_based_job_spec.rb +7 -5
- data/spec/jobs/audit_job_spec.rb +7 -7
- data/spec/jobs/batch_update_job_spec.rb +5 -6
- data/spec/jobs/characterize_job_spec.rb +1 -1
- data/spec/jobs/content_depositor_change_event_job_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +5 -5
- data/spec/jobs/event_jobs_spec.rb +16 -16
- data/spec/jobs/import_url_job_spec.rb +36 -5
- data/spec/jobs/ingest_local_file_job_spec.rb +31 -20
- data/spec/jobs/sufia_resque_queue_spec.rb +1 -1
- data/spec/lib/sufia/analytics_spec.rb +0 -1
- data/spec/lib/sufia/arkivo/actor_spec.rb +6 -6
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +18 -18
- data/spec/lib/sufia/breadcrumbs_spec.rb +5 -6
- data/spec/lib/sufia/messages_spec.rb +11 -12
- data/spec/lib/sufia/readable_permissions_spec.rb +8 -10
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +6 -7
- data/spec/lib/sufia/user_stat_importer_spec.rb +30 -33
- data/spec/lib/sufia/writable_permissions_spec.rb +1 -3
- data/spec/lib/sufia/zotero/config_spec.rb +4 -6
- data/spec/models/ability_spec.rb +11 -9
- data/spec/models/batch_spec.rb +13 -13
- data/spec/models/characterization_spec.rb +2 -3
- data/spec/models/checksum_audit_log_spec.rb +18 -19
- data/spec/models/collection_spec.rb +11 -12
- data/spec/models/content_block_spec.rb +33 -22
- data/spec/models/download_spec.rb +3 -5
- data/spec/models/featured_work_list_spec.rb +3 -3
- data/spec/models/featured_work_spec.rb +12 -14
- data/spec/models/file_content_datastream_spec.rb +9 -7
- data/spec/models/file_download_stat_spec.rb +34 -40
- data/spec/models/file_usage_spec.rb +46 -52
- data/spec/models/file_view_stat_spec.rb +35 -41
- data/spec/models/fits_datastream_spec.rb +23 -25
- data/spec/models/generic_file/visibility_spec.rb +10 -5
- data/spec/models/generic_file_spec.rb +86 -88
- data/spec/models/geo_names_resource_spec.rb +3 -5
- data/spec/models/local_authority_spec.rb +30 -33
- data/spec/models/pageview_spec.rb +3 -3
- data/spec/models/proxy_deposit_request_spec.rb +3 -3
- data/spec/models/single_use_link_spec.rb +36 -36
- data/spec/models/solr_document_spec.rb +3 -6
- data/spec/models/trophy_spec.rb +8 -9
- data/spec/models/user_mailbox_spec.rb +62 -0
- data/spec/models/user_spec.rb +28 -29
- data/spec/presenters/presenter_renderer_spec.rb +1 -1
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +5 -5
- data/spec/presenters/sufia/version_list_presenter_spec.rb +2 -2
- data/spec/presenters/sufia/version_presenter_spec.rb +1 -1
- data/spec/routing/featured_works_route_spec.rb +4 -4
- data/spec/routing/ownership_transfers_route_spec.rb +1 -1
- data/spec/routing/route_spec.rb +89 -89
- data/spec/services/generic_file_audit_service_spec.rb +8 -8
- data/spec/services/repository_audit_service_spec.rb +7 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/support/input_support.rb +1 -2
- data/spec/support/rake.rb +1 -1
- data/spec/support/selectors.rb +1 -6
- data/spec/support/statistic_helper.rb +1 -1
- data/spec/support/uploaded_file_monkeypatch.rb +1 -1
- data/spec/tasks/rake_spec.rb +3 -5
- data/spec/views/admin/stats/index.html.erb_spec.rb +16 -16
- data/spec/views/batch/edit.html.erb_spec.rb +1 -3
- data/spec/views/batch_edits/check_all_spec.rb +5 -5
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -3
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +4 -5
- data/spec/views/collections/_form.html.erb_spec.rb +5 -3
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +7 -8
- data/spec/views/collections/_show_document_list.erb_spec.rb +4 -6
- data/spec/views/dashboard/index_spec.rb +14 -21
- data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +8 -9
- data/spec/views/generic_file/edit.html.erb_spec.rb +7 -7
- data/spec/views/generic_file/show.html.erb_spec.rb +24 -25
- data/spec/views/generic_file/stats.html.erb_spec.rb +19 -19
- data/spec/views/homepage/_announcement.html.erb_spec.rb +51 -0
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +5 -9
- data/spec/views/homepage/_home_header.html.erb_spec.rb +2 -2
- data/spec/views/my/facet.html.erb_spec.rb +4 -4
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +28 -0
- data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +29 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +7 -8
- data/spec/views/users/_following_modal.html.erb_spec.rb +4 -5
- data/spec/views/users/_notify_number.html.erb_spec.rb +2 -5
- data/spec/views/users/_user_util_links.html.erb_spec.rb +5 -8
- data/spec/views/users/index.html.erb_spec.rb +4 -6
- data/spec/views/users/show.html.erb_spec.rb +4 -7
- data/tasks/sufia-dev.rake +19 -3
- metadata +20 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TransfersController, :
|
3
|
+
describe TransfersController, type: :controller do
|
4
4
|
describe "with a signed in user" do
|
5
5
|
let(:another_user) { FactoryGirl.find_or_create(:jill) }
|
6
6
|
let(:user) { FactoryGirl.find_or_create(:archivist) }
|
@@ -38,7 +38,7 @@ describe TransfersController, :type => :controller do
|
|
38
38
|
before do
|
39
39
|
incoming_file.destroy
|
40
40
|
end
|
41
|
-
it "
|
41
|
+
it "does not show that file" do
|
42
42
|
get :index
|
43
43
|
expect(response).to be_success
|
44
44
|
expect(assigns[:incoming]).to be_empty
|
@@ -54,7 +54,7 @@ describe TransfersController, :type => :controller do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
context 'when user is the depositor' do
|
57
|
-
it "
|
57
|
+
it "is successful" do
|
58
58
|
sign_in user
|
59
59
|
get :new, id: file
|
60
60
|
expect(response).to be_success
|
@@ -72,11 +72,11 @@ describe TransfersController, :type => :controller do
|
|
72
72
|
f.save!
|
73
73
|
end
|
74
74
|
end
|
75
|
-
it "
|
75
|
+
it "is successful" do
|
76
76
|
allow_any_instance_of(User).to receive(:display_name).and_return("Jill Z. User")
|
77
|
-
expect
|
78
|
-
post :create, id: file, proxy_deposit_request: {transfer_to: another_user.user_key}
|
79
|
-
|
77
|
+
expect do
|
78
|
+
post :create, id: file, proxy_deposit_request: { transfer_to: another_user.user_key }
|
79
|
+
end.to change(ProxyDepositRequest, :count).by(1)
|
80
80
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
81
81
|
expect(flash[:notice]).to eq('Transfer request created')
|
82
82
|
proxy_request = another_user.proxy_deposit_requests.first
|
@@ -87,10 +87,10 @@ describe TransfersController, :type => :controller do
|
|
87
87
|
expect(notification.subject).to eq("Ownership Change Request")
|
88
88
|
expect(notification.body).to eq("<a href=\"/users/#{user.user_key}\">#{user.name}</a> wants to transfer a file to you. Review all <a href=\"#{@routes.url_helpers.transfers_path}\">transfer requests</a>")
|
89
89
|
end
|
90
|
-
it "
|
91
|
-
expect
|
92
|
-
post :create, id: file, proxy_deposit_request: {transfer_to: 'foo' }
|
93
|
-
|
90
|
+
it "gives an error if the user is not found" do
|
91
|
+
expect do
|
92
|
+
post :create, id: file, proxy_deposit_request: { transfer_to: 'foo' }
|
93
|
+
end.not_to change(ProxyDepositRequest, :count)
|
94
94
|
expect(assigns[:proxy_deposit_request].errors[:transfer_to]).to eq(['must be an existing user'])
|
95
95
|
expect(response).to redirect_to(root_path)
|
96
96
|
end
|
@@ -105,21 +105,21 @@ describe TransfersController, :type => :controller do
|
|
105
105
|
f.request_transfer_to(user)
|
106
106
|
end
|
107
107
|
end
|
108
|
-
it "
|
108
|
+
it "is successful when retaining access rights" do
|
109
109
|
put :accept, id: user.proxy_deposit_requests.first
|
110
110
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
111
111
|
expect(flash[:notice]).to eq("Transfer complete")
|
112
112
|
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
113
113
|
expect(incoming_file.reload.edit_users).to eq([another_user.user_key, user.user_key])
|
114
114
|
end
|
115
|
-
it "
|
115
|
+
it "is successful when resetting access rights" do
|
116
116
|
put :accept, id: user.proxy_deposit_requests.first, reset: true
|
117
117
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
118
118
|
expect(flash[:notice]).to eq("Transfer complete")
|
119
119
|
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
120
120
|
expect(incoming_file.reload.edit_users).to eq([user.user_key])
|
121
121
|
end
|
122
|
-
it "
|
122
|
+
it "handles sticky requests" do
|
123
123
|
put :accept, id: user.proxy_deposit_requests.first, sticky: true
|
124
124
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
125
125
|
expect(flash[:notice]).to eq("Transfer complete")
|
@@ -136,7 +136,7 @@ describe TransfersController, :type => :controller do
|
|
136
136
|
f.request_transfer_to(another_user)
|
137
137
|
end
|
138
138
|
end
|
139
|
-
it "
|
139
|
+
it "does not allow me" do
|
140
140
|
put :accept, id: another_user.proxy_deposit_requests.first
|
141
141
|
expect(response).to redirect_to root_path
|
142
142
|
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
@@ -153,7 +153,7 @@ describe TransfersController, :type => :controller do
|
|
153
153
|
f.request_transfer_to(user)
|
154
154
|
end
|
155
155
|
end
|
156
|
-
it "
|
156
|
+
it "is successful" do
|
157
157
|
put :reject, id: user.proxy_deposit_requests.first
|
158
158
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
159
159
|
expect(flash[:notice]).to eq("Transfer rejected")
|
@@ -169,7 +169,7 @@ describe TransfersController, :type => :controller do
|
|
169
169
|
f.request_transfer_to(another_user)
|
170
170
|
end
|
171
171
|
end
|
172
|
-
it "
|
172
|
+
it "does not allow me" do
|
173
173
|
put :reject, id: another_user.proxy_deposit_requests.first
|
174
174
|
expect(response).to redirect_to root_path
|
175
175
|
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
@@ -186,7 +186,7 @@ describe TransfersController, :type => :controller do
|
|
186
186
|
f.request_transfer_to(another_user)
|
187
187
|
end
|
188
188
|
end
|
189
|
-
it "
|
189
|
+
it "is successful" do
|
190
190
|
delete :destroy, id: another_user.proxy_deposit_requests.first
|
191
191
|
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
192
192
|
expect(flash[:notice]).to eq("Transfer canceled")
|
@@ -201,7 +201,7 @@ describe TransfersController, :type => :controller do
|
|
201
201
|
f.request_transfer_to(user)
|
202
202
|
end
|
203
203
|
end
|
204
|
-
it "
|
204
|
+
it "does not allow me" do
|
205
205
|
delete :destroy, id: user.proxy_deposit_requests.first
|
206
206
|
expect(response).to redirect_to root_path
|
207
207
|
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UsersController, :
|
3
|
+
describe UsersController, type: :controller do
|
4
4
|
let(:user) { FactoryGirl.create(:user) }
|
5
5
|
before(:each) do
|
6
6
|
sign_in user
|
@@ -18,7 +18,7 @@ describe UsersController, :type => :controller do
|
|
18
18
|
it "redirects to root if user does not exist" do
|
19
19
|
get :show, id: 'johndoe666'
|
20
20
|
expect(response).to redirect_to(root_path)
|
21
|
-
expect(flash[:alert]).to include
|
21
|
+
expect(flash[:alert]).to include("User 'johndoe666' does not exist")
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "when the user has trophies" do
|
@@ -35,7 +35,6 @@ describe UsersController, :type => :controller do
|
|
35
35
|
expect(response).to be_success
|
36
36
|
expect(assigns[:trophies]).to match_array([file1, file2, file3])
|
37
37
|
end
|
38
|
-
|
39
38
|
end
|
40
39
|
end
|
41
40
|
describe "#index" do
|
@@ -43,25 +42,25 @@ describe UsersController, :type => :controller do
|
|
43
42
|
let!(:u2) { FactoryGirl.create(:user) }
|
44
43
|
|
45
44
|
describe "requesting html" do
|
46
|
-
it "
|
45
|
+
it "tests users" do
|
47
46
|
get :index
|
48
47
|
expect(assigns[:users]).to include(u1, u2)
|
49
48
|
expect(response).to be_successful
|
50
49
|
end
|
51
50
|
end
|
52
51
|
describe "requesting json" do
|
53
|
-
it "
|
52
|
+
it "displays users" do
|
54
53
|
get :index, format: :json
|
55
54
|
expect(response).to be_successful
|
56
55
|
json = JSON.parse(response.body)
|
57
|
-
expect(json.map{|u| u['id']}).to include(u1.email, u2.email)
|
58
|
-
expect(json.map{|u| u['text']}).to include(u1.email, u2.email)
|
56
|
+
expect(json.map { |u| u['id'] }).to include(u1.email, u2.email)
|
57
|
+
expect(json.map { |u| u['text'] }).to include(u1.email, u2.email)
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
|
-
describe "query users"
|
61
|
+
describe "query users" do
|
63
62
|
it "finds the expected user via email" do
|
64
|
-
get :index,
|
63
|
+
get :index, uq: u1.email
|
65
64
|
expect(assigns[:users]).to include(u1)
|
66
65
|
expect(assigns[:users]).to_not include(u2)
|
67
66
|
expect(response).to be_successful
|
@@ -73,7 +72,7 @@ describe UsersController, :type => :controller do
|
|
73
72
|
u2.display_name = "Jr. Architect"
|
74
73
|
u2.save
|
75
74
|
allow_any_instance_of(User).to receive(:display_name).and_return("Dr. Curator", "Jr.Archivist")
|
76
|
-
get :index,
|
75
|
+
get :index, uq: u1.display_name
|
77
76
|
expect(assigns[:users]).to include(u1)
|
78
77
|
expect(assigns[:users]).to_not include(u2)
|
79
78
|
expect(response).to be_successful
|
@@ -138,21 +137,20 @@ describe UsersController, :type => :controller do
|
|
138
137
|
expect(response).to be_success
|
139
138
|
expect(assigns[:trophies]).to match_array([file1, file2, file3])
|
140
139
|
end
|
141
|
-
|
142
140
|
end
|
143
141
|
end
|
144
142
|
|
145
143
|
describe "#update" do
|
146
144
|
context "the profile of another user" do
|
147
145
|
let(:another_user) { FactoryGirl.create(:user) }
|
148
|
-
it "
|
146
|
+
it "does not allow other users to update" do
|
149
147
|
post :update, id: another_user.user_key, user: { avatar: nil }
|
150
148
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
|
151
149
|
expect(flash[:alert]).to include("Permission denied: cannot access this page.")
|
152
150
|
end
|
153
151
|
end
|
154
152
|
|
155
|
-
it "
|
153
|
+
it "sets an avatar and redirect to profile" do
|
156
154
|
expect(user.avatar?).to be false
|
157
155
|
s1 = double('one')
|
158
156
|
expect(UserEditProfileEventJob).to receive(:new).with(user.user_key).and_return(s1)
|
@@ -163,14 +161,14 @@ describe UsersController, :type => :controller do
|
|
163
161
|
expect(flash[:notice]).to include("Your profile has been updated")
|
164
162
|
expect(User.find_by_user_key(user.user_key).avatar?).to be true
|
165
163
|
end
|
166
|
-
it "
|
164
|
+
it "validates the content type of an avatar" do
|
167
165
|
expect(Sufia.queue).to receive(:push).never
|
168
166
|
f = fixture_file_upload('/image.jp2', 'image/jp2')
|
169
167
|
post :update, id: user.user_key, user: { avatar: f }
|
170
168
|
expect(response).to redirect_to(@routes.url_helpers.edit_profile_path(user.to_param))
|
171
169
|
expect(flash[:alert]).to include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
|
172
170
|
end
|
173
|
-
it "
|
171
|
+
it "validates the size of an avatar" do
|
174
172
|
f = fixture_file_upload('/4-20.png', 'image/png')
|
175
173
|
expect(Sufia.queue).to receive(:push).never
|
176
174
|
post :update, id: user.user_key, user: { avatar: f }
|
@@ -184,7 +182,7 @@ describe UsersController, :type => :controller do
|
|
184
182
|
user.update(avatar: f)
|
185
183
|
end
|
186
184
|
|
187
|
-
it "
|
185
|
+
it "deletes an avatar" do
|
188
186
|
s1 = double('one')
|
189
187
|
expect(UserEditProfileEventJob).to receive(:new).with(user.user_key).and_return(s1)
|
190
188
|
expect(Sufia.queue).to receive(:push).with(s1).once
|
@@ -195,7 +193,7 @@ describe UsersController, :type => :controller do
|
|
195
193
|
end
|
196
194
|
end
|
197
195
|
|
198
|
-
it "
|
196
|
+
it "refreshes directory attributes" do
|
199
197
|
s1 = double('one')
|
200
198
|
expect(UserEditProfileEventJob).to receive(:new).with(user.user_key).and_return(s1)
|
201
199
|
expect(Sufia.queue).to receive(:push).with(s1).once
|
@@ -205,13 +203,13 @@ describe UsersController, :type => :controller do
|
|
205
203
|
expect(flash[:notice]).to include("Your profile has been updated")
|
206
204
|
end
|
207
205
|
|
208
|
-
it "
|
206
|
+
it "sets an social handles" do
|
209
207
|
expect(user.twitter_handle).to be_blank
|
210
208
|
expect(user.facebook_handle).to be_blank
|
211
209
|
expect(user.googleplus_handle).to be_blank
|
212
210
|
expect(user.linkedin_handle).to be_blank
|
213
211
|
expect(user.orcid).to be_blank
|
214
|
-
post :update, id: user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle:"link", orcid: '0000-0000-1111-2222' }
|
212
|
+
post :update, id: user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle: "link", orcid: '0000-0000-1111-2222' }
|
215
213
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
216
214
|
expect(flash[:notice]).to include("Your profile has been updated")
|
217
215
|
u = User.find_by_user_key(user.user_key)
|
@@ -234,10 +232,10 @@ describe UsersController, :type => :controller do
|
|
234
232
|
before do
|
235
233
|
user.trophies.create!(generic_file_id: file.id)
|
236
234
|
end
|
237
|
-
it "
|
238
|
-
expect
|
239
|
-
post :update, id: user.user_key, 'remove_trophy_'+file.id => 'yes'
|
240
|
-
|
235
|
+
it "removes a trophy" do
|
236
|
+
expect do
|
237
|
+
post :update, id: user.user_key, 'remove_trophy_' + file.id => 'yes'
|
238
|
+
end.to change { user.trophies.count }.by(-1)
|
241
239
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
242
240
|
expect(flash[:notice]).to include("Your profile has been updated")
|
243
241
|
end
|
@@ -246,7 +244,7 @@ describe UsersController, :type => :controller do
|
|
246
244
|
|
247
245
|
describe "#follow" do
|
248
246
|
let(:another_user) { FactoryGirl.create(:user) }
|
249
|
-
it "
|
247
|
+
it "follows another user if not already following, and log an event" do
|
250
248
|
expect(user.following?(another_user)).to be false
|
251
249
|
s1 = double('one')
|
252
250
|
expect(UserFollowEventJob).to receive(:new).with(user.user_key, another_user.user_key).and_return(s1)
|
@@ -255,14 +253,14 @@ describe UsersController, :type => :controller do
|
|
255
253
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
|
256
254
|
expect(flash[:notice]).to include("You are following #{another_user.user_key}")
|
257
255
|
end
|
258
|
-
it "
|
256
|
+
it "redirects to profile if already following and not log an event" do
|
259
257
|
allow_any_instance_of(User).to receive(:following?).with(another_user).and_return(true)
|
260
258
|
expect(Sufia.queue).to receive(:push).never
|
261
259
|
post :follow, id: another_user.user_key
|
262
260
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
|
263
261
|
expect(flash[:notice]).to include("You are following #{another_user.user_key}")
|
264
262
|
end
|
265
|
-
it "
|
263
|
+
it "redirects to profile if user attempts to self-follow and not log an event" do
|
266
264
|
expect(Sufia.queue).to receive(:push).never
|
267
265
|
post :follow, id: user.user_key
|
268
266
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
@@ -272,7 +270,7 @@ describe UsersController, :type => :controller do
|
|
272
270
|
|
273
271
|
describe "#unfollow" do
|
274
272
|
let(:another_user) { FactoryGirl.create(:user) }
|
275
|
-
it "
|
273
|
+
it "unfollows another user if already following, and log an event" do
|
276
274
|
allow_any_instance_of(User).to receive(:following?).with(another_user).and_return(true)
|
277
275
|
s1 = double('one')
|
278
276
|
expect(UserUnfollowEventJob).to receive(:new).with(user.user_key, another_user.user_key).and_return(s1)
|
@@ -281,14 +279,14 @@ describe UsersController, :type => :controller do
|
|
281
279
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
|
282
280
|
expect(flash[:notice]).to include("You are no longer following #{another_user.user_key}")
|
283
281
|
end
|
284
|
-
it "
|
282
|
+
it "redirects to profile if not following and not log an event" do
|
285
283
|
allow(user).to receive(:following?).with(another_user).and_return(false)
|
286
284
|
expect(Sufia.queue).to receive(:push).never
|
287
285
|
post :unfollow, id: another_user.user_key
|
288
286
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
|
289
287
|
expect(flash[:notice]).to include("You are no longer following #{another_user.user_key}")
|
290
288
|
end
|
291
|
-
it "
|
289
|
+
it "redirects to profile if user attempts to self-follow and not log an event" do
|
292
290
|
expect(Sufia.queue).to receive(:push).never
|
293
291
|
post :unfollow, id: user.user_key
|
294
292
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
@@ -301,19 +299,19 @@ describe UsersController, :type => :controller do
|
|
301
299
|
let(:file_id) { file.id }
|
302
300
|
let(:another_user) { FactoryGirl.create(:user) }
|
303
301
|
|
304
|
-
it "
|
305
|
-
post :toggle_trophy,
|
302
|
+
it "trophies a file" do
|
303
|
+
post :toggle_trophy, id: user.user_key, file_id: file_id
|
306
304
|
json = JSON.parse(response.body)
|
307
305
|
expect(json['user_id']).to eq user.id
|
308
306
|
expect(json['generic_file_id']).to eq file_id
|
309
307
|
end
|
310
|
-
it "
|
311
|
-
post :toggle_trophy,
|
308
|
+
it "does not trophy a file for a different user" do
|
309
|
+
post :toggle_trophy, id: another_user.user_key, file_id: file_id
|
312
310
|
expect(response).to_not be_success
|
313
311
|
end
|
314
|
-
it "
|
312
|
+
it "does not trophy a file with no edit privs" do
|
315
313
|
sign_in another_user
|
316
|
-
post :toggle_trophy,
|
314
|
+
post :toggle_trophy, id: another_user.user_key, file_id: file_id
|
317
315
|
expect(response).to_not be_success
|
318
316
|
end
|
319
317
|
end
|
data/spec/factories/api_items.rb
CHANGED
@@ -26,7 +26,7 @@ FactoryGirl.define do
|
|
26
26
|
{
|
27
27
|
creatorType: 'contributor',
|
28
28
|
name: 'Jane Doeski'
|
29
|
-
}
|
29
|
+
}
|
30
30
|
],
|
31
31
|
description: 'This was funded by the NSF in 2013',
|
32
32
|
publisher: 'National Science Foundation',
|
@@ -70,7 +70,7 @@ FactoryGirl.define do
|
|
70
70
|
{
|
71
71
|
creatorType: 'inventor',
|
72
72
|
name: 'Babs McGee'
|
73
|
-
}
|
73
|
+
}
|
74
74
|
],
|
75
75
|
rights: 'http://creativecommons.org/licenses/by-sa/3.0/us/',
|
76
76
|
tags: [
|
@@ -23,7 +23,7 @@ FactoryGirl.define do
|
|
23
23
|
initialize_with { new(id: id) }
|
24
24
|
read_groups ["public"]
|
25
25
|
resource_type ["Dissertation"]
|
26
|
-
subject %w
|
26
|
+
subject %w(lorem ipsum dolor sit amet)
|
27
27
|
title ["fake_document.pdf"]
|
28
28
|
before(:create) do |gf|
|
29
29
|
gf.title = ["Fake PDF Title"]
|
@@ -34,7 +34,7 @@ FactoryGirl.define do
|
|
34
34
|
id "fixturemp3"
|
35
35
|
end
|
36
36
|
initialize_with { new(id: id) }
|
37
|
-
subject %w
|
37
|
+
subject %w(consectetur adipisicing elit)
|
38
38
|
title ["Test Document MP3.mp3"]
|
39
39
|
read_groups ["public"]
|
40
40
|
end
|
@@ -46,7 +46,7 @@ FactoryGirl.define do
|
|
46
46
|
resource_type ["Audio", "Dataset"]
|
47
47
|
read_groups ["public"]
|
48
48
|
title ["Fake Wav File.wav"]
|
49
|
-
subject %w
|
49
|
+
subject %w(sed do eiusmod tempor incididunt ut labore)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/spec/factories/users.rb
CHANGED
@@ -19,31 +19,30 @@ FactoryGirl.define do
|
|
19
19
|
|
20
20
|
# Create examples of single file successes and failures
|
21
21
|
(1..10).each do |number|
|
22
|
-
file = MockFile.new(number.to_s, "Single File #{number
|
23
|
-
User.batchuser
|
24
|
-
User.batchuser
|
22
|
+
file = MockFile.new(number.to_s, "Single File #{number}")
|
23
|
+
User.batchuser.send_message(user, message.single_success("single-batch-success", file), message.success_subject, false)
|
24
|
+
User.batchuser.send_message(user, message.single_failure("single-batch-failure", file), message.failure_subject, false)
|
25
25
|
end
|
26
26
|
|
27
27
|
# Create examples of mulitple file successes and failures
|
28
28
|
files = []
|
29
29
|
(1..50).each do |number|
|
30
|
-
files << MockFile.new(number.to_s, "File #{number
|
30
|
+
files << MockFile.new(number.to_s, "File #{number}")
|
31
31
|
end
|
32
|
-
User.batchuser
|
33
|
-
User.batchuser
|
32
|
+
User.batchuser.send_message(user, message.multiple_success("multiple-batch-success", files), message.success_subject, false)
|
33
|
+
User.batchuser.send_message(user, message.multiple_failure("multiple-batch-failure", files), message.failure_subject, false)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
factory :curator do
|
38
38
|
email 'curator1@example.com'
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
43
|
class MockFile
|
45
44
|
attr_accessor :to_s, :id
|
46
|
-
def initialize
|
45
|
+
def initialize(id, string)
|
47
46
|
self.id = id
|
48
47
|
self.to_s = string
|
49
48
|
end
|
@@ -11,7 +11,7 @@ describe "Browse Dashboard", type: :feature do
|
|
11
11
|
context "within dashboard" do
|
12
12
|
let(:handles) { [:public_pdf] }
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "searches your files by default" do
|
15
15
|
visit "/dashboard"
|
16
16
|
fill_in "q", with: "PDF"
|
17
17
|
click_button "search-submit-header"
|
@@ -20,16 +20,15 @@ describe "Browse Dashboard", type: :feature do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
context "within my files page" do
|
23
|
-
|
24
23
|
before do
|
25
24
|
visit "/dashboard/files"
|
26
25
|
end
|
27
26
|
|
28
27
|
context "no files" do
|
29
|
-
let(:handles) { [
|
28
|
+
let(:handles) { [] }
|
30
29
|
|
31
|
-
it "
|
32
|
-
# TODO this would make a good view test.
|
30
|
+
it "links to my other tabs" do
|
31
|
+
# TODO: this would make a good view test.
|
33
32
|
["My Collections", "My Highlights", "Files Shared with Me"].each do |tab|
|
34
33
|
within("#my_nav") do
|
35
34
|
click_link(tab)
|
@@ -40,10 +39,10 @@ describe "Browse Dashboard", type: :feature do
|
|
40
39
|
end
|
41
40
|
|
42
41
|
context "with one file" do
|
43
|
-
let(:handles) { [
|
42
|
+
let(:handles) { [:public_pdf] }
|
44
43
|
|
45
|
-
it "
|
46
|
-
# TODO this would make a good view test.
|
44
|
+
it "displays all the necessary information" do
|
45
|
+
# TODO: this would make a good view test.
|
47
46
|
within("#document_#{fixtures.first.id}") do
|
48
47
|
click_button("Select an action")
|
49
48
|
end
|
@@ -62,9 +61,8 @@ describe "Browse Dashboard", type: :feature do
|
|
62
61
|
let(:handles) { [:public_pdf, :public_mp3, :public_wav] }
|
63
62
|
|
64
63
|
it "allows you to interact your own files" do
|
65
|
-
|
66
|
-
|
67
|
-
# TODO this would make a good view test.
|
64
|
+
# refreshes the page of files
|
65
|
+
# TODO: this would make a good view test.
|
68
66
|
click_button "Refresh"
|
69
67
|
within("#document_#{fixtures.first.id}") do
|
70
68
|
click_button("Select an action")
|
@@ -72,7 +70,7 @@ describe "Browse Dashboard", type: :feature do
|
|
72
70
|
expect(page).to have_content("Download File")
|
73
71
|
end
|
74
72
|
|
75
|
-
|
73
|
+
# allows you to search your own files and remove constraints
|
76
74
|
fill_in "q", with: "PDF"
|
77
75
|
click_button "search-submit-header"
|
78
76
|
expect(page).to have_content("Fake PDF Title")
|
@@ -83,7 +81,7 @@ describe "Browse Dashboard", type: :feature do
|
|
83
81
|
end
|
84
82
|
expect(page).to have_content("Fake Wav File")
|
85
83
|
|
86
|
-
|
84
|
+
# allows you to browse facets
|
87
85
|
visit "/dashboard/files"
|
88
86
|
click_link "Subject"
|
89
87
|
click_link "more Subjects"
|
@@ -93,8 +91,8 @@ describe "Browse Dashboard", type: :feature do
|
|
93
91
|
end
|
94
92
|
expect(page).to have_content("File Details")
|
95
93
|
|
96
|
-
|
97
|
-
# TODO this would make a good view test.
|
94
|
+
# allows me to edit files (from the fixtures)
|
95
|
+
# TODO: this would make a good view test.
|
98
96
|
visit "/dashboard/files"
|
99
97
|
|
100
98
|
fill_in "q", with: "Wav"
|
@@ -103,15 +101,13 @@ describe "Browse Dashboard", type: :feature do
|
|
103
101
|
click_link "Edit File"
|
104
102
|
expect(page).to have_content("Edit Fake Wav File.wav")
|
105
103
|
|
106
|
-
|
104
|
+
# allows me to edit files in batches"
|
107
105
|
visit "/dashboard/files"
|
108
106
|
|
109
107
|
first('input#check_all').click
|
110
108
|
click_button('Edit Selected')
|
111
109
|
expect(page).to have_content('3 files')
|
112
|
-
|
113
110
|
end
|
114
111
|
end
|
115
112
|
end
|
116
|
-
|
117
113
|
end
|