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.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +247 -215
  3. data/README.md +7 -3
  4. data/SUFIA_VERSION +1 -1
  5. data/app/assets/javascripts/sufia.js +5 -2
  6. data/app/assets/javascripts/sufia/proxy_rights.js +68 -0
  7. data/app/assets/javascripts/sufia/transfers.js +3 -0
  8. data/app/assets/javascripts/sufia/user_search.js +31 -0
  9. data/app/assets/stylesheets/jquery-ui.css +17 -17
  10. data/app/assets/stylesheets/sufia.css.scss +3 -2
  11. data/app/assets/stylesheets/sufia/_proxy-rights.scss +10 -0
  12. data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +22 -23
  13. data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +41 -0
  14. data/app/controllers/concerns/sufia/files_controller_behavior.rb +1 -0
  15. data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +76 -0
  16. data/app/controllers/concerns/sufia/users_controller_behavior.rb +9 -11
  17. data/app/controllers/depositors_controller.rb +3 -0
  18. data/app/controllers/transfers_controller.rb +3 -0
  19. data/app/helpers/sufia/dashboard_helper_behavior.rb +15 -0
  20. data/app/helpers/sufia/sufia_helper_behavior.rb +24 -2
  21. data/app/jobs/content_depositor_change_event_job.rb +50 -0
  22. data/app/views/dashboard/_index_partials/_contents.html.erb +18 -0
  23. data/app/views/dashboard/_index_partials/_proxy_rights.html.erb +23 -0
  24. data/app/views/dashboard/_index_partials/_transfers.html.erb +14 -0
  25. data/app/views/generic_files/proxy.html.erb +5 -0
  26. data/app/views/generic_files/upload/_form.html.erb +7 -2
  27. data/app/views/my/_action_menu.html.erb +3 -1
  28. data/app/views/records/edit_fields/_default.html.erb +1 -1
  29. data/app/views/transfers/_received.html.erb +58 -0
  30. data/app/views/transfers/_sent.html.erb +38 -0
  31. data/app/views/transfers/index.html.erb +7 -0
  32. data/app/views/transfers/new.html.erb +23 -0
  33. data/app/views/users/_proxies.html.erb +8 -0
  34. data/app/views/users/_user_util_links_extra.html.erb +1 -0
  35. data/app/views/users/edit.html.erb +6 -1
  36. data/config/locales/sufia.en.yml +9 -4
  37. data/config/routes.rb +14 -3
  38. data/lib/sufia.rb +7 -5
  39. data/lib/sufia/version.rb +1 -1
  40. data/spec/controllers/authorities_controller_spec.rb +6 -6
  41. data/spec/controllers/batch_controller_spec.rb +29 -29
  42. data/spec/controllers/batch_edits_controller_spec.rb +7 -7
  43. data/spec/controllers/catalog_controller_spec.rb +9 -9
  44. data/spec/controllers/collections_controller_spec.rb +28 -28
  45. data/spec/controllers/content_blocks_controller_spec.rb +3 -3
  46. data/spec/controllers/dashboard_controller_spec.rb +1 -1
  47. data/spec/controllers/depositors_controller_spec.rb +50 -0
  48. data/spec/controllers/downloads_controller_spec.rb +22 -22
  49. data/spec/controllers/featured_work_lists_controller_spec.rb +1 -1
  50. data/spec/controllers/featured_works_controller_spec.rb +1 -1
  51. data/spec/controllers/generic_files_controller_spec.rb +98 -90
  52. data/spec/controllers/homepage_controller_spec.rb +1 -1
  53. data/spec/controllers/mailbox_controller_spec.rb +10 -10
  54. data/spec/controllers/my/collections_controller_spec.rb +1 -1
  55. data/spec/controllers/my/files_controller_spec.rb +1 -1
  56. data/spec/controllers/my/highlights_controller_spec.rb +1 -1
  57. data/spec/controllers/my/shares_controller_spec.rb +1 -1
  58. data/spec/controllers/my_controller_spec.rb +1 -1
  59. data/spec/controllers/pages_controller_spec.rb +1 -1
  60. data/spec/controllers/single_use_links_controller_spec.rb +46 -50
  61. data/spec/controllers/single_use_links_viewer_controller_spec.rb +16 -16
  62. data/spec/controllers/static_controller_spec.rb +9 -9
  63. data/spec/controllers/tinymce_assets_controller_spec.rb +1 -1
  64. data/spec/controllers/transfers_controller_spec.rb +212 -0
  65. data/spec/controllers/users_controller_spec.rb +1 -1
  66. data/spec/factories/generic_files.rb +4 -4
  67. data/spec/factories/proxy_deposit_requests.rb +6 -0
  68. data/spec/features/browse_dashboard_files_spec.rb +25 -36
  69. data/spec/features/browse_files_spec.rb +18 -13
  70. data/spec/features/catalog_search_spec.rb +3 -6
  71. data/spec/features/cloud_upload_spec.rb +5 -7
  72. data/spec/features/collection_spec.rb +28 -35
  73. data/spec/features/contact_form_spec.rb +24 -24
  74. data/spec/features/display_dashboard_spec.rb +11 -11
  75. data/spec/features/ingest_upload_files_spec.rb +10 -10
  76. data/spec/features/notifications_spec.rb +11 -11
  77. data/spec/features/ownership_transfer_spec.rb +111 -0
  78. data/spec/features/proxy_spec.rb +52 -0
  79. data/spec/features/search_spec.rb +1 -1
  80. data/spec/features/single_use_links_spec.rb +28 -18
  81. data/spec/features/users_spec.rb +3 -3
  82. data/spec/helpers/batch_edits_helper_spec.rb +1 -1
  83. data/spec/helpers/content_block_helper_spec.rb +1 -1
  84. data/spec/helpers/dashboard_helper_spec.rb +1 -1
  85. data/spec/helpers/generic_file_helper_spec.rb +1 -1
  86. data/spec/helpers/records_helper_spec.rb +1 -1
  87. data/spec/helpers/sufia_helper_spec.rb +8 -8
  88. data/spec/helpers/trophy_helper_spec.rb +1 -1
  89. data/spec/jobs/audit_job_spec.rb +5 -5
  90. data/spec/jobs/batch_update_job_spec.rb +14 -14
  91. data/spec/jobs/content_depositor_change_event_job_spec.rb +22 -0
  92. data/spec/jobs/event_jobs_spec.rb +104 -104
  93. data/spec/jobs/import_url_job_spec.rb +2 -2
  94. data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
  95. data/spec/lib/sufia/breadcrumbs_spec.rb +3 -3
  96. data/spec/lib/sufia/id_service_spec.rb +1 -1
  97. data/spec/lib/sufia/upload_complete_behavior_spec.rb +4 -4
  98. data/spec/models/ability_spec.rb +59 -15
  99. data/spec/models/batch_spec.rb +16 -16
  100. data/spec/models/characterization_spec.rb +1 -1
  101. data/spec/models/checksum_audit_log_spec.rb +34 -26
  102. data/spec/models/collection_spec.rb +1 -1
  103. data/spec/models/download_spec.rb +1 -1
  104. data/spec/models/featured_work_list_spec.rb +1 -1
  105. data/spec/models/featured_work_spec.rb +15 -4
  106. data/spec/models/file_content_datastream_spec.rb +14 -14
  107. data/spec/models/file_usage_spec.rb +1 -1
  108. data/spec/models/fits_datastream_spec.rb +1 -1
  109. data/spec/models/generic_file/reload_on_save_spec.rb +4 -4
  110. data/spec/models/generic_file/visibility_spec.rb +1 -1
  111. data/spec/models/generic_file/web_form_spec.rb +6 -5
  112. data/spec/models/generic_file_rdf_datastream_spec.rb +1 -1
  113. data/spec/models/generic_file_spec.rb +254 -220
  114. data/spec/models/geo_names_resource_spec.rb +2 -2
  115. data/spec/models/local_authority_spec.rb +60 -59
  116. data/spec/models/pageview_spec.rb +1 -1
  117. data/spec/models/properties_datastream_spec.rb +29 -10
  118. data/spec/models/proxy_deposit_request_spec.rb +107 -0
  119. data/spec/models/single_use_link_spec.rb +13 -13
  120. data/spec/models/solr_document_spec.rb +1 -1
  121. data/spec/models/trophy_spec.rb +6 -6
  122. data/spec/models/user_spec.rb +38 -22
  123. data/spec/routing/featured_works_route_spec.rb +1 -1
  124. data/spec/routing/ownership_transfers_route_spec.rb +45 -0
  125. data/spec/routing/route_spec.rb +42 -42
  126. data/spec/services/noid_spec.rb +2 -2
  127. data/spec/spec_helper.rb +10 -5
  128. data/spec/support/cleaner.rb +12 -0
  129. data/spec/support/features.rb +5 -0
  130. data/spec/support/features/session_helpers.rb +3 -17
  131. data/spec/support/locations.rb +36 -0
  132. data/spec/support/poltergeist.rb +11 -0
  133. data/spec/support/proxies.rb +14 -0
  134. data/spec/support/selectors.rb +122 -0
  135. data/spec/views/batch/edit.html.erb_spec.rb +1 -1
  136. data/spec/views/batch_edits/check_all_spec.rb +4 -4
  137. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  138. data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +1 -1
  139. data/spec/views/collections/_form.html.erb_spec.rb +3 -1
  140. data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
  141. data/spec/views/dashboard/index_spec.rb +3 -6
  142. data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
  143. data/spec/views/generic_file/show.html.erb_spec.rb +1 -1
  144. data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
  145. data/spec/views/my/facet.html.erb_spec.rb +2 -2
  146. data/spec/views/users/_follower_modal.html.erb_spec.rb +1 -1
  147. data/spec/views/users/_following_modal.html.erb_spec.rb +1 -1
  148. data/spec/views/users/_notify_number.html.erb_spec.rb +1 -1
  149. data/spec/views/users/_user_util_links.html.erb_spec.rb +1 -1
  150. data/spec/views/users/index.html.erb_spec.rb +2 -2
  151. data/spec/views/users/show.html.erb_spec.rb +2 -2
  152. data/sufia-models/app/models/concerns/sufia/ability.rb +22 -0
  153. data/sufia-models/app/models/concerns/sufia/generic_file.rb +1 -0
  154. data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +22 -0
  155. data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +3 -0
  156. data/sufia-models/app/models/concerns/sufia/user.rb +9 -0
  157. data/sufia-models/app/models/proxy_deposit_request.rb +85 -0
  158. data/sufia-models/app/models/proxy_deposit_rights.rb +4 -0
  159. data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
  160. data/sufia-models/lib/generators/sufia/models/install_generator.rb +9 -1
  161. data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +53 -0
  162. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +16 -0
  163. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +11 -0
  164. data/sufia-models/lib/sufia/models/engine.rb +1 -1
  165. data/sufia-models/lib/sufia/models/version.rb +1 -1
  166. data/sufia.gemspec +2 -1
  167. data/tasks/sufia-dev.rake +5 -0
  168. metadata +82 -6
  169. data/tasks/sufia-db.rake +0 -21
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GeoNamesResource do
3
+ describe GeoNamesResource, :type => :model do
4
4
 
