sufia 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,102 +1,103 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@tsv = [fixture_path + '/cities15000.tsv']
|
8
|
-
@nt = [fixture_path + '/genreForms.nt']
|
9
|
-
@rdfxml = [fixture_path + '/lexvo.rdf']
|
10
|
-
LocalAuthority.count.should == 0
|
11
|
-
LocalAuthorityEntry.count.should == 0
|
3
|
+
describe LocalAuthority, :type => :model do
|
4
|
+
|
5
|
+
def harvest_nt
|
6
|
+
LocalAuthority.harvest_rdf("genres", [fixture_path + '/genreForms.nt'])
|
12
7
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
|
9
|
+
def harvest_tsv
|
10
|
+
LocalAuthority.harvest_tsv("geo", [fixture_path + '/cities15000.tsv'], prefix: 'http://sws.geonames.org/')
|
11
|
+
end
|
12
|
+
|
13
|
+
before :all do
|
14
|
+
class MyTestRdfDatastream; end
|
15
|
+
end
|
16
|
+
after :all do
|
17
|
+
Object.send(:remove_const, :MyTestRdfDatastream)
|
18
|
+
end
|
19
|
+
after do
|
20
|
+
DomainTerm.destroy_all
|
21
|
+
LocalAuthority.destroy_all
|
22
|
+
LocalAuthorityEntry.destroy_all
|
21
23
|
end
|
24
|
+
|
22
25
|
it "should harvest an ntriples RDF vocab" do
|
23
|
-
|
24
|
-
LocalAuthority.count.
|
25
|
-
LocalAuthorityEntry.count.
|
26
|
+
harvest_nt
|
27
|
+
expect(LocalAuthority.count).to eq(1)
|
28
|
+
expect(LocalAuthorityEntry.count).to eq(6)
|
26
29
|
end
|
27
30
|
it "should harvest an RDF/XML vocab (w/ an alt predicate)" do
|
28
|
-
LocalAuthority.harvest_rdf("langs",
|
31
|
+
LocalAuthority.harvest_rdf("langs", [fixture_path + '/lexvo.rdf'],
|
29
32
|
format: 'rdfxml',
|
30
33
|
predicate: RDF::URI("http://www.w3.org/2008/05/skos#prefLabel"))
|
31
|
-
LocalAuthority.count.
|
32
|
-
LocalAuthorityEntry.count.
|
34
|
+
expect(LocalAuthority.count).to eq(1)
|
35
|
+
expect(LocalAuthorityEntry.count).to eq(35)
|
33
36
|
end
|
34
37
|
it "should harvest TSV vocabs" do
|
35
|
-
|
36
|
-
LocalAuthority.count.
|
38
|
+
harvest_tsv
|
39
|
+
expect(LocalAuthority.count).to eq(1)
|
37
40
|
auth = LocalAuthority.where(name: "geo").first
|
38
41
|
expect(LocalAuthorityEntry.where(local_authority_id: auth.id).first.uri).to start_with('http://sws.geonames.org/')
|
39
|
-
LocalAuthorityEntry.count.
|
42
|
+
expect(LocalAuthorityEntry.count).to eq(149)
|
40
43
|
end
|
44
|
+
|
41
45
|
describe "when vocabs are harvested" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
|
47
|
+
let(:num_auths) { LocalAuthority.count }
|
48
|
+
let(:num_entries) { LocalAuthorityEntry.count }
|
49
|
+
|
50
|
+
before do
|
51
|
+
harvest_nt
|
52
|
+
harvest_tsv
|
49
53
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
LocalAuthorityEntry.all.each(&:delete)
|
54
|
-
Object.send(:remove_const, :MyTestRdfDatastream)
|
54
|
+
|
55
|
+
it "should not have any initial domain terms" do
|
56
|
+
expect(DomainTerm.count).to eq(0)
|
55
57
|
end
|
58
|
+
|
56
59
|
it "should not harvest an RDF vocab twice" do
|
57
|
-
|
58
|
-
LocalAuthority.count.
|
59
|
-
LocalAuthorityEntry.count.
|
60
|
+
harvest_nt
|
61
|
+
expect(LocalAuthority.count).to eq(num_auths)
|
62
|
+
expect(LocalAuthorityEntry.count).to eq(num_entries)
|
60
63
|
end
|
61
64
|
it "should not harvest a TSV vocab twice" do
|
62
|
-
|
63
|
-
LocalAuthority.count.
|
64
|
-
LocalAuthorityEntry.count.
|
65
|
+
harvest_tsv
|
66
|
+
expect(LocalAuthority.count).to eq(num_auths)
|
67
|
+
expect(LocalAuthorityEntry.count).to eq(num_entries)
|
65
68
|
end
|
66
69
|
it "should register a vocab" do
|
67
70
|
LocalAuthority.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
|
68
|
-
DomainTerm.count.
|
71
|
+
expect(DomainTerm.count).to eq(1)
|
69
72
|
end
|
73
|
+
|
70
74
|
describe "when vocabs are registered" do
|
71
|
-
|
72
|
-
|
73
|
-
LocalAuthority.harvest_tsv("geo", @tsv, prefix: 'http://sws.geonames.org/')
|
74
|
-
class TestRdfDatastream; end
|
75
|
+
|
76
|
+
before do
|
75
77
|
LocalAuthority.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
|
76
78
|
LocalAuthority.register_vocabulary(MyTestRdfDatastream, "genre", "genres")
|
77
|
-
DomainTerm.count.should == 2
|
78
79
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
LocalAuthorityEntry.all.each(&:delete)
|
80
|
+
|
81
|
+
it "should have some doamin terms" do
|
82
|
+
expect(DomainTerm.count).to eq(2)
|
83
83
|
end
|
84
|
+
|
84
85
|
it "should return nil for empty queries" do
|
85
|
-
LocalAuthority.entries_by_term("my_test", "geographic", "").
|
86
|
+
expect(LocalAuthority.entries_by_term("my_test", "geographic", "")).to be_nil
|
86
87
|
end
|
87
88
|
it "should return an empty array for unregistered models" do
|
88
|
-
LocalAuthority.entries_by_term("my_foobar", "geographic", "E").
|
89
|
+
expect(LocalAuthority.entries_by_term("my_foobar", "geographic", "E")).to eq([])
|
89
90
|
end
|
90
91
|
it "should return an empty array for unregistered terms" do
|
91
|
-
LocalAuthority.entries_by_term("my_test", "foobar", "E").
|
92
|
+
expect(LocalAuthority.entries_by_term("my_test", "foobar", "E")).to eq([])
|
92
93
|
end
|
93
94
|
it "should return entries by term" do
|
94
95
|
term = DomainTerm.where(model: "my_tests", term: "genre").first
|
95
96
|
authorities = term.local_authorities.collect(&:id).uniq
|
96
97
|
hits = LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("label like ?", "A%").select("label, uri").limit(25)
|
97
|
-
LocalAuthority.entries_by_term("my_tests", "genre", "A").count.
|
98
|
+
expect(LocalAuthority.entries_by_term("my_tests", "genre", "A").count).to eq(6)
|
98
99
|
end
|
100
|
+
|
99
101
|
end
|
100
102
|
end
|
101
103
|
end
|
102
|
-
|
@@ -1,22 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe PropertiesDatastream do
|
3
|
+
describe PropertiesDatastream, :type => :model do
|
4
|
+
describe "import_url" do
|
5
|
+
before do
|
6
|
+
subject.import_url = 'http://example.com/somefile.txt'
|
7
|
+
end
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
it "serializes" do
|
10
|
+
expect(subject.import_url).to eq ['http://example.com/somefile.txt']
|
11
|
+
expect(subject.ng_xml.to_xml).to be_equivalent_to "<?xml version=\"1.0\"?><fields><importUrl>http://example.com/somefile.txt</importUrl></fields>"
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
|
-
describe "
|
15
|
+
describe "proxy_depositor" do
|
12
16
|
before do
|
13
|
-
|
17
|
+
subject.proxy_depositor = 'kim@example.com'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "serializes proxy_depositor" do
|
21
|
+
expect(subject.proxy_depositor).to eq ['kim@example.com']
|
22
|
+
expect(subject.ng_xml.to_xml).to be_equivalent_to "<?xml version=\"1.0\"?><fields><proxyDepositor>kim@example.com</proxyDepositor></fields>"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "to_solr" do
|
27
|
+
let(:doc) {
|
28
|
+
PropertiesDatastream.new(nil, 'properties').tap do |ds|
|
14
29
|
ds.import_url = 'http://example.com/somefile.txt'
|
30
|
+
ds.proxy_depositor = 'kim@example.com'
|
15
31
|
end
|
32
|
+
}
|
33
|
+
subject { doc.to_solr}
|
34
|
+
it "solrizes import_url" do
|
35
|
+
expect(subject['import_url_ssim']).to eq ['http://example.com/somefile.txt']
|
16
36
|
end
|
17
|
-
|
18
|
-
|
19
|
-
subject['import_url_ssim'].should == ['http://example.com/somefile.txt']
|
37
|
+
it "solrizes proxy_depositor" do
|
38
|
+
expect(subject['proxy_depositor_ssim']).to eq ['kim@example.com']
|
20
39
|
end
|
21
40
|
end
|
22
41
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ProxyDepositRequest, type: :model do
|
4
|
+
let(:sender) { FactoryGirl.find_or_create(:jill) }
|
5
|
+
let(:receiver) { FactoryGirl.find_or_create(:archivist) }
|
6
|
+
let(:receiver2) { FactoryGirl.find_or_create(:curator) }
|
7
|
+
let(:file) do
|
8
|
+
GenericFile.new.tap do |f|
|
9
|
+
f.title = ["Test file"]
|
10
|
+
f.apply_depositor_metadata(sender.user_key)
|
11
|
+
f.save!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
subject do
|
16
|
+
ProxyDepositRequest.new(pid: file.pid, sending_user: sender,
|
17
|
+
receiving_user: receiver, sender_comment: "please take this")
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
subject.destroy if subject.persisted?
|
22
|
+
end
|
23
|
+
|
24
|
+
its(:status) { is_expected.to eq 'pending' }
|
25
|
+
it { is_expected.to be_pending }
|
26
|
+
its(:fulfillment_date) { is_expected.to be_nil }
|
27
|
+
its(:sender_comment) { is_expected.to eq 'please take this' }
|
28
|
+
|
29
|
+
it "has a title for the file" do
|
30
|
+
expect(subject.title).to eq('Test file')
|
31
|
+
end
|
32
|
+
|
33
|
+
context "After approval" do
|
34
|
+
before do
|
35
|
+
subject.transfer!
|
36
|
+
end
|
37
|
+
|
38
|
+
its(:status) { is_expected.to eq 'accepted' }
|
39
|
+
its(:fulfillment_date) { is_expected.not_to be_nil }
|
40
|
+
its(:deleted_file?) { is_expected.to be false }
|
41
|
+
|
42
|
+
describe "and the file is deleted" do
|
43
|
+
before do
|
44
|
+
file.destroy
|
45
|
+
end
|
46
|
+
|
47
|
+
its(:title) { is_expected.to eq 'file not found' }
|
48
|
+
its(:deleted_file?) { is_expected.to be true }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "After rejection" do
|
53
|
+
before do
|
54
|
+
subject.reject!('a comment')
|
55
|
+
end
|
56
|
+
|
57
|
+
its(:status) { is_expected.to eq 'rejected' }
|
58
|
+
its(:fulfillment_date) { is_expected.not_to be_nil }
|
59
|
+
its(:receiver_comment) { is_expected.to eq 'a comment' }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "After cancel" do
|
63
|
+
before do
|
64
|
+
subject.cancel!
|
65
|
+
end
|
66
|
+
|
67
|
+
its(:status) { is_expected.to eq 'canceled' }
|
68
|
+
its(:fulfillment_date) { is_expected.not_to be_nil }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'transfer' do
|
72
|
+
context 'when the transfer_to user is not found' do
|
73
|
+
it 'raises an error' do
|
74
|
+
subject.transfer_to = 'dave'
|
75
|
+
expect(subject).not_to be_valid
|
76
|
+
expect(subject.errors[:transfer_to]).to eq(['must be an existing user'])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when the transfer_to user is found' do
|
81
|
+
it 'creates a transfer_request' do
|
82
|
+
subject.transfer_to = receiver.user_key
|
83
|
+
subject.save!
|
84
|
+
proxy_request = receiver.proxy_deposit_requests.first
|
85
|
+
expect(proxy_request.pid).to eq(file.pid)
|
86
|
+
expect(proxy_request.sending_user).to eq(sender)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'when the receiving user is the sending user' do
|
91
|
+
it 'raises an error' do
|
92
|
+
subject.transfer_to = sender.user_key
|
93
|
+
expect(subject).not_to be_valid
|
94
|
+
expect(subject.errors[:sending_user]).to eq(['must specify another user to receive the file'])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when the file is already being transferred' do
|
99
|
+
it 'raises an error' do
|
100
|
+
subject.save!
|
101
|
+
subject2 = ProxyDepositRequest.new(pid: file.pid, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this')
|
102
|
+
expect(subject2).not_to be_valid
|
103
|
+
expect(subject2.errors[:open_transfer]).to eq(['must close open transfer on the file before creating a new one'])
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SingleUseLink do
|
3
|
+
describe SingleUseLink, :type => :model do
|
4
4
|
before(:all) do
|
5
5
|
@file = GenericFile.new
|
6
6
|
@file.apply_depositor_metadata('mjg36')
|
@@ -16,22 +16,22 @@ describe SingleUseLink do
|
|
16
16
|
describe "create" do
|
17
17
|
before do
|
18
18
|
@now = DateTime.now
|
19
|
-
DateTime.
|
19
|
+
allow(DateTime).to receive(:now).and_return(@now)
|
20
20
|
@hash = "sha2hash#{@now.to_f.to_s}"
|
21
|
-
Digest::SHA2.
|
21
|
+
expect(Digest::SHA2).to receive(:new).and_return(@hash)
|
22
22
|
end
|
23
23
|
it "should create show link" do
|
24
24
|
su = SingleUseLink.create itemId: file.pid, path: Sufia::Engine.routes.url_helpers.generic_file_path(file.pid)
|
25
|
-
su.downloadKey.
|
26
|
-
su.itemId.
|
27
|
-
su.path.
|
25
|
+
expect(su.downloadKey).to eq(@hash)
|
26
|
+
expect(su.itemId).to eq(file.pid)
|
27
|
+
expect(su.path).to eq(Sufia::Engine.routes.url_helpers.generic_file_path(file.pid))
|
28
28
|
su.delete
|
29
29
|
end
|
30
30
|
it "should create show download link" do
|
31
31
|
su = SingleUseLink.create itemId: file.pid, path: Sufia::Engine.routes.url_helpers.download_path(file.pid)
|
32
|
-
su.downloadKey.
|
33
|
-
su.itemId.
|
34
|
-
su.path.
|
32
|
+
expect(su.downloadKey).to eq(@hash)
|
33
|
+
expect(su.itemId).to eq(file.pid)
|
34
|
+
expect(su.path).to eq(Sufia::Engine.routes.url_helpers.download_path(file.pid))
|
35
35
|
su.delete
|
36
36
|
end
|
37
37
|
end
|
@@ -42,15 +42,15 @@ describe SingleUseLink do
|
|
42
42
|
end
|
43
43
|
it "should retrieve link" do
|
44
44
|
link = SingleUseLink.where(downloadKey: 'sha2hashb').first
|
45
|
-
link.itemId.
|
45
|
+
expect(link.itemId).to eq(file.pid)
|
46
46
|
end
|
47
47
|
it "should retrieve link with find_by" do
|
48
48
|
link = SingleUseLink.find_by_downloadKey('sha2hashb')
|
49
|
-
link.itemId.
|
49
|
+
expect(link.itemId).to eq(file.pid)
|
50
50
|
end
|
51
51
|
it "should expire link" do
|
52
52
|
link = SingleUseLink.where(downloadKey: 'sha2hashb').first
|
53
|
-
link.expired
|
53
|
+
expect(link.expired?).to eq(false)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
describe "expired" do
|
@@ -62,7 +62,7 @@ describe SingleUseLink do
|
|
62
62
|
|
63
63
|
it "should expire link" do
|
64
64
|
link = SingleUseLink.where(downloadKey: 'sha2hashb').first
|
65
|
-
link.expired
|
65
|
+
expect(link.expired?).to eq(true)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/spec/models/trophy_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Trophy do
|
3
|
+
describe Trophy, :type => :model do
|
4
4
|
before(:all) do
|
5
5
|
@trophy = Trophy.create(user_id:99,generic_file_id:"99")
|
6
6
|
end
|
@@ -9,17 +9,17 @@ describe Trophy do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should have a user" do
|
12
|
-
@trophy.
|
13
|
-
@trophy.user_id.
|
12
|
+
expect(@trophy).to respond_to(:user_id)
|
13
|
+
expect(@trophy.user_id).to eq(99)
|
14
14
|
end
|
15
15
|
it "should have a file" do
|
16
|
-
@trophy.
|
17
|
-
@trophy.generic_file_id.
|
16
|
+
expect(@trophy).to respond_to(:generic_file_id)
|
17
|
+
expect(@trophy.generic_file_id).to eq("99")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should not allow six trophies" do
|
21
21
|
(1..6).each {|n| Trophy.create(user_id:120,generic_file_id:n.to_s)}
|
22
|
-
Trophy.where(user_id:120).count.
|
22
|
+
expect(Trophy.where(user_id:120).count).to eq(5)
|
23
23
|
Trophy.where(user_id:120).map(&:delete)
|
24
24
|
end
|
25
25
|
end
|