sufia 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +247 -215
- data/README.md +7 -3
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia.js +5 -2
- data/app/assets/javascripts/sufia/proxy_rights.js +68 -0
- data/app/assets/javascripts/sufia/transfers.js +3 -0
- data/app/assets/javascripts/sufia/user_search.js +31 -0
- data/app/assets/stylesheets/jquery-ui.css +17 -17
- data/app/assets/stylesheets/sufia.css.scss +3 -2
- data/app/assets/stylesheets/sufia/_proxy-rights.scss +10 -0
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +22 -23
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +41 -0
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +1 -0
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +76 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +9 -11
- data/app/controllers/depositors_controller.rb +3 -0
- data/app/controllers/transfers_controller.rb +3 -0
- data/app/helpers/sufia/dashboard_helper_behavior.rb +15 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +24 -2
- data/app/jobs/content_depositor_change_event_job.rb +50 -0
- data/app/views/dashboard/_index_partials/_contents.html.erb +18 -0
- data/app/views/dashboard/_index_partials/_proxy_rights.html.erb +23 -0
- data/app/views/dashboard/_index_partials/_transfers.html.erb +14 -0
- data/app/views/generic_files/proxy.html.erb +5 -0
- data/app/views/generic_files/upload/_form.html.erb +7 -2
- data/app/views/my/_action_menu.html.erb +3 -1
- data/app/views/records/edit_fields/_default.html.erb +1 -1
- data/app/views/transfers/_received.html.erb +58 -0
- data/app/views/transfers/_sent.html.erb +38 -0
- data/app/views/transfers/index.html.erb +7 -0
- data/app/views/transfers/new.html.erb +23 -0
- data/app/views/users/_proxies.html.erb +8 -0
- data/app/views/users/_user_util_links_extra.html.erb +1 -0
- data/app/views/users/edit.html.erb +6 -1
- data/config/locales/sufia.en.yml +9 -4
- data/config/routes.rb +14 -3
- data/lib/sufia.rb +7 -5
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/authorities_controller_spec.rb +6 -6
- data/spec/controllers/batch_controller_spec.rb +29 -29
- data/spec/controllers/batch_edits_controller_spec.rb +7 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -9
- data/spec/controllers/collections_controller_spec.rb +28 -28
- data/spec/controllers/content_blocks_controller_spec.rb +3 -3
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/depositors_controller_spec.rb +50 -0
- data/spec/controllers/downloads_controller_spec.rb +22 -22
- data/spec/controllers/featured_work_lists_controller_spec.rb +1 -1
- data/spec/controllers/featured_works_controller_spec.rb +1 -1
- data/spec/controllers/generic_files_controller_spec.rb +98 -90
- data/spec/controllers/homepage_controller_spec.rb +1 -1
- data/spec/controllers/mailbox_controller_spec.rb +10 -10
- data/spec/controllers/my/collections_controller_spec.rb +1 -1
- data/spec/controllers/my/files_controller_spec.rb +1 -1
- data/spec/controllers/my/highlights_controller_spec.rb +1 -1
- data/spec/controllers/my/shares_controller_spec.rb +1 -1
- data/spec/controllers/my_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +1 -1
- data/spec/controllers/single_use_links_controller_spec.rb +46 -50
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +16 -16
- data/spec/controllers/static_controller_spec.rb +9 -9
- data/spec/controllers/tinymce_assets_controller_spec.rb +1 -1
- data/spec/controllers/transfers_controller_spec.rb +212 -0
- data/spec/controllers/users_controller_spec.rb +1 -1
- data/spec/factories/generic_files.rb +4 -4
- data/spec/factories/proxy_deposit_requests.rb +6 -0
- data/spec/features/browse_dashboard_files_spec.rb +25 -36
- data/spec/features/browse_files_spec.rb +18 -13
- data/spec/features/catalog_search_spec.rb +3 -6
- data/spec/features/cloud_upload_spec.rb +5 -7
- data/spec/features/collection_spec.rb +28 -35
- data/spec/features/contact_form_spec.rb +24 -24
- data/spec/features/display_dashboard_spec.rb +11 -11
- data/spec/features/ingest_upload_files_spec.rb +10 -10
- data/spec/features/notifications_spec.rb +11 -11
- data/spec/features/ownership_transfer_spec.rb +111 -0
- data/spec/features/proxy_spec.rb +52 -0
- data/spec/features/search_spec.rb +1 -1
- data/spec/features/single_use_links_spec.rb +28 -18
- data/spec/features/users_spec.rb +3 -3
- data/spec/helpers/batch_edits_helper_spec.rb +1 -1
- data/spec/helpers/content_block_helper_spec.rb +1 -1
- data/spec/helpers/dashboard_helper_spec.rb +1 -1
- data/spec/helpers/generic_file_helper_spec.rb +1 -1
- data/spec/helpers/records_helper_spec.rb +1 -1
- data/spec/helpers/sufia_helper_spec.rb +8 -8
- data/spec/helpers/trophy_helper_spec.rb +1 -1
- data/spec/jobs/audit_job_spec.rb +5 -5
- data/spec/jobs/batch_update_job_spec.rb +14 -14
- data/spec/jobs/content_depositor_change_event_job_spec.rb +22 -0
- data/spec/jobs/event_jobs_spec.rb +104 -104
- data/spec/jobs/import_url_job_spec.rb +2 -2
- data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
- data/spec/lib/sufia/breadcrumbs_spec.rb +3 -3
- data/spec/lib/sufia/id_service_spec.rb +1 -1
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +4 -4
- data/spec/models/ability_spec.rb +59 -15
- data/spec/models/batch_spec.rb +16 -16
- data/spec/models/characterization_spec.rb +1 -1
- data/spec/models/checksum_audit_log_spec.rb +34 -26
- data/spec/models/collection_spec.rb +1 -1
- data/spec/models/download_spec.rb +1 -1
- data/spec/models/featured_work_list_spec.rb +1 -1
- data/spec/models/featured_work_spec.rb +15 -4
- data/spec/models/file_content_datastream_spec.rb +14 -14
- data/spec/models/file_usage_spec.rb +1 -1
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file/reload_on_save_spec.rb +4 -4
- data/spec/models/generic_file/visibility_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +6 -5
- data/spec/models/generic_file_rdf_datastream_spec.rb +1 -1
- data/spec/models/generic_file_spec.rb +254 -220
- data/spec/models/geo_names_resource_spec.rb +2 -2
- data/spec/models/local_authority_spec.rb +60 -59
- data/spec/models/pageview_spec.rb +1 -1
- data/spec/models/properties_datastream_spec.rb +29 -10
- data/spec/models/proxy_deposit_request_spec.rb +107 -0
- data/spec/models/single_use_link_spec.rb +13 -13
- data/spec/models/solr_document_spec.rb +1 -1
- data/spec/models/trophy_spec.rb +6 -6
- data/spec/models/user_spec.rb +38 -22
- data/spec/routing/featured_works_route_spec.rb +1 -1
- data/spec/routing/ownership_transfers_route_spec.rb +45 -0
- data/spec/routing/route_spec.rb +42 -42
- data/spec/services/noid_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -5
- data/spec/support/cleaner.rb +12 -0
- data/spec/support/features.rb +5 -0
- data/spec/support/features/session_helpers.rb +3 -17
- data/spec/support/locations.rb +36 -0
- data/spec/support/poltergeist.rb +11 -0
- data/spec/support/proxies.rb +14 -0
- data/spec/support/selectors.rb +122 -0
- data/spec/views/batch/edit.html.erb_spec.rb +1 -1
- data/spec/views/batch_edits/check_all_spec.rb +4 -4
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/collections/_form.html.erb_spec.rb +3 -1
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
- data/spec/views/dashboard/index_spec.rb +3 -6
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
- data/spec/views/my/facet.html.erb_spec.rb +2 -2
- data/spec/views/users/_follower_modal.html.erb_spec.rb +1 -1
- data/spec/views/users/_following_modal.html.erb_spec.rb +1 -1
- data/spec/views/users/_notify_number.html.erb_spec.rb +1 -1
- data/spec/views/users/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/users/index.html.erb_spec.rb +2 -2
- data/spec/views/users/show.html.erb_spec.rb +2 -2
- data/sufia-models/app/models/concerns/sufia/ability.rb +22 -0
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +1 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +22 -0
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +3 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +9 -0
- data/sufia-models/app/models/proxy_deposit_request.rb +85 -0
- data/sufia-models/app/models/proxy_deposit_rights.rb +4 -0
- data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +9 -1
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +53 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +16 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +11 -0
- data/sufia-models/lib/sufia/models/engine.rb +1 -1
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia.gemspec +2 -1
- data/tasks/sufia-dev.rake +5 -0
- metadata +82 -6
- data/tasks/sufia-db.rake +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe MailboxController do
|
|
3
|
+
describe MailboxController, :type => :controller do
|
|
4
4
|
before(:each) do
|
|
5
5
|
@user = FactoryGirl.find_or_create(:jill)
|
|
6
6
|
@another_user = FactoryGirl.find_or_create(:archivist)
|
|
@@ -8,7 +8,7 @@ describe MailboxController do
|
|
|
8
8
|
@subject = "Test Subject"
|
|
9
9
|
@rec1 = @another_user.send_message(@user, @message, @subject)
|
|
10
10
|
@rec2 = @user.send_message(@another_user, @message, @subject)
|
|
11
|
-
MailboxController.
|
|
11
|
+
allow_any_instance_of(MailboxController).to receive(:authenticate_user!).and_return(true)
|
|
12
12
|
sign_in @user
|
|
13
13
|
end
|
|
14
14
|
after(:each) do
|
|
@@ -18,10 +18,10 @@ describe MailboxController do
|
|
|
18
18
|
describe "#index" do
|
|
19
19
|
it "should show message" do
|
|
20
20
|
get :index
|
|
21
|
-
response.
|
|
22
|
-
assigns[:messages].first.last_message.body.
|
|
23
|
-
assigns[:messages].first.last_message.subject.
|
|
24
|
-
@user.mailbox.inbox(unread: true).count.
|
|
21
|
+
expect(response).to be_success
|
|
22
|
+
expect(assigns[:messages].first.last_message.body).to eq('Test Message')
|
|
23
|
+
expect(assigns[:messages].first.last_message.subject).to eq('Test Subject')
|
|
24
|
+
expect(@user.mailbox.inbox(unread: true).count).to eq(0)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
describe "#delete" do
|
|
@@ -29,7 +29,7 @@ describe MailboxController do
|
|
|
29
29
|
rec = @another_user.send_message(@user, 'message 2', 'subject 2')
|
|
30
30
|
expect {
|
|
31
31
|
delete :destroy, id: rec.conversation.id
|
|
32
|
-
response.
|
|
32
|
+
expect(response).to redirect_to(@routes.url_helpers.notifications_path)
|
|
33
33
|
}.to change {@user.mailbox.inbox.count}.by(-1)
|
|
34
34
|
end
|
|
35
35
|
it "should not delete message" do
|
|
@@ -37,7 +37,7 @@ describe MailboxController do
|
|
|
37
37
|
rec = @another_user.send_message(@curator, 'message 3', 'subject 3')
|
|
38
38
|
expect {
|
|
39
39
|
delete :destroy, id: rec.conversation.id
|
|
40
|
-
response.
|
|
40
|
+
expect(response).to redirect_to(@routes.url_helpers.notifications_path)
|
|
41
41
|
}.to_not change { @curator.mailbox.inbox.count}
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -45,9 +45,9 @@ describe MailboxController do
|
|
|
45
45
|
it "should delete message" do
|
|
46
46
|
rec1 = @another_user.send_message(@user, 'message 2', 'subject 2')
|
|
47
47
|
rec2 = @another_user.send_message(@user, 'message 3', 'subject 3')
|
|
48
|
-
@user.mailbox.inbox.count.
|
|
48
|
+
expect(@user.mailbox.inbox.count).to eq(3)
|
|
49
49
|
get :delete_all
|
|
50
|
-
@user.mailbox.inbox.count.
|
|
50
|
+
expect(@user.mailbox.inbox.count).to eq(0)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -1,93 +1,89 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe SingleUseLinksController do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@file2.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
12
|
-
@file2.apply_depositor_metadata('mjg36')
|
|
13
|
-
@file2.save
|
|
3
|
+
describe SingleUseLinksController, :type => :controller do
|
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
|
5
|
+
let(:file) do
|
|
6
|
+
GenericFile.new.tap do |f|
|
|
7
|
+
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
8
|
+
f.apply_depositor_metadata(user)
|
|
9
|
+
f.save
|
|
10
|
+
end
|
|
14
11
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
let(:file2) do
|
|
13
|
+
GenericFile.new.tap do |f|
|
|
14
|
+
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
15
|
+
f.apply_depositor_metadata('mjg36')
|
|
16
|
+
f.save
|
|
17
|
+
end
|
|
19
18
|
end
|
|
20
19
|
before do
|
|
21
|
-
controller.
|
|
22
|
-
controller.
|
|
20
|
+
allow(controller).to receive(:has_access?).and_return(true)
|
|
21
|
+
allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
|
22
|
+
end
|
|
23
|
+
after(:all) do
|
|
24
|
+
ActiveFedora::Base.destroy_all
|
|
25
|
+
SingleUseLink.destroy_all
|
|
23
26
|
end
|
|
24
27
|
describe "logged in user with edit permission" do
|
|
25
28
|
before do
|
|
26
|
-
sign_in
|
|
29
|
+
sign_in user
|
|
27
30
|
@now = DateTime.now
|
|
28
|
-
DateTime.
|
|
29
|
-
@hash = "some-dummy-sha2-hash"
|
|
30
|
-
Digest::SHA2.
|
|
31
|
+
allow(DateTime).to receive(:now).and_return(@now)
|
|
32
|
+
@hash = "some-dummy-sha2-hash"
|
|
33
|
+
allow(Digest::SHA2).to receive(:new).and_return(@hash)
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
assigns[:link].should == @routes.url_helpers.download_single_use_link_path(@hash)
|
|
38
|
-
end
|
|
39
|
-
|
|
36
|
+
it "gets the download link" do
|
|
37
|
+
get 'new_download', id: file.pid
|
|
38
|
+
expect(response).to be_success
|
|
39
|
+
expect(assigns[:link]).to eq @routes.url_helpers.download_single_use_link_path(@hash)
|
|
40
40
|
end
|
|
41
|
-
|
|
42
|
-
describe "GET 'show'" do
|
|
43
|
-
it "and_return http success" do
|
|
44
|
-
get 'new_show', id:@file.pid
|
|
45
|
-
response.should be_success
|
|
46
|
-
assigns[:link].should == @routes.url_helpers.show_single_use_link_path(@hash)
|
|
47
|
-
end
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
it "gets the show link" do
|
|
43
|
+
get 'new_show', id: file.pid
|
|
44
|
+
expect(response).to be_success
|
|
45
|
+
expect(assigns[:link]).to eq @routes.url_helpers.show_single_use_link_path(@hash)
|
|
46
|
+
end
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
describe "logged in user without edit permission" do
|
|
53
50
|
before do
|
|
54
51
|
@other_user = FactoryGirl.find_or_create(:archivist)
|
|
55
|
-
@file.read_users << @other_user
|
|
56
|
-
@file.save
|
|
57
52
|
sign_in @other_user
|
|
53
|
+
file.read_users << @other_user
|
|
54
|
+
file.save
|
|
58
55
|
end
|
|
59
56
|
|
|
60
57
|
describe "GET 'download'" do
|
|
61
58
|
it "and_return http success" do
|
|
62
|
-
get 'new_download', id
|
|
63
|
-
response.
|
|
59
|
+
get 'new_download', id: file.pid
|
|
60
|
+
expect(response).not_to be_success
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
end
|
|
67
64
|
|
|
68
65
|
describe "GET 'show'" do
|
|
69
66
|
it "and_return http success" do
|
|
70
|
-
get 'new_show', id
|
|
71
|
-
response.
|
|
67
|
+
get 'new_show', id: file.pid
|
|
68
|
+
expect(response).not_to be_success
|
|
72
69
|
end
|
|
73
70
|
|
|
74
71
|
end
|
|
75
72
|
end
|
|
76
73
|
|
|
77
|
-
describe "
|
|
74
|
+
describe "unknown user" do
|
|
78
75
|
describe "GET 'download'" do
|
|
79
76
|
it "and_return http failure" do
|
|
80
|
-
get 'new_download', id
|
|
81
|
-
response.
|
|
77
|
+
get 'new_download', id: file.pid
|
|
78
|
+
expect(response).not_to be_success
|
|
82
79
|
end
|
|
83
80
|
end
|
|
84
|
-
|
|
81
|
+
|
|
85
82
|
describe "GET 'show'" do
|
|
86
83
|
it "and_return http failure" do
|
|
87
|
-
get 'new_show', id
|
|
88
|
-
response.
|
|
84
|
+
get 'new_show', id: file.pid
|
|
85
|
+
expect(response).not_to be_success
|
|
89
86
|
end
|
|
90
|
-
end
|
|
87
|
+
end
|
|
91
88
|
end
|
|
92
|
-
|
|
93
89
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe SingleUseLinksViewerController do
|
|
3
|
+
describe SingleUseLinksViewerController, :type => :controller do
|
|
4
4
|
before(:all) do
|
|
5
5
|
@user = FactoryGirl.find_or_create(:jill)
|
|
6
6
|
@file = GenericFile.new
|
|
@@ -18,8 +18,8 @@ describe SingleUseLinksViewerController do
|
|
|
18
18
|
SingleUseLink.delete_all
|
|
19
19
|
end
|
|
20
20
|
before do
|
|
21
|
-
controller.
|
|
22
|
-
controller.
|
|
21
|
+
allow(controller).to receive(:has_access?).and_return(true)
|
|
22
|
+
allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe "retrieval links" do
|
|
@@ -44,24 +44,24 @@ describe SingleUseLinksViewerController do
|
|
|
44
44
|
end
|
|
45
45
|
describe "GET 'download'" do
|
|
46
46
|
it "and_return http success" do
|
|
47
|
-
controller.
|
|
47
|
+
allow(controller).to receive(:render)
|
|
48
48
|
expected_content = ActiveFedora::Base.find(@file.pid, cast: true).content.content
|
|
49
|
-
controller.
|
|
49
|
+
expect(controller).to receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
|
|
50
50
|
get :download, id:download_link_hash
|
|
51
|
-
response.body.
|
|
52
|
-
response.
|
|
51
|
+
expect(response.body).to eq(expected_content)
|
|
52
|
+
expect(response).to be_success
|
|
53
53
|
end
|
|
54
54
|
it "and_return 404 on second attempt" do
|
|
55
55
|
get :download, id:download_link_hash
|
|
56
|
-
response.
|
|
56
|
+
expect(response).to be_success
|
|
57
57
|
get :download, id:download_link_hash
|
|
58
|
-
response.
|
|
58
|
+
expect(response).to render_template('error/single_use_error')
|
|
59
59
|
end
|
|
60
60
|
it "and_return 404 on attempt to get download with show" do
|
|
61
61
|
get :download, id:download_link_hash
|
|
62
|
-
response.
|
|
62
|
+
expect(response).to be_success
|
|
63
63
|
get :show, id:download_link_hash
|
|
64
|
-
response.
|
|
64
|
+
expect(response).to render_template('error/single_use_error')
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -69,18 +69,18 @@ describe SingleUseLinksViewerController do
|
|
|
69
69
|
it "and_return http success" do
|
|
70
70
|
|
|
71
71
|
get 'show', id:show_link_hash
|
|
72
|
-
response.
|
|
73
|
-
assigns[:asset].pid.
|
|
72
|
+
expect(response).to be_success
|
|
73
|
+
expect(assigns[:asset].pid).to eq(@file.pid)
|
|
74
74
|
end
|
|
75
75
|
it "and_return 404 on second attempt" do
|
|
76
76
|
get :show, id:show_link_hash
|
|
77
|
-
response.
|
|
77
|
+
expect(response).to be_success
|
|
78
78
|
get :show, id:show_link_hash
|
|
79
|
-
response.
|
|
79
|
+
expect(response).to render_template('error/single_use_error')
|
|
80
80
|
end
|
|
81
81
|
it "and_return 404 on attempt to get show path with download hash" do
|
|
82
82
|
get :show, id:download_link_hash
|
|
83
|
-
response.
|
|
83
|
+
expect(response).to render_template('error/single_use_error')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe StaticController do
|
|
3
|
+
describe StaticController, :type => :controller do
|
|
4
4
|
routes { Sufia::Engine.routes }
|
|
5
5
|
describe "#mendeley" do
|
|
6
6
|
it "renders page" do
|
|
7
7
|
get "mendeley"
|
|
8
|
-
response.
|
|
9
|
-
response.
|
|
8
|
+
expect(response).to be_success
|
|
9
|
+
expect(response).to render_template "layouts/homepage"
|
|
10
10
|
end
|
|
11
11
|
it "renders no layout with javascript" do
|
|
12
12
|
xhr :get, :mendeley
|
|
13
|
-
response.
|
|
14
|
-
response.
|
|
13
|
+
expect(response).to be_success
|
|
14
|
+
expect(response).not_to render_template "layouts/homepage"
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe "#zotero" do
|
|
19
19
|
it "renders page" do
|
|
20
20
|
get "zotero"
|
|
21
|
-
response.
|
|
22
|
-
response.
|
|
21
|
+
expect(response).to be_success
|
|
22
|
+
expect(response).to render_template "layouts/homepage"
|
|
23
23
|
end
|
|
24
24
|
it "renders no layout with javascript" do
|
|
25
25
|
xhr :get, :zotero
|
|
26
|
-
response.
|
|
27
|
-
response.
|
|
26
|
+
expect(response).to be_success
|
|
27
|
+
expect(response).not_to render_template "layouts/homepage"
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe TransfersController, :type => :controller do
|
|
4
|
+
describe "with a signed in user" do
|
|
5
|
+
let(:another_user) { FactoryGirl.find_or_create(:jill) }
|
|
6
|
+
let(:user) { FactoryGirl.find_or_create(:archivist) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
sign_in user
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "#index" do
|
|
13
|
+
let!(:incoming_file) do
|
|
14
|
+
GenericFile.new.tap do |f|
|
|
15
|
+
f.apply_depositor_metadata(another_user.user_key)
|
|
16
|
+
f.save!
|
|
17
|
+
f.request_transfer_to(user)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
let!(:outgoing_file) do
|
|
21
|
+
GenericFile.new.tap do |f|
|
|
22
|
+
f.apply_depositor_metadata(user.user_key)
|
|
23
|
+
f.save!
|
|
24
|
+
f.request_transfer_to(another_user)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "is successful" do
|
|
29
|
+
get :index
|
|
30
|
+
expect(response).to be_success
|
|
31
|
+
expect(assigns[:incoming].first).to be_kind_of ProxyDepositRequest
|
|
32
|
+
expect(assigns[:incoming].first.pid).to eq(incoming_file.pid)
|
|
33
|
+
expect(assigns[:outgoing].first).to be_kind_of ProxyDepositRequest
|
|
34
|
+
expect(assigns[:outgoing].first.pid).to eq(outgoing_file.pid)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "When the incoming request is for a deleted file" do
|
|
38
|
+
before do
|
|
39
|
+
incoming_file.destroy
|
|
40
|
+
end
|
|
41
|
+
it "should not show that file" do
|
|
42
|
+
get :index
|
|
43
|
+
expect(response).to be_success
|
|
44
|
+
expect(assigns[:incoming]).to be_empty
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "#new" do
|
|
50
|
+
let(:file) do
|
|
51
|
+
GenericFile.new.tap do |f|
|
|
52
|
+
f.apply_depositor_metadata(user.user_key)
|
|
53
|
+
f.save!
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
context 'when user is the depositor' do
|
|
57
|
+
it "should be successful" do
|
|
58
|
+
sign_in user
|
|
59
|
+
get :new, id: file
|
|
60
|
+
expect(response).to be_success
|
|
61
|
+
expect(assigns[:generic_file]).to eq(file)
|
|
62
|
+
expect(assigns[:proxy_deposit_request]).to be_kind_of ProxyDepositRequest
|
|
63
|
+
expect(assigns[:proxy_deposit_request].pid).to eq(file.pid)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "#create" do
|
|
69
|
+
let(:file) do
|
|
70
|
+
GenericFile.new.tap do |f|
|
|
71
|
+
f.apply_depositor_metadata(user.user_key)
|
|
72
|
+
f.save!
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
it "should be successful" do
|
|
76
|
+
allow_any_instance_of(User).to receive(:display_name).and_return("Jill Z. User")
|
|
77
|
+
expect {
|
|
78
|
+
post :create, id: file.id, proxy_deposit_request: {transfer_to: another_user.user_key}
|
|
79
|
+
}.to change(ProxyDepositRequest, :count).by(1)
|
|
80
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
81
|
+
expect(flash[:notice]).to eq('Transfer request created')
|
|
82
|
+
proxy_request = another_user.proxy_deposit_requests.first
|
|
83
|
+
expect(proxy_request.pid).to eq(file.pid)
|
|
84
|
+
expect(proxy_request.sending_user).to eq(user)
|
|
85
|
+
# AND A NOTIFICATION SHOULD HAVE BEEN CREATED
|
|
86
|
+
notification = another_user.reload.mailbox.inbox[0].messages[0]
|
|
87
|
+
expect(notification.subject).to eq("Ownership Change Request")
|
|
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
|
+
end
|
|
90
|
+
it "should give an error if the user is not found" do
|
|
91
|
+
expect {
|
|
92
|
+
post :create, id: file.id, proxy_deposit_request: {transfer_to: 'foo' }
|
|
93
|
+
}.not_to change(ProxyDepositRequest, :count)
|
|
94
|
+
expect(assigns[:proxy_deposit_request].errors[:transfer_to]).to eq(['must be an existing user'])
|
|
95
|
+
expect(response).to redirect_to(root_path)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe "#accept" do
|
|
100
|
+
context "when I am the receiver" do
|
|
101
|
+
let!(:incoming_file) do
|
|
102
|
+
GenericFile.new.tap do |f|
|
|
103
|
+
f.apply_depositor_metadata(another_user.user_key)
|
|
104
|
+
f.save!
|
|
105
|
+
f.request_transfer_to(user)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
it "should be successful when retaining access rights" do
|
|
109
|
+
put :accept, id: user.proxy_deposit_requests.first
|
|
110
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
111
|
+
expect(flash[:notice]).to eq("Transfer complete")
|
|
112
|
+
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
|
113
|
+
expect(incoming_file.reload.edit_users).to eq([another_user.user_key, user.user_key])
|
|
114
|
+
end
|
|
115
|
+
it "should be successful when resetting access rights" do
|
|
116
|
+
put :accept, id: user.proxy_deposit_requests.first, reset: true
|
|
117
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
118
|
+
expect(flash[:notice]).to eq("Transfer complete")
|
|
119
|
+
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
|
120
|
+
expect(incoming_file.reload.edit_users).to eq([user.user_key])
|
|
121
|
+
end
|
|
122
|
+
it "should handle sticky requests " do
|
|
123
|
+
put :accept, id: user.proxy_deposit_requests.first, sticky: true
|
|
124
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
125
|
+
expect(flash[:notice]).to eq("Transfer complete")
|
|
126
|
+
expect(assigns[:proxy_deposit_request].status).to eq('accepted')
|
|
127
|
+
expect(user.can_receive_deposits_from).to include(another_user)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
context "accepting one that isn't mine" do
|
|
132
|
+
let!(:incoming_file) do
|
|
133
|
+
GenericFile.new.tap do |f|
|
|
134
|
+
f.apply_depositor_metadata(user.user_key)
|
|
135
|
+
f.save!
|
|
136
|
+
f.request_transfer_to(another_user)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
it "should not allow me" do
|
|
140
|
+
put :accept, id: another_user.proxy_deposit_requests.first
|
|
141
|
+
expect(response).to redirect_to root_path
|
|
142
|
+
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe "#reject" do
|
|
148
|
+
context "when I am the receiver" do
|
|
149
|
+
let!(:incoming_file) do
|
|
150
|
+
GenericFile.new.tap do |f|
|
|
151
|
+
f.apply_depositor_metadata(another_user.user_key)
|
|
152
|
+
f.save!
|
|
153
|
+
f.request_transfer_to(user)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
it "should be successful" do
|
|
157
|
+
put :reject, id: user.proxy_deposit_requests.first
|
|
158
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
159
|
+
expect(flash[:notice]).to eq("Transfer rejected")
|
|
160
|
+
expect(assigns[:proxy_deposit_request].status).to eq('rejected')
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
context "accepting one that isn't mine" do
|
|
165
|
+
let!(:incoming_file) do
|
|
166
|
+
GenericFile.new.tap do |f|
|
|
167
|
+
f.apply_depositor_metadata(user.user_key)
|
|
168
|
+
f.save!
|
|
169
|
+
f.request_transfer_to(another_user)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
it "should not allow me" do
|
|
173
|
+
put :reject, id: another_user.proxy_deposit_requests.first
|
|
174
|
+
expect(response).to redirect_to root_path
|
|
175
|
+
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe "#destroy" do
|
|
181
|
+
context "when I am the sender" do
|
|
182
|
+
let!(:incoming_file) do
|
|
183
|
+
GenericFile.new.tap do |f|
|
|
184
|
+
f.apply_depositor_metadata(user.user_key)
|
|
185
|
+
f.save!
|
|
186
|
+
f.request_transfer_to(another_user)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
it "should be successful" do
|
|
190
|
+
delete :destroy, id: another_user.proxy_deposit_requests.first
|
|
191
|
+
expect(response).to redirect_to @routes.url_helpers.transfers_path
|
|
192
|
+
expect(flash[:notice]).to eq("Transfer canceled")
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
context "accepting one that isn't mine" do
|
|
197
|
+
let!(:incoming_file) do
|
|
198
|
+
GenericFile.new.tap do |f|
|
|
199
|
+
f.apply_depositor_metadata(another_user.user_key)
|
|
200
|
+
f.save!
|
|
201
|
+
f.request_transfer_to(user)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
it "should not allow me" do
|
|
205
|
+
delete :destroy, id: user.proxy_deposit_requests.first
|
|
206
|
+
expect(response).to redirect_to root_path
|
|
207
|
+
expect(flash[:alert]).to eq("You are not authorized to access this page.")
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|