5
5
  it "should find locations" do
6
6
  hits = GeoNamesResource.find_location("State")
7
- hits.should_not be_nil
7
+ expect(hits).not_to be_nil
8
8
  end
9
9
  end
10
10
 
@@ -1,102 +1,103 @@
1
1
  require 'spec_helper'
2
2
 
3
- # Don't run the tests if activerecord-import isn't installed.
4
- # The 0.3.1 version doesn't work with rails 4, so suppress these tests
5
- describe LocalAuthority do
6
- before(:all) do
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
- after(:each) do
14
- LocalAuthorityEntry.all.each(&:destroy)
15
- DomainTerm.all.each do |term|
16
- term.local_authorities.each do |auth|
17
- auth.destroy
18
- end
19
- term.destroy
20
- end
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
- LocalAuthority.harvest_rdf("genres", @nt)
24
- LocalAuthority.count.should == 1
25
- LocalAuthorityEntry.count.should == 6
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", @rdfxml,
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.should == 1
32
- LocalAuthorityEntry.count.should == 35
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
- LocalAuthority.harvest_tsv("geo", @tsv, prefix: 'http://sws.geonames.org/')
36
- LocalAuthority.count.should == 1
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.should == 149
42
+ expect(LocalAuthorityEntry.count).to eq(149)
40
43
  end
