sufia 7.0.0.beta3 → 7.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +66 -7
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +6 -3
- data/app/controllers/concerns/sufia/controller.rb +0 -7
- data/app/controllers/concerns/sufia/file_sets_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/uploads_controller_behavior.rb +18 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -25
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +31 -32
- data/app/controllers/curation_concerns/audits_controller.rb +0 -1
- data/app/controllers/sufia/resource_sync_controller.rb +41 -0
- data/app/controllers/sufia/trophies_controller.rb +17 -0
- data/app/controllers/sufia/uploads_controller.rb +1 -12
- data/app/helpers/sufia/sufia_helper_behavior.rb +15 -3
- data/app/helpers/trophy_helper.rb +1 -1
- data/app/models/concerns/sufia/user.rb +0 -12
- data/app/models/contact_form.rb +2 -2
- data/app/models/local_authority.rb +5 -2
- data/app/presenters/sufia/user_profile_presenter.rb +29 -0
- data/app/services/sufia/query_service.rb +1 -1
- data/app/views/collections/_edit_actions.html.erb +2 -1
- data/app/views/collections/_show_actions.html.erb +2 -1
- data/app/views/collections/_work_action_menu.html.erb +1 -1
- data/app/views/contact_form/new.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_progress.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_contents.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_proxy_rights.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +1 -0
- data/app/views/my/_work_action_menu.html.erb +1 -1
- data/app/views/sufia/homepage/_featured_fields.html.erb +1 -5
- data/app/views/sufia/homepage/_home_header.html.erb +1 -1
- data/app/views/transfers/new.html.erb +1 -1
- data/app/views/users/_activity.html.erb +1 -1
- data/app/views/users/_contributions.html.erb +5 -5
- data/app/views/users/_edit_primary.html.erb +2 -2
- data/app/views/users/_profile_actions.html.erb +1 -1
- data/app/views/users/_profile_tabs.html.erb +2 -2
- data/app/views/users/show.html.erb +2 -5
- data/config/locales/sufia.en.yml +1 -1
- data/config/routes.rb +7 -8
- data/{lib/generators/sufia/templates/migrations/acts_as_follower_migration.rb → db/migrate/20160328222155_acts_as_follower_migration.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_social_to_users.rb → db/migrate/20160328222156_add_social_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_ldap_attrs_to_user.rb → db/migrate/20160328222157_add_ldap_attrs_to_user.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_avatars_to_users.rb → db/migrate/20160328222158_add_avatars_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_local_authorities.rb → db/migrate/20160328222160_create_local_authorities.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_trophies.rb → db/migrate/20160328222161_create_trophies.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_linkedin_to_users.rb → db/migrate/20160328222162_add_linkedin_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_tinymce_assets.rb → db/migrate/20160328222163_create_tinymce_assets.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_content_blocks.rb → db/migrate/20160328222164_create_content_blocks.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_featured_works.rb → db/migrate/20160328222165_create_featured_works.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_external_key_to_content_blocks.rb → db/migrate/20160328222166_add_external_key_to_content_blocks.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_proxy_deposit_rights.rb → db/migrate/20160328222226_create_proxy_deposit_rights.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_proxy_deposit_requests.rb → db/migrate/20160328222227_create_proxy_deposit_requests.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_file_view_stats.rb → db/migrate/20160328222228_create_file_view_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_file_download_stats.rb → db/migrate/20160328222229_create_file_download_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_orcid_to_users.rb → db/migrate/20160328222230_add_orcid_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_user_stats.rb → db/migrate/20160328222231_create_user_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_work_view_stats.rb → db/migrate/20160328222232_create_work_view_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_works_to_user_stats.rb → db/migrate/20160328222233_add_works_to_user_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_trophy_generic_file_id_to_work_id.rb → db/migrate/20160328222236_change_trophy_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_proxy_deposit_generic_file_id_to_work_id.rb → db/migrate/20160328222237_change_proxy_deposit_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_audit_log_generic_file_id_to_file_set_id.rb → db/migrate/20160328222238_change_audit_log_generic_file_id_to_file_set_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_proxy_deposit_request_generic_file_id_to_work_id.rb → db/migrate/20160328222239_change_proxy_deposit_request_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_uploaded_files.rb → db/migrate/20160401142419_create_uploaded_files.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_featured_work_generic_file_id_to_work_id.rb → db/migrate/20160510000007_change_featured_work_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_arkivo_to_users.rb → db/migrate/20160516190435_add_arkivo_to_users.rb} +0 -0
- data/lib/generators/sufia/arkivo_api_generator.rb +1 -8
- data/lib/generators/sufia/config_generator.rb +3 -11
- data/lib/generators/sufia/install_generator.rb +12 -46
- data/lib/generators/sufia/templates/catalog_controller.rb +10 -10
- data/lib/generators/sufia/templates/config/sufia.rb +11 -14
- data/lib/generators/sufia/upgrade700_generator.rb +1 -16
- data/lib/sufia.rb +4 -8
- data/lib/sufia/configuration.rb +132 -0
- data/lib/sufia/engine.rb +6 -46
- data/lib/sufia/resource_sync.rb +11 -0
- data/lib/sufia/resource_sync/capability_list_writer.rb +31 -0
- data/lib/sufia/resource_sync/resource_list_writer.rb +77 -0
- data/lib/sufia/resource_sync/source_description_writer.rb +30 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/{create_with_files_actor_spec.rb → sufia/create_with_files_actor_spec.rb} +0 -0
- data/spec/controllers/{admin_stats_controller_spec.rb → admin/stats_controller_spec.rb} +0 -0
- data/spec/controllers/batch_edits_controller_spec.rb +5 -9
- data/spec/controllers/contact_form_controller_spec.rb +88 -0
- data/spec/controllers/{file_sets_controller_spec.rb → curation_concerns/file_sets_controller_spec.rb} +1 -2
- data/spec/controllers/{generic_works_controller_spec.rb → curation_concerns/generic_works_controller_spec.rb} +1 -1
- data/spec/controllers/depositors_controller_spec.rb +1 -1
- data/spec/controllers/featured_works_controller_spec.rb +1 -1
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/my/highlights_controller_spec.rb +15 -11
- data/spec/controllers/stats_controller_spec.rb +1 -1
- data/spec/controllers/{homepage_controller_spec.rb → sufia/homepage_controller_spec.rb} +1 -1
- data/spec/controllers/sufia/resource_sync_controller_spec.rb +52 -0
- data/spec/controllers/sufia/trophies_controller_spec.rb +27 -0
- data/spec/controllers/transfers_controller_spec.rb +7 -7
- data/spec/controllers/users_controller_spec.rb +22 -60
- data/spec/features/browse_catalog_spec.rb +1 -1
- data/spec/features/collection_spec.rb +6 -7
- data/spec/features/contact_form_spec.rb +2 -89
- data/spec/features/search_spec.rb +7 -7
- data/spec/features/users_spec.rb +1 -1
- data/spec/forms/curation_concerns/{work_form_spec.rb → generic_work_form_spec.rb} +0 -0
- data/spec/forms/sufia/{batch_edit_form_spec.rb → forms/batch_edit_form_spec.rb} +0 -0
- data/spec/forms/sufia/{batch_upload_form_spec.rb → forms/batch_upload_form_spec.rb} +0 -0
- data/spec/forms/sufia/{collection_form_spec.rb → forms/collection_form_spec.rb} +0 -0
- data/spec/helpers/blacklight_helper_spec.rb +91 -0
- data/spec/helpers/dashboard_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +7 -12
- data/spec/helpers/trophy_helper_spec.rb +1 -1
- data/spec/javascripts/jasmine_spec.rb +1 -1
- data/spec/lib/sufia/resource_sync/capability_list_writer_spec.rb +26 -0
- data/spec/lib/sufia/resource_sync/resource_list_writer_spec.rb +24 -0
- data/spec/lib/sufia/resource_sync/source_description_writer_spec.rb +21 -0
- data/spec/models/featured_work_spec.rb +1 -1
- data/spec/models/generic_work_spec.rb +7 -10
- data/spec/models/local_authority_spec.rb +3 -11
- data/spec/models/{ability_spec.rb → sufia/ability_spec.rb} +0 -0
- data/spec/models/sufia/download_spec.rb +13 -0
- data/spec/models/sufia/pageview_spec.rb +13 -0
- data/spec/models/sufia/uploaded_file_spec.rb +1 -1
- data/spec/models/{user_usage_stats_spec.rb → sufia/user_usage_stats_spec.rb} +0 -0
- data/spec/models/trophy_spec.rb +5 -7
- data/spec/models/user_spec.rb +12 -12
- data/spec/presenters/{file_usage_spec.rb → sufia/file_usage_spec.rb} +4 -4
- data/spec/presenters/{presenter_renderer_spec.rb → sufia/presenter_renderer_spec.rb} +0 -0
- data/spec/presenters/sufia/user_profile_presenter_spec.rb +23 -0
- data/spec/presenters/{work_usage_spec.rb → sufia/work_usage_spec.rb} +4 -4
- data/spec/requests/legacy_routing_spec.rb +1 -1
- data/spec/routing/ownership_transfers_route_spec.rb +2 -2
- data/spec/routing/route_spec.rb +19 -16
- data/spec/services/{collection_member_service_spec.rb → sufia/collection_member_service_spec.rb} +0 -0
- data/spec/services/{collection_size_service_spec.rb → sufia/collection_size_service_spec.rb} +0 -0
- data/spec/services/{file_set_csv_service_spec.rb → sufia/file_set_csv_service_spec.rb} +0 -0
- data/spec/services/{repository_audit_service_spec.rb → sufia/repository_audit_service_spec.rb} +0 -0
- data/spec/services/{statistics → sufia/statistics}/collections/over_time_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/depositors/summary_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/file_sets/by_format_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/system_stats_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/by_depositor_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/by_resource_type_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/count_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/over_time_spec.rb +0 -0
- data/spec/spec_helper.rb +12 -15
- data/spec/tasks/rake_spec.rb +0 -28
- data/spec/views/_toolbar.html.erb_spec.rb +1 -1
- data/spec/views/admin/stats/index.html.erb_spec.rb +2 -4
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +14 -19
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +9 -10
- data/spec/views/collections/_form.html.erb_spec.rb +2 -2
- data/spec/views/collections/_form_for_select_collection.html.erb_spec.rb +1 -2
- data/spec/views/collections/edit.html.erb_spec.rb +1 -1
- data/spec/views/collections/show.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +11 -33
- data/spec/views/curation_concerns/base/_form_progress.html.erb_spec.rb +3 -3
- data/spec/views/curation_concerns/base/_relationships.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/edit.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/file_sets/_versioning.html.erb_spec.rb +1 -3
- data/spec/views/curation_concerns/permissions/confirm.html.erb_spec.rb +1 -1
- data/spec/views/dashboard/index_spec.rb +2 -4
- data/spec/views/homepage/_announcement.html.erb_spec.rb +1 -2
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +9 -2
- data/spec/views/homepage/_home_header.html.erb_spec.rb +1 -1
- data/spec/views/my/_list_collections.html.erb_spec.rb +1 -1
- data/spec/views/my/_list_works.html.erb_spec.rb +1 -1
- data/spec/views/sufia/batch_uploads/_form.html.erb_spec.rb +4 -4
- data/spec/views/users/edit.html.erb_spec.rb +0 -3
- data/spec/views/users/show.html.erb_spec.rb +9 -7
- data/sufia.gemspec +1 -0
- metadata +124 -96
- data/app/controllers/directory_controller.rb +0 -30
- data/lib/generators/sufia/abstract_migration_generator.rb +0 -31
- data/lib/generators/sufia/cached_stats_generator.rb +0 -24
- data/lib/generators/sufia/cached_work_stats_generator.rb +0 -24
- data/lib/generators/sufia/citation_config_generator.rb +0 -22
- data/lib/generators/sufia/minimagick_config_generator.rb +0 -18
- data/lib/generators/sufia/orcid_field_generator.rb +0 -19
- data/lib/generators/sufia/proxies_generator.rb +0 -24
- data/lib/generators/sufia/usagestats_generator.rb +0 -18
- data/lib/generators/sufia/user_stats_generator.rb +0 -31
- data/spec/models/download_spec.rb +0 -17
- data/spec/models/pageview_spec.rb +0 -17
- data/tasks/migrate.rake +0 -20
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec.describe Sufia::TrophiesController do
|
2
|
+
describe "#toggle_trophy" do
|
3
|
+
let(:user) { create(:user) }
|
4
|
+
let(:work) { create(:work, user: user) }
|
5
|
+
let(:work_id) { work.id }
|
6
|
+
|
7
|
+
context "for a work we have edit access on" do
|
8
|
+
before do
|
9
|
+
sign_in user
|
10
|
+
end
|
11
|
+
it "creates a trophy for a work" do
|
12
|
+
post :toggle_trophy, id: work_id
|
13
|
+
expect(response).to be_success
|
14
|
+
json = JSON.parse(response.body)
|
15
|
+
expect(json['user_id']).to eq user.id
|
16
|
+
expect(json['work_id']).to eq work_id
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "for a work that we don't have edit access on" do
|
21
|
+
it "does not create a trophy" do
|
22
|
+
post :toggle_trophy, id: work_id
|
23
|
+
expect(response).not_to be_success
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -83,7 +83,7 @@ describe TransfersController, type: :controller do
|
|
83
83
|
expect {
|
84
84
|
post :create, id: work.id, proxy_deposit_request: { transfer_to: another_user.user_key }
|
85
85
|
}.to change(ProxyDepositRequest, :count).by(1)
|
86
|
-
expect(response).to redirect_to
|
86
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
87
87
|
expect(flash[:notice]).to eq('Transfer request created')
|
88
88
|
proxy_request = another_user.proxy_deposit_requests.first
|
89
89
|
expect(proxy_request.work_id).to eq(work.id)
|
@@ -91,7 +91,7 @@ describe TransfersController, type: :controller do
|
|
91
91
|
# AND A NOTIFICATION SHOULD HAVE BEEN CREATED
|
92
92
|
notification = another_user.reload.mailbox.inbox[0].messages[0]
|
93
93
|
expect(notification.subject).to eq("Ownership Change Request")
|
94
|
-
expect(notification.body).to eq("<a href=\"/users/#{user.user_key}\">#{user.name}</a> wants to transfer a work to you. Review all <a href=\"#{
|
94
|
+
expect(notification.body).to eq("<a href=\"/users/#{user.user_key}\">#{user.name}</a> wants to transfer a work to you. Review all <a href=\"#{routes.url_helpers.transfers_path}\">transfer requests</a>")
|
95
95
|
end
|
96
96
|
it "gives an error if the user is not found" do
|
97
97
|
expect {
|
@@ -113,21 +113,21 @@ describe TransfersController, type: :controller do
|
|
113
113
|
end
|
114
114
|
it "is successful when retaining access rights" do
|
115
115
|
put :accept, id: user.proxy_deposit_requests.first
|
116
|
-
expect(response).to redirect_to
|
116
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
117
117
|
expect(flash[:notice]).to eq("Transfer complete")
|
118
118
|
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
119
119
|
expect(incoming_work.reload.edit_users).to eq([another_user.user_key, user.user_key])
|
120
120
|
end
|
121
121
|
it "is successful when resetting access rights" do
|
122
122
|
put :accept, id: user.proxy_deposit_requests.first, reset: true
|
123
|
-
expect(response).to redirect_to
|
123
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
124
124
|
expect(flash[:notice]).to eq("Transfer complete")
|
125
125
|
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
126
126
|
expect(incoming_work.reload.edit_users).to eq([user.user_key])
|
127
127
|
end
|
128
128
|
it "handles sticky requests" do
|
129
129
|
put :accept, id: user.proxy_deposit_requests.first, sticky: true
|
130
|
-
expect(response).to redirect_to
|
130
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
131
131
|
expect(flash[:notice]).to eq("Transfer complete")
|
132
132
|
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
133
133
|
expect(user.can_receive_deposits_from).to include(another_user)
|
@@ -161,7 +161,7 @@ describe TransfersController, type: :controller do
|
|
161
161
|
end
|
162
162
|
it "is successful" do
|
163
163
|
put :reject, id: user.proxy_deposit_requests.first
|
164
|
-
expect(response).to redirect_to
|
164
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
165
165
|
expect(flash[:notice]).to eq("Transfer rejected")
|
166
166
|
expect(assigns[:proxy_deposit_request].status).to eq('rejected')
|
167
167
|
end
|
@@ -194,7 +194,7 @@ describe TransfersController, type: :controller do
|
|
194
194
|
end
|
195
195
|
it "is successful" do
|
196
196
|
delete :destroy, id: another_user.proxy_deposit_requests.first
|
197
|
-
expect(response).to redirect_to
|
197
|
+
expect(response).to redirect_to routes.url_helpers.transfers_path
|
198
198
|
expect(flash[:notice]).to eq("Transfer canceled")
|
199
199
|
end
|
200
200
|
end
|
@@ -10,30 +10,14 @@ describe UsersController, type: :controller do
|
|
10
10
|
it "show the user profile if user exists" do
|
11
11
|
get :show, id: user.user_key
|
12
12
|
expect(response).to be_success
|
13
|
-
expect(
|
14
|
-
expect(flash[:alert]).to be_nil
|
13
|
+
expect(assigns[:presenter]).to be_kind_of Sufia::UserProfilePresenter
|
15
14
|
end
|
15
|
+
|
16
16
|
it "redirects to root if user does not exist" do
|
17
17
|
get :show, id: 'johndoe666'
|
18
18
|
expect(response).to redirect_to(root_path)
|
19
19
|
expect(flash[:alert]).to include("User 'johndoe666' does not exist")
|
20
20
|
end
|
21
|
-
|
22
|
-
describe "when the user has trophies" do
|
23
|
-
let(:work1) { GenericWork.create(title: ["w1"]) { |w| w.apply_depositor_metadata(user) } }
|
24
|
-
let(:work2) { GenericWork.create(title: ["w2"]) { |w| w.apply_depositor_metadata(user) } }
|
25
|
-
let(:work3) { GenericWork.create(title: ["w3"]) { |w| w.apply_depositor_metadata(user) } }
|
26
|
-
let!(:trophy1) { user.trophies.create!(work_id: work1.id) }
|
27
|
-
let!(:trophy2) { user.trophies.create!(work_id: work2.id) }
|
28
|
-
let!(:trophy3) { user.trophies.create!(work_id: work3.id) }
|
29
|
-
let!(:badtrophy) { user.trophies.create!(work_id: 'not_a_generic_work') }
|
30
|
-
|
31
|
-
it "show the user profile if user exists" do
|
32
|
-
get :show, id: user.user_key
|
33
|
-
expect(response).to be_success
|
34
|
-
expect(assigns[:trophies]).to match_array([work1, work2, work3])
|
35
|
-
end
|
36
|
-
end
|
37
21
|
end
|
38
22
|
describe "#index" do
|
39
23
|
let!(:u1) { FactoryGirl.create(:user) }
|
@@ -60,7 +44,7 @@ describe UsersController, type: :controller do
|
|
60
44
|
it "finds the expected user via email" do
|
61
45
|
get :index, uq: u1.email
|
62
46
|
expect(assigns[:users]).to include(u1)
|
63
|
-
expect(assigns[:users]).
|
47
|
+
expect(assigns[:users]).not_to include(u2)
|
64
48
|
expect(response).to be_successful
|
65
49
|
end
|
66
50
|
|
@@ -72,7 +56,7 @@ describe UsersController, type: :controller do
|
|
72
56
|
allow_any_instance_of(User).to receive(:display_name).and_return("Dr. Curator", "Jr.Archivist")
|
73
57
|
get :index, uq: u1.display_name
|
74
58
|
expect(assigns[:users]).to include(u1)
|
75
|
-
expect(assigns[:users]).
|
59
|
+
expect(assigns[:users]).not_to include(u2)
|
76
60
|
expect(response).to be_successful
|
77
61
|
u1.display_name = nil
|
78
62
|
u1.save
|
@@ -85,7 +69,7 @@ describe UsersController, type: :controller do
|
|
85
69
|
allow(controller).to receive(:base_query).and_return(["email == \"#{u3.email}\""])
|
86
70
|
get :index
|
87
71
|
expect(assigns[:users]).to include(u3)
|
88
|
-
expect(assigns[:users]).
|
72
|
+
expect(assigns[:users]).not_to include(u1, u2)
|
89
73
|
u3.destroy
|
90
74
|
end
|
91
75
|
end
|
@@ -105,7 +89,7 @@ describe UsersController, type: :controller do
|
|
105
89
|
it "redirects to show profile" do
|
106
90
|
expect_any_instance_of(Ability).to receive(:can?).with(:edit, another_user).and_return(false)
|
107
91
|
get :edit, id: another_user.to_param
|
108
|
-
expect(response).to redirect_to(
|
92
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
109
93
|
expect(flash[:alert]).to include("Permission denied: cannot access this page.")
|
110
94
|
end
|
111
95
|
end
|
@@ -116,7 +100,7 @@ describe UsersController, type: :controller do
|
|
116
100
|
it "allows user to edit another user's profile" do
|
117
101
|
get :edit, id: another_user.to_param
|
118
102
|
expect(response).to be_success
|
119
|
-
expect(response).not_to redirect_to(
|
103
|
+
expect(response).not_to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
120
104
|
expect(flash[:alert]).to be_nil
|
121
105
|
end
|
122
106
|
end
|
@@ -143,7 +127,7 @@ describe UsersController, type: :controller do
|
|
143
127
|
let(:another_user) { FactoryGirl.create(:user) }
|
144
128
|
it "does not allow other users to update" do
|
145
129
|
post :update, id: another_user.user_key, user: { avatar: nil }
|
146
|
-
expect(response).to redirect_to(
|
130
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
147
131
|
expect(flash[:alert]).to include("Permission denied: cannot access this page.")
|
148
132
|
end
|
149
133
|
end
|
@@ -153,7 +137,7 @@ describe UsersController, type: :controller do
|
|
153
137
|
expect(UserEditProfileEventJob).to receive(:perform_later).with(user)
|
154
138
|
f = fixture_file_upload('/1.5mb-avatar.jpg', 'image/jpg')
|
155
139
|
post :update, id: user.user_key, user: { avatar: f }
|
156
|
-
expect(response).to redirect_to(
|
140
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
157
141
|
expect(flash[:notice]).to include("Your profile has been updated")
|
158
142
|
expect(User.find_by_user_key(user.user_key).avatar?).to be true
|
159
143
|
end
|
@@ -161,14 +145,14 @@ describe UsersController, type: :controller do
|
|
161
145
|
expect(UserEditProfileEventJob).to receive(:perform_later).never
|
162
146
|
f = fixture_file_upload('/image.jp2', 'image/jp2')
|
163
147
|
post :update, id: user.user_key, user: { avatar: f }
|
164
|
-
expect(response).to redirect_to(
|
148
|
+
expect(response).to redirect_to(routes.url_helpers.edit_profile_path(user.to_param))
|
165
149
|
expect(flash[:alert]).to include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
|
166
150
|
end
|
167
151
|
it "validates the size of an avatar" do
|
168
152
|
f = fixture_file_upload('/4-20.png', 'image/png')
|
169
153
|
expect(UserEditProfileEventJob).to receive(:perform_later).never
|
170
154
|
post :update, id: user.user_key, user: { avatar: f }
|
171
|
-
expect(response).to redirect_to(
|
155
|
+
expect(response).to redirect_to(routes.url_helpers.edit_profile_path(user.to_param))
|
172
156
|
expect(flash[:alert]).to include("Avatar file size must be less than 2MB")
|
173
157
|
end
|
174
158
|
|
@@ -181,7 +165,7 @@ describe UsersController, type: :controller do
|
|
181
165
|
it "deletes an avatar" do
|
182
166
|
expect(UserEditProfileEventJob).to receive(:perform_later).with(user)
|
183
167
|
post :update, id: user.user_key, user: { remove_avatar: 'true' }
|
184
|
-
expect(response).to redirect_to(
|
168
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
185
169
|
expect(flash[:notice]).to include("Your profile has been updated")
|
186
170
|
expect(User.find_by_user_key(user.user_key).avatar?).to be false
|
187
171
|
end
|
@@ -191,7 +175,7 @@ describe UsersController, type: :controller do
|
|
191
175
|
expect(UserEditProfileEventJob).to receive(:perform_later).with(user)
|
192
176
|
expect_any_instance_of(User).to receive(:populate_attributes).once
|
193
177
|
post :update, id: user.user_key, user: { update_directory: 'true' }
|
194
|
-
expect(response).to redirect_to(
|
178
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
195
179
|
expect(flash[:notice]).to include("Your profile has been updated")
|
196
180
|
end
|
197
181
|
|
@@ -202,7 +186,7 @@ describe UsersController, type: :controller do
|
|
202
186
|
expect(user.linkedin_handle).to be_blank
|
203
187
|
expect(user.orcid).to be_blank
|
204
188
|
post :update, id: user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle: "link", orcid: '0000-0000-1111-2222' }
|
205
|
-
expect(response).to redirect_to(
|
189
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
206
190
|
expect(flash[:notice]).to include("Your profile has been updated")
|
207
191
|
u = User.find_by_user_key(user.user_key)
|
208
192
|
expect(u.twitter_handle).to eq 'twit'
|
@@ -215,7 +199,7 @@ describe UsersController, type: :controller do
|
|
215
199
|
it 'displays a flash when invalid ORCID is entered' do
|
216
200
|
expect(user.orcid).to be_blank
|
217
201
|
post :update, id: user.user_key, user: { orcid: 'foobar' }
|
218
|
-
expect(response).to redirect_to(
|
202
|
+
expect(response).to redirect_to(routes.url_helpers.edit_profile_path(user.to_param))
|
219
203
|
expect(flash[:alert]).to include('Orcid must be a string of 19 characters, e.g., "0000-0000-0000-0000"')
|
220
204
|
end
|
221
205
|
|
@@ -228,7 +212,7 @@ describe UsersController, type: :controller do
|
|
228
212
|
expect {
|
229
213
|
post :update, id: user.user_key, 'remove_trophy_' + work.id => 'yes'
|
230
214
|
}.to change { user.trophies.count }.by(-1)
|
231
|
-
expect(response).to redirect_to(
|
215
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
232
216
|
expect(flash[:notice]).to include("Your profile has been updated")
|
233
217
|
end
|
234
218
|
end
|
@@ -240,20 +224,20 @@ describe UsersController, type: :controller do
|
|
240
224
|
expect(user.following?(another_user)).to be false
|
241
225
|
expect(UserFollowEventJob).to receive(:perform_later).with(user, another_user)
|
242
226
|
post :follow, id: another_user.user_key
|
243
|
-
expect(response).to redirect_to(
|
227
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
244
228
|
expect(flash[:notice]).to include("You are following #{another_user.user_key}")
|
245
229
|
end
|
246
230
|
it "redirects to profile if already following and not log an event" do
|
247
231
|
allow_any_instance_of(User).to receive(:following?).with(another_user).and_return(true)
|
248
232
|
expect(UserFollowEventJob).to receive(:perform_later).never
|
249
233
|
post :follow, id: another_user.user_key
|
250
|
-
expect(response).to redirect_to(
|
234
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
251
235
|
expect(flash[:notice]).to include("You are following #{another_user.user_key}")
|
252
236
|
end
|
253
237
|
it "redirects to profile if user attempts to self-follow and not log an event" do
|
254
238
|
expect(UserFollowEventJob).to receive(:perform_later).never
|
255
239
|
post :follow, id: user.user_key
|
256
|
-
expect(response).to redirect_to(
|
240
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
257
241
|
expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
|
258
242
|
end
|
259
243
|
end
|
@@ -264,43 +248,21 @@ describe UsersController, type: :controller do
|
|
264
248
|
allow_any_instance_of(User).to receive(:following?).with(another_user).and_return(true)
|
265
249
|
expect(UserUnfollowEventJob).to receive(:perform_later).with(user, another_user).once
|
266
250
|
post :unfollow, id: another_user.user_key
|
267
|
-
expect(response).to redirect_to(
|
251
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
268
252
|
expect(flash[:notice]).to include("You are no longer following #{another_user.user_key}")
|
269
253
|
end
|
270
254
|
it "redirects to profile if not following and not log an event" do
|
271
255
|
allow(user).to receive(:following?).with(another_user).and_return(false)
|
272
256
|
expect(UserUnfollowEventJob).to receive(:perform_later).never
|
273
257
|
post :unfollow, id: another_user.user_key
|
274
|
-
expect(response).to redirect_to(
|
258
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(another_user.to_param))
|
275
259
|
expect(flash[:notice]).to include("You are no longer following #{another_user.user_key}")
|
276
260
|
end
|
277
261
|
it "redirects to profile if user attempts to self-follow and not log an event" do
|
278
262
|
expect(UserUnfollowEventJob).to receive(:perform_later).never
|
279
263
|
post :unfollow, id: user.user_key
|
280
|
-
expect(response).to redirect_to(
|
264
|
+
expect(response).to redirect_to(routes.url_helpers.profile_path(user.to_param))
|
281
265
|
expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
|
282
266
|
end
|
283
267
|
end
|
284
|
-
|
285
|
-
describe "#toggle_trophy" do
|
286
|
-
let(:work) { GenericWork.create(title: ["w1"]) { |w| w.apply_depositor_metadata(user) } }
|
287
|
-
let(:work_id) { work.id }
|
288
|
-
let(:another_user) { FactoryGirl.create(:user) }
|
289
|
-
|
290
|
-
it "trophies a work" do
|
291
|
-
post :toggle_trophy, id: user.user_key, work_id: work_id
|
292
|
-
json = JSON.parse(response.body)
|
293
|
-
expect(json['user_id']).to eq user.id
|
294
|
-
expect(json['work_id']).to eq work_id
|
295
|
-
end
|
296
|
-
it "does not trophy a work for a different user" do
|
297
|
-
post :toggle_trophy, id: another_user.user_key, work_id: work_id
|
298
|
-
expect(response).to_not be_success
|
299
|
-
end
|
300
|
-
it "does not trophy a work with no edit privs" do
|
301
|
-
sign_in another_user
|
302
|
-
post :toggle_trophy, id: another_user.user_key, work_id: work_id
|
303
|
-
expect(response).to_not be_success
|
304
|
-
end
|
305
|
-
end
|
306
268
|
end
|
@@ -49,7 +49,7 @@ describe "Browse catalog:", type: :feature do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
expect(page).to have_content jills_work.title.first
|
52
|
-
expect(page).
|
52
|
+
expect(page).not_to have_content jacks_work.title.first
|
53
53
|
|
54
54
|
# TODO: After the _generic_work.html.erb view is finished
|
55
55
|
#
|
@@ -14,21 +14,20 @@ describe 'collection', type: :feature do
|
|
14
14
|
let(:title) { "Test Collection" }
|
15
15
|
let(:description) { "Description for collection we are testing." }
|
16
16
|
|
17
|
-
it "makes a new collection"
|
17
|
+
it "makes a new collection" do
|
18
18
|
visit '/dashboard'
|
19
19
|
first('#hydra-collection-add').click
|
20
20
|
expect(page).to have_content 'Create New Collection'
|
21
21
|
click_link('Additional fields')
|
22
|
-
# Creator is a multi-value field, so it should have button to add more fields
|
23
|
-
expect(page).to have_selector "div.collection_creator .input-append button.add"
|
24
22
|
|
25
|
-
|
26
|
-
expect(page).to have_selector "
|
23
|
+
expect(page).to have_selector "input.collection_creator.multi_value"
|
24
|
+
expect(page).to have_selector "input.collection_title.multi_value"
|
27
25
|
|
28
26
|
fill_in('Title', with: title)
|
29
27
|
fill_in('Abstract or Summary', with: description)
|
30
28
|
fill_in('Location', with: 'Over there')
|
31
29
|
fill_in('Related URL', with: 'http://example.com/')
|
30
|
+
|
32
31
|
click_button("Create Collection")
|
33
32
|
expect(page).to have_content 'Items in this Collection'
|
34
33
|
expect(page).to have_content title
|
@@ -100,7 +99,7 @@ describe 'collection', type: :feature do
|
|
100
99
|
# Should have search results / contents listing
|
101
100
|
expect(page).to have_content(work1.title.first)
|
102
101
|
expect(page).to have_content(work2.title.first)
|
103
|
-
expect(page).
|
102
|
+
expect(page).not_to have_css(".pager")
|
104
103
|
|
105
104
|
click_link "Gallery"
|
106
105
|
expect(page).to have_content(work1.title.first)
|
@@ -127,7 +126,7 @@ describe 'collection', type: :feature do
|
|
127
126
|
# Should have search results / contents listing
|
128
127
|
expect(page).to have_content("Search Results")
|
129
128
|
expect(page).to have_content(work1.title.first)
|
130
|
-
expect(page).
|
129
|
+
expect(page).not_to have_content(work2.title.first)
|
131
130
|
end
|
132
131
|
end
|
133
132
|
|
@@ -1,26 +1,7 @@
|
|
1
1
|
describe "Sending an email via the contact form", type: :feature do
|
2
|
-
before
|
3
|
-
sign_in :user_with_fixtures
|
4
|
-
end
|
2
|
+
before { sign_in(:user) }
|
5
3
|
|
6
4
|
it "sends mail" do
|
7
|
-
allow_any_instance_of(ContactForm).to receive(:deliver).and_return(true)
|
8
|
-
visit '/'
|
9
|
-
click_link "Contact"
|
10
|
-
expect(page).to have_content "Contact Form"
|
11
|
-
fill_in "contact_form_name", with: "Test McPherson"
|
12
|
-
fill_in "contact_form_email", with: "archivist1@example.com"
|
13
|
-
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
14
|
-
fill_in "contact_form_subject", with: "My Subject is Cool"
|
15
|
-
select "Depositing content", from: "contact_form_category"
|
16
|
-
click_button "Send"
|
17
|
-
expect(page).to have_content "Thank you"
|
18
|
-
expect(page).not_to have_content "I am contacting you regarding ScholarSphere."
|
19
|
-
# this step allows the delivery to go back to normal
|
20
|
-
allow_any_instance_of(ContactForm).to receive(:deliver).and_call_original
|
21
|
-
end
|
22
|
-
|
23
|
-
it "gives an error when I don't provide a contact type" do
|
24
5
|
visit '/'
|
25
6
|
click_link "Contact"
|
26
7
|
expect(page).to have_content "Contact Form"
|
@@ -28,76 +9,8 @@ describe "Sending an email via the contact form", type: :feature do
|
|
28
9
|
fill_in "contact_form_email", with: "archivist1@example.com"
|
29
10
|
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
30
11
|
fill_in "contact_form_subject", with: "My Subject is Cool"
|
31
|
-
click_button "Send"
|
32
|
-
expect(page).to have_content "Sorry, this message was not sent successfully"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "gives an error when I don't provide a valid email" do
|
36
|
-
visit '/'
|
37
|
-
click_link "Contact"
|
38
|
-
expect(page).to have_content "Contact Form"
|
39
|
-
fill_in "contact_form_name", with: "Test McPherson"
|
40
|
-
fill_in "contact_form_email", with: "archivist1"
|
41
|
-
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
42
|
-
fill_in "contact_form_subject", with: "My Subject is Cool"
|
43
|
-
select "Depositing content", from: "contact_form_category"
|
44
|
-
click_button "Send"
|
45
|
-
expect(page).to have_content "Sorry, this message was not sent successfully"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "gives an error when I don't provide a name" do
|
49
|
-
visit '/'
|
50
|
-
click_link "Contact"
|
51
|
-
expect(page).to have_content "Contact Form"
|
52
|
-
fill_in "contact_form_email", with: "archivist1@example.com"
|
53
|
-
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
54
|
-
fill_in "contact_form_subject", with: "My Subject is Cool"
|
55
|
-
select "Depositing content", from: "contact_form_category"
|
56
|
-
click_button "Send"
|
57
|
-
expect(page).to have_content "Sorry, this message was not delivered"
|
58
|
-
end
|
59
|
-
|
60
|
-
context "when I don't provide a subject", :js do
|
61
|
-
it "gives an error" do
|
62
|
-
# TODO: this should be a controller test, because that any_instance will be in a different thread
|
63
|
-
visit '/'
|
64
|
-
click_link "Contact"
|
65
|
-
expect(page).to have_content "Contact Form"
|
66
|
-
fill_in "contact_form_name", with: "Test McPherson"
|
67
|
-
fill_in "contact_form_email", with: "archivist1@example.com"
|
68
|
-
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
69
|
-
select "Depositing content", from: "contact_form_category"
|
70
|
-
expect_any_instance_of(ContactForm).not_to receive(:deliver)
|
71
|
-
click_button "Send"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when I don't provide a message", :js do
|
76
|
-
it "gives an error" do
|
77
|
-
# TODO: this should be a controller test, because that any_instance will be in a different thread
|
78
|
-
visit '/'
|
79
|
-
click_link "Contact"
|
80
|
-
expect(page).to have_content "Contact Form"
|
81
|
-
fill_in "contact_form_name", with: "Test McPherson"
|
82
|
-
fill_in "contact_form_email", with: "archivist1@example.com"
|
83
|
-
fill_in "contact_form_subject", with: "My Subject is Cool"
|
84
|
-
select "Depositing content", from: "contact_form_category"
|
85
|
-
expect_any_instance_of(ContactForm).not_to receive(:deliver)
|
86
|
-
click_button "Send"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "gives an error when I provide an invalid captcha" do
|
91
|
-
visit '/'
|
92
|
-
click_link "Contact"
|
93
|
-
expect(page).to have_content "Contact Form"
|
94
|
-
fill_in 'contact_form_contact_method', with: 'My name is', visible: false
|
95
|
-
fill_in "contact_form_name", with: "Test McPherson"
|
96
|
-
fill_in "contact_form_email", with: "archivist1@example.com"
|
97
|
-
fill_in "contact_form_subject", with: "My Subject is Cool"
|
98
|
-
fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
|
99
12
|
select "Depositing content", from: "contact_form_category"
|
100
13
|
click_button "Send"
|
101
|
-
expect(page).to have_content "
|
14
|
+
expect(page).to have_content "Thank you for your message!"
|
102
15
|
end
|
103
16
|
end
|