44
+
41
45
  describe "when vocabs are harvested" do
42
- before(:all) do
43
- class MyTestRdfDatastream; end
44
- LocalAuthority.harvest_rdf("genres", @nt)
45
- LocalAuthority.harvest_tsv("geo", @tsv, prefix: 'http://sws.geonames.org/')
46
- DomainTerm.count.should == 0
47
- @num_auths = LocalAuthority.count
48
- @num_entries = LocalAuthorityEntry.count
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
- after(:all) do
51
- DomainTerm.all.each(&:delete)
52
- LocalAuthority.all.each(&:delete)
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
- LocalAuthority.harvest_rdf("genres", @nt)
58
- LocalAuthority.count.should == @num_auths
59
- LocalAuthorityEntry.count.should == @num_entries
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
- LocalAuthority.harvest_tsv("geo", @tsv, prefix: 'http://sws.geonames.org/')
63
- LocalAuthority.count.should == @num_auths
64
- LocalAuthorityEntry.count.should == @num_entries
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.should == 1
71
+ expect(DomainTerm.count).to eq(1)
69
72
  end
73
+
70
74
  describe "when vocabs are registered" do
71
- before(:all) do
72
- LocalAuthority.harvest_rdf("genres", @nt)
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
- after(:all) do
80
- DomainTerm.all.each(&:delete)
81
- LocalAuthority.all.each(&:delete)
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", "").should be_nil
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").should == []
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").should == []
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.should == 6
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,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Sufia::Pageview do
3
+ describe Sufia::Pageview, :type => :model do
4
4
  before do
5
5
  @pageview = Sufia::Pageview
6
6
  end
@@ -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
- it "should have import_url" do
6
- subject.import_url = 'http://example.com/somefile.txt'
7
- subject.import_url.should == ['http://example.com/somefile.txt']
8
- subject.ng_xml.to_xml.should be_equivalent_to "<?xml version=\"1.0\"?><fields><importUrl>http://example.com/somefile.txt</importUrl></fields>"
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 "to_solr" do
15
+ describe "proxy_depositor" do
12
16
  before do
13
- @doc = PropertiesDatastream.new(nil, 'properties').tap do |ds|
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
- subject { @doc.to_solr}
18
- it "should have import_url" do
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.stub(:now).and_return(@now)
19
+ allow(DateTime).to receive(:now).and_return(@now)
20
20
  @hash = "sha2hash#{@now.to_f.to_s}"
21
- Digest::SHA2.should_receive(:new).and_return(@hash)
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.should == @hash
26
- su.itemId.should == file.pid
27
- su.path.should == Sufia::Engine.routes.url_helpers.generic_file_path(file.pid)
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.should == @hash
33
- su.itemId.should == file.pid
34
- su.path.should == Sufia::Engine.routes.url_helpers.download_path(file.pid)
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.should == file.pid
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.should == file.pid
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?.should == false
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?.should == true
65
+ expect(link.expired?).to eq(true)
66
66
  end
67
67
  end
68
68
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SolrDocument do
3
+ describe SolrDocument, :type => :model do
4
4
 
5
5
  describe "date_uploaded" do
6
6
  before do
@@ -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.should respond_to(:user_id)
13
- @trophy.user_id.should == 99
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.should respond_to(:generic_file_id)
17
- @trophy.generic_file_id.should == "99"
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.should == 5
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