sufia 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GenericFileRdfDatastream do
3
+ describe GenericFileRdfDatastream, :type => :model do
4
4
  it "should have bibliographicCitation" do
5
5
  subject.bibliographic_citation = "foo"
6
6
  expect(subject.bibliographic_citation).to eq ["foo"]
@@ -1,6 +1,40 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GenericFile do
3
+ describe GenericFile, :type => :model do
4
+ let(:user) { FactoryGirl.find_or_create(:jill) }
5
+
6
+ before(:each) do
7
+ @file = GenericFile.new
8
+ @file.apply_depositor_metadata(user.user_key)
9
+ end
10
+
11
+ describe "created for someone (proxy)" do
12
+ before do
13
+ @transfer_to = FactoryGirl.find_or_create(:jill)
14
+ end
15
+ after do
16
+ @file.destroy
17
+ end
18
+
19
+ it "transfers the request" do
20
+ @file.on_behalf_of = @transfer_to.user_key
21
+ stub_job = double('change depositor job')
22
+ allow(ContentDepositorChangeEventJob).to receive(:new).and_return(stub_job)
23
+ expect(Sufia.queue).to receive(:push).with(stub_job).once.and_return(true)
24
+ @file.save!
25
+ end
26
+ end
27
+
28
+ describe "delegations" do
29
+ before do
30
+ @file.proxy_depositor = "sally@example.com"
31
+ end
32
+ it "should include proxies" do
33
+ expect(@file).to respond_to(:relative_path)
34
+ expect(@file).to respond_to(:depositor)
35
+ expect(@file.proxy_depositor).to eq 'sally@example.com'
36
+ end
37
+ end
4
38
 
5
39
  subject { GenericFile.new }
6
40
 
@@ -56,176 +90,176 @@ describe GenericFile do
56
90
  context "when pdf?" do
57
91
  it "should be true for pdf" do
58
92
  subject.mime_type = 'application/pdf'
59
- subject.should be_pdf
93
+ expect(subject).to be_pdf
60
94
  end
61
95
  end
62
96
  context "when audio?" do
63
97
  it "should be true for wav" do
64
98
  subject.mime_type = 'audio/x-wave'
65
- subject.should be_audio
99
+ expect(subject).to be_audio
66
100
  subject.mime_type = 'audio/x-wav'
67
- subject.should be_audio
101
+ expect(subject).to be_audio
68
102
  end
69
103
  it "should be true for mpeg" do
70
104
  subject.mime_type = 'audio/mpeg'
71
- subject.should be_audio
105
+ expect(subject).to be_audio
72
106
  subject.mime_type = 'audio/mp3'
73
- subject.should be_audio
107
+ expect(subject).to be_audio
74
108
  end
75
109
  it "should be true for ogg" do
76
110
  subject.mime_type = 'audio/ogg'
77
- subject.should be_audio
111
+ expect(subject).to be_audio
78
112
  end
79
113
  end
80
114
  context "when video?" do
81
115
  it "should be true for avi" do
82
116
  subject.mime_type = 'video/avi'
83
- subject.should be_video
117
+ expect(subject).to be_video
84
118
  end
85
119
  it "should be true for webm" do
86
120
  subject.mime_type = 'video/webm'
87
- subject.should be_video
121
+ expect(subject).to be_video
88
122
  end
89
123
  it "should be true for mpeg" do
90
124
  subject.mime_type = 'video/mp4'
91
- subject.should be_video
125
+ expect(subject).to be_video
92
126
  subject.mime_type = 'video/mpeg'
93
- subject.should be_video
127
+ expect(subject).to be_video
94
128
  end
95
129
  it "should be true for quicktime" do
96
130
  subject.mime_type = 'video/quicktime'
97
- subject.should be_video
131
+ expect(subject).to be_video
98
132
  end
99
133
  it "should be true for mxf" do
100
134
  subject.mime_type = 'application/mxf'
101
- subject.should be_video
135
+ expect(subject).to be_video
102
136
  end
103
137
  end
104
138
  end
105
139
 
106
140
  describe "visibility" do
107
141
  it "should not be changed when it's new" do
108
- subject.should_not be_visibility_changed
142
+ expect(subject).not_to be_visibility_changed
109
143
  end
110
144
  it "should be changed when it has been changed" do
111
145
  subject.visibility= 'open'
112
- subject.should be_visibility_changed
146
+ expect(subject).to be_visibility_changed
113
147
  end
114
148
 
115
149
  it "should not be changed when it's set to its previous value" do
116
150
  subject.visibility= 'restricted'
117
- subject.should_not be_visibility_changed
151
+ expect(subject).not_to be_visibility_changed
118
152
  end
119
153
 
120
154
  end
121
155
 
122
156
  describe "attributes" do
123
157
  it "should have rightsMetadata" do
124
- subject.rightsMetadata.should be_instance_of ParanoidRightsDatastream
158
+ expect(subject.rightsMetadata).to be_instance_of ParanoidRightsDatastream
125
159
  end
126
160
  it "should have properties datastream for depositor" do
127
- subject.properties.should be_instance_of PropertiesDatastream
161
+ expect(subject.properties).to be_instance_of PropertiesDatastream
128
162
  end
129
163
  it "should have apply_depositor_metadata" do
130
- subject.rightsMetadata.edit_access.should == ['jcoyne']
131
- subject.depositor.should == 'jcoyne'
164
+ expect(subject.rightsMetadata.edit_access).to eq(['jcoyne'])
165
+ expect(subject.depositor).to eq('jcoyne')
132
166
  end
133
167
  it "should have a set of permissions" do
134
168
  subject.read_groups=['group1', 'group2']
135
169
  subject.edit_users=['user1']
136
170
  subject.read_users=['user2', 'user3']
137
- subject.permissions.should == [{type: "group", access: "read", name: "group1"},
171
+ expect(subject.permissions).to eq([{type: "group", access: "read", name: "group1"},
138
172
  {type: "group", access: "read", name: "group2"},
139
173
  {type: "user", access: "read", name: "user2"},
140
174
  {type: "user", access: "read", name: "user3"},
141
- {type: "user", access: "edit", name: "user1"}]
175
+ {type: "user", access: "edit", name: "user1"}])
142
176
  end
143
177
  describe "updating permissions" do
144
178
  it "should create new group permissions" do
145
179
  subject.permissions = {new_group_name: {'group1'=>'read'}}
146
- subject.permissions.should == [{type: "group", access: "read", name: "group1"},
147
- {type: "user", access: "edit", name: "jcoyne"}]
180
+ expect(subject.permissions).to eq([{type: "group", access: "read", name: "group1"},
181
+ {type: "user", access: "edit", name: "jcoyne"}])
148
182
  end
149
183
  it "should create new user permissions" do
150
184
  subject.permissions = {new_user_name: {'user1'=>'read'}}
151
- subject.permissions.should == [{type: "user", access: "read", name: "user1"},
152
- {type: "user", access: "edit", name: "jcoyne"}]
185
+ expect(subject.permissions).to eq([{type: "user", access: "read", name: "user1"},
186
+ {type: "user", access: "edit", name: "jcoyne"}])
153
187
  end
154
188
  it "should not replace existing groups" do
155
189
  subject.permissions = {new_group_name: {'group1' => 'read'}}
156
190
  subject.permissions = {new_group_name: {'group2' => 'read'}}
157
- subject.permissions.should == [{type: "group", access: "read", name: "group1"},
191
+ expect(subject.permissions).to eq([{type: "group", access: "read", name: "group1"},
158
192
  {type: "group", access: "read", name: "group2"},
159
- {type: "user", access: "edit", name: "jcoyne"}]
193
+ {type: "user", access: "edit", name: "jcoyne"}])
160
194
  end
161
195
  it "should not replace existing users" do
162
196
  subject.permissions = {new_user_name:{'user1'=>'read'}}
163
197
  subject.permissions = {new_user_name:{'user2'=>'read'}}
164
- subject.permissions.should == [{type: "user", access: "read", name: "user1"},
198
+ expect(subject.permissions).to eq([{type: "user", access: "read", name: "user1"},
165
199
  {type: "user", access: "read", name: "user2"},
166
- {type: "user", access: "edit", name: "jcoyne"}]
200
+ {type: "user", access: "edit", name: "jcoyne"}])
167
201
  end
168
202
  it "should update permissions on existing users" do
169
203
  subject.permissions = {new_user_name:{'user1'=>'read'}}
170
204
  subject.permissions = {user:{'user1'=>'edit'}}
171
- subject.permissions.should == [{type: "user", access: "edit", name: "user1"},
172
- {type: "user", access: "edit", name: "jcoyne"}]
205
+ expect(subject.permissions).to eq([{type: "user", access: "edit", name: "user1"},
206
+ {type: "user", access: "edit", name: "jcoyne"}])
173
207
  end
174
208
  it "should update permissions on existing groups" do
175
209
  subject.permissions = {new_group_name:{'group1'=>'read'}}
176
210
  subject.permissions = {group:{'group1'=>'edit'}}
177
- subject.permissions.should == [{type: "group", access: "edit", name: "group1"},
178
- {type: "user", access: "edit", name: "jcoyne"}]
211
+ expect(subject.permissions).to eq([{type: "group", access: "edit", name: "group1"},
212
+ {type: "user", access: "edit", name: "jcoyne"}])
179
213
  end
180
214
  end
181
215
  it "should have a characterization datastream" do
182
- subject.characterization.should be_kind_of FitsDatastream
216
+ expect(subject.characterization).to be_kind_of FitsDatastream
183
217
  end
184
218
  it "should have a dc desc metadata" do
185
- subject.descMetadata.should be_kind_of GenericFileRdfDatastream
219
+ expect(subject.descMetadata).to be_kind_of GenericFileRdfDatastream
186
220
  end
187
221
  it "should have content datastream" do
188
222
  subject.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
189
- subject.content.should be_kind_of FileContentDatastream
223
+ expect(subject.content).to be_kind_of FileContentDatastream
190
224
  end
191
225
  end
192
226
  describe "delegations" do
193
227
  it "should delegate methods to properties metadata" do
194
- subject.should respond_to(:relative_path)
195
- subject.should respond_to(:depositor)
228
+ expect(subject).to respond_to(:relative_path)
229
+ expect(subject).to respond_to(:depositor)
196
230
  end
197
231
  it "should delegate methods to descriptive metadata" do
198
- subject.should respond_to(:related_url)
199
- subject.should respond_to(:based_near)
200
- subject.should respond_to(:part_of)
201
- subject.should respond_to(:contributor)
202
- subject.should respond_to(:creator)
203
- subject.should respond_to(:title)
204
- subject.should respond_to(:description)
205
- subject.should respond_to(:publisher)
206
- subject.should respond_to(:date_created)
207
- subject.should respond_to(:date_uploaded)
208
- subject.should respond_to(:date_modified)
209
- subject.should respond_to(:subject)
210
- subject.should respond_to(:language)
211
- subject.should respond_to(:rights)
212
- subject.should respond_to(:resource_type)
213
- subject.should respond_to(:identifier)
232
+ expect(subject).to respond_to(:related_url)
233
+ expect(subject).to respond_to(:based_near)
234
+ expect(subject).to respond_to(:part_of)
235
+ expect(subject).to respond_to(:contributor)
236
+ expect(subject).to respond_to(:creator)
237
+ expect(subject).to respond_to(:title)
238
+ expect(subject).to respond_to(:description)
239
+ expect(subject).to respond_to(:publisher)
240
+ expect(subject).to respond_to(:date_created)
241
+ expect(subject).to respond_to(:date_uploaded)
242
+ expect(subject).to respond_to(:date_modified)
243
+ expect(subject).to respond_to(:subject)
244
+ expect(subject).to respond_to(:language)
245
+ expect(subject).to respond_to(:rights)
246
+ expect(subject).to respond_to(:resource_type)
247
+ expect(subject).to respond_to(:identifier)
214
248
  end
215
249
  it "should delegate methods to characterization metadata" do
216
- subject.should respond_to(:format_label)
217
- subject.should respond_to(:mime_type)
218
- subject.should respond_to(:file_size)
219
- subject.should respond_to(:last_modified)
220
- subject.should respond_to(:filename)
221
- subject.should respond_to(:original_checksum)
222
- subject.should respond_to(:well_formed)
223
- subject.should respond_to(:file_title)
224
- subject.should respond_to(:file_author)
225
- subject.should respond_to(:page_count)
250
+ expect(subject).to respond_to(:format_label)
251
+ expect(subject).to respond_to(:mime_type)
252
+ expect(subject).to respond_to(:file_size)
253
+ expect(subject).to respond_to(:last_modified)
254
+ expect(subject).to respond_to(:filename)
255
+ expect(subject).to respond_to(:original_checksum)
256
+ expect(subject).to respond_to(:well_formed)
257
+ expect(subject).to respond_to(:file_title)
258
+ expect(subject).to respond_to(:file_author)
259
+ expect(subject).to respond_to(:page_count)
226
260
  end
227
261
  it "should redefine to_param to make redis keys more recognizable" do
228
- subject.to_param.should == subject.noid
262
+ expect(subject.to_param).to eq(subject.noid)
229
263
  end
230
264
  describe "that have been saved" do
231
265
  # This file has no content, so it doesn't characterize
@@ -244,10 +278,10 @@ describe GenericFile do
244
278
  it "should have activity stream-related methods defined" do
245
279
  subject.save
246
280
  f = subject.reload
247
- f.should respond_to(:stream)
248
- f.should respond_to(:events)
249
- f.should respond_to(:create_event)
250
- f.should respond_to(:log_event)
281
+ expect(f).to respond_to(:stream)
282
+ expect(f).to respond_to(:events)
283
+ expect(f).to respond_to(:create_event)
284
+ expect(f).to respond_to(:log_event)
251
285
  end
252
286
  it "should be able to set values via delegated methods" do
253
287
  subject.related_url = ["http://example.org/"]
@@ -255,23 +289,23 @@ describe GenericFile do
255
289
  subject.title = ["New work"]
256
290
  subject.save
257
291
  f = subject.reload
258
- f.related_url.should == ["http://example.org/"]
259
- f.creator.should == ["John Doe"]
260
- f.title.should == ["New work"]
292
+ expect(f.related_url).to eq(["http://example.org/"])
293
+ expect(f.creator).to eq(["John Doe"])
294
+ expect(f.title).to eq(["New work"])
261
295
  end
262
296
  it "should be able to be added to w/o unexpected graph behavior" do
263
297
  subject.creator = ["John Doe"]
264
298
  subject.title = ["New work"]
265
299
  subject.save
266
300
  f = subject.reload
267
- f.creator.should == ["John Doe"]
268
- f.title.should == ["New work"]
301
+ expect(f.creator).to eq(["John Doe"])
302
+ expect(f.title).to eq(["New work"])
269
303
  f.creator = ["Jane Doe"]
270
304
  f.title << "Newer work"
271
305
  f.save
272
306
  f = subject.reload
273
- f.creator.should == ["Jane Doe"]
274
- f.title.should == ["New work", "Newer work"]
307
+ expect(f.creator).to eq(["Jane Doe"])
308
+ expect(f.title).to eq(["New work", "Newer work"])
275
309
  end
276
310
  end
277
311
  end
@@ -327,12 +361,12 @@ describe GenericFile do
327
361
  end
328
362
  it "should support multi-valued fields in solr" do
329
363
  subject.tag = ["tag1", "tag2"]
330
- lambda { subject.save }.should_not raise_error
364
+ expect { subject.save }.not_to raise_error
331
365
  subject.delete
332
366
  end
333
367
  it "should support setting and getting the relative_path value" do
334
368
  subject.relative_path = "documents/research/NSF/2010"
335
- subject.relative_path.should == "documents/research/NSF/2010"
369
+ expect(subject.relative_path).to eq("documents/research/NSF/2010")
336
370
  end
337
371
  describe "create_thumbnail" do
338
372
  before do
@@ -344,14 +378,14 @@ describe GenericFile do
344
378
  end
345
379
  describe "with a video", if: Sufia.config.enable_ffmpeg do
346
380
  before do
347
- @f.stub(mime_type: 'video/quicktime') #Would get set by the characterization job
381
+ allow(@f).to receive_messages(mime_type: 'video/quicktime') #Would get set by the characterization job
348
382
  @f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), 'content', 'countdown.avi')
349
383
  @f.save
350
384
  end
351
385
  it "should make a png thumbnail" do
352
386
  @f.create_thumbnail
353
- @f.thumbnail.content.size.should == 4768 # this is a bad test. I just want to show that it did something.
354
- @f.thumbnail.mimeType.should == 'image/png'
387
+ expect(@f.thumbnail.content.size).to eq(4768) # this is a bad test. I just want to show that it did something.
388
+ expect(@f.thumbnail.mimeType).to eq('image/png')
355
389
  end
356
390
  end
357
391
  end
@@ -384,33 +418,33 @@ describe GenericFile do
384
418
  end
385
419
  it "should schedule a audit job for each datastream" do
386
420
  s0 = double('zero')
387
- AuditJob.should_receive(:new).with(@f.pid, 'descMetadata', "descMetadata.0").and_return(s0)
388
- Sufia.queue.should_receive(:push).with(s0)
421
+ expect(AuditJob).to receive(:new).with(@f.pid, 'descMetadata', "descMetadata.0").and_return(s0)
422
+ expect(Sufia.queue).to receive(:push).with(s0)
389
423
  s1 = double('one')
390
- AuditJob.should_receive(:new).with(@f.pid, 'DC', "DC1.0").and_return(s1)
391
- Sufia.queue.should_receive(:push).with(s1)
424
+ expect(AuditJob).to receive(:new).with(@f.pid, 'DC', "DC1.0").and_return(s1)
425
+ expect(Sufia.queue).to receive(:push).with(s1)
392
426
  s2 = double('two')
393
- AuditJob.should_receive(:new).with(@f.pid, 'RELS-EXT', "RELS-EXT.0").and_return(s2)
394
- Sufia.queue.should_receive(:push).with(s2)
427
+ expect(AuditJob).to receive(:new).with(@f.pid, 'RELS-EXT', "RELS-EXT.0").and_return(s2)
428
+ expect(Sufia.queue).to receive(:push).with(s2)
395
429
  s3 = double('three')
396
- AuditJob.should_receive(:new).with(@f.pid, 'rightsMetadata', "rightsMetadata.0").and_return(s3)
397
- Sufia.queue.should_receive(:push).with(s3)
430
+ expect(AuditJob).to receive(:new).with(@f.pid, 'rightsMetadata', "rightsMetadata.0").and_return(s3)
431
+ expect(Sufia.queue).to receive(:push).with(s3)
398
432
  s4 = double('four')
399
- AuditJob.should_receive(:new).with(@f.pid, 'properties', "properties.0").and_return(s4)
400
- Sufia.queue.should_receive(:push).with(s4)
433
+ expect(AuditJob).to receive(:new).with(@f.pid, 'properties', "properties.0").and_return(s4)
434
+ expect(Sufia.queue).to receive(:push).with(s4)
401
435
  s5 = double('five')
402
- AuditJob.should_receive(:new).with(@f.pid, 'content', "content.0").and_return(s5)
403
- Sufia.queue.should_receive(:push).with(s5)
436
+ expect(AuditJob).to receive(:new).with(@f.pid, 'content', "content.0").and_return(s5)
437
+ expect(Sufia.queue).to receive(:push).with(s5)
404
438
  @f.audit!
405
439
  end
406
440
  it "should log a failing audit" do
407
- @f.datastreams.each { |ds| ds.stub(:dsChecksumValid).and_return(false) }
408
- GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
441
+ @f.datastreams.each { |ds| allow(ds).to receive(:dsChecksumValid).and_return(false) }
442
+ allow(GenericFile).to receive(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
409
443
  @f.audit!
410
444
  expect(ChecksumAuditLog.all).to be_all { |cal| cal.pass == 0 }
411
445
  end
412
446
  it "should log a passing audit" do
413
- GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
447
+ allow(GenericFile).to receive(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
414
448
  @f.audit!
415
449
  expect(ChecksumAuditLog.all).to be_all { |cal| cal.pass == 1 }
416
450
  end
@@ -431,22 +465,22 @@ describe GenericFile do
431
465
  @new = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 0)
432
466
  end
433
467
  it "should not prune failed audits" do
434
- @version.should_receive(:dsChecksumValid).and_return(true)
468
+ expect(@version).to receive(:dsChecksumValid).and_return(true)
435
469
  GenericFile.run_audit(@version)
436
470
 
437
- @version.should_receive(:dsChecksumValid).and_return(false)
471
+ expect(@version).to receive(:dsChecksumValid).and_return(false)
438
472
  GenericFile.run_audit(@version)
439
473
 
440
- @version.should_receive(:dsChecksumValid).and_return(false)
474
+ expect(@version).to receive(:dsChecksumValid).and_return(false)
441
475
  GenericFile.run_audit(@version)
442
476
 
443
- @version.should_receive(:dsChecksumValid).and_return(true)
477
+ expect(@version).to receive(:dsChecksumValid).and_return(true)
444
478
  GenericFile.run_audit(@version)
445
479
 
446
- @version.should_receive(:dsChecksumValid).and_return(false)
480
+ expect(@version).to receive(:dsChecksumValid).and_return(false)
447
481
  GenericFile.run_audit(@version)
448
482
 
449
- @f.logs(@version.dsid).map(&:pass).should == [0, 1, 0, 0, 1, 0, 1]
483
+ expect(@f.logs(@version.dsid).map(&:pass)).to eq([0, 1, 0, 0, 1, 0, 1])
450
484
  end
451
485
 
452
486
  end
@@ -503,15 +537,15 @@ describe GenericFile do
503
537
  @new_file.delete
504
538
  end
505
539
  it "should support the noid method" do
506
- @new_file.should respond_to(:noid)
540
+ expect(@new_file).to respond_to(:noid)
507
541
  end
508
542
  it "should return the expected identifier" do
509
- @new_file.noid.should == '123'
543
+ expect(@new_file.noid).to eq('123')
510
544
  end
511
545
  it "should work outside of an instance" do
512
546
  new_id = Sufia::IdService.mint
513
547
  noid = new_id.split(':').last
514
- Sufia::Noid.noidify(new_id).should == noid
548
+ expect(Sufia::Noid.noidify(new_id)).to eq(noid)
515
549
  end
516
550
  end
517
551
  describe "characterize" do
@@ -519,7 +553,7 @@ describe GenericFile do
519
553
  subject.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
520
554
  subject.characterize
521
555
  doc = Nokogiri::XML.parse(subject.characterization.content)
522
- doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
556
+ expect(doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text).to eq('50')
523
557
  end
524
558
  context "after characterization" do
525
559
  before(:all) do
@@ -535,25 +569,25 @@ describe GenericFile do
535
569
  @myfile.destroy
536
570
  end
537
571
  it "should return expected results after a save" do
538
- @myfile.file_size.should == ['218882']
539
- @myfile.original_checksum.should == ['5a2d761cab7c15b2b3bb3465ce64586d']
572
+ expect(@myfile.file_size).to eq(['218882'])
573
+ expect(@myfile.original_checksum).to eq(['5a2d761cab7c15b2b3bb3465ce64586d'])
540
574
  end
541
575
  it "should return a hash of all populated values from the characterization terminology" do
542
- @myfile.characterization_terms[:format_label].should == ["Portable Document Format"]
543
- @myfile.characterization_terms[:mime_type].should == "application/pdf"
544
- @myfile.characterization_terms[:file_size].should == ["218882"]
545
- @myfile.characterization_terms[:original_checksum].should == ["5a2d761cab7c15b2b3bb3465ce64586d"]
546
- @myfile.characterization_terms.keys.should include(:last_modified)
547
- @myfile.characterization_terms.keys.should include(:filename)
576
+ expect(@myfile.characterization_terms[:format_label]).to eq(["Portable Document Format"])
577
+ expect(@myfile.characterization_terms[:mime_type]).to eq("application/pdf")
578
+ expect(@myfile.characterization_terms[:file_size]).to eq(["218882"])
579
+ expect(@myfile.characterization_terms[:original_checksum]).to eq(["5a2d761cab7c15b2b3bb3465ce64586d"])
580
+ expect(@myfile.characterization_terms.keys).to include(:last_modified)
581
+ expect(@myfile.characterization_terms.keys).to include(:filename)
548
582
  end
549
583
  it "should append metadata from the characterization" do
550
- @myfile.title.should include("Microsoft Word - sample.pdf.docx")
551
- @myfile.filename[0].should == @myfile.label
584
+ expect(@myfile.title).to include("Microsoft Word - sample.pdf.docx")
585
+ expect(@myfile.filename[0]).to eq(@myfile.label)
552
586
  end
553
587
  it "should append each term only once" do
554
588
  @myfile.append_metadata
555
- @myfile.format_label.should == ["Portable Document Format"]
556
- @myfile.title.should include("Microsoft Word - sample.pdf.docx")
589
+ expect(@myfile.format_label).to eq(["Portable Document Format"])
590
+ expect(@myfile.title).to include("Microsoft Word - sample.pdf.docx")
557
591
  end
558
592
  it 'includes extracted full-text content' do
559
593
  expect(@myfile.full_text.content).to eq("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMicrosoft Word - sample.pdf.docx\n\n\n \n \n\n \n\n \n\n \n\nThis PDF file was created using CutePDF. \n\nwww.cutepdf.com")
@@ -563,7 +597,7 @@ describe GenericFile do
563
597
  describe "label" do
564
598
  it "should set the inner label" do
565
599
  subject.label = "My New Label"
566
- subject.inner_object.label.should == "My New Label"
600
+ expect(subject.inner_object.label).to eq("My New Label")
567
601
  end
568
602
  end
569
603
  context "with rightsMetadata" do
@@ -574,27 +608,27 @@ describe GenericFile do
574
608
  m
575
609
  end
576
610
  it "should have read groups accessor" do
577
- subject.read_groups.should == ['group-6', 'group-7']
611
+ expect(subject.read_groups).to eq(['group-6', 'group-7'])
578
612
  end
579
613
  it "should have read groups string accessor" do
580
- subject.read_groups_string.should == 'group-6, group-7'
614
+ expect(subject.read_groups_string).to eq('group-6, group-7')
581
615
  end
582
616
  it "should have read groups writer" do
583
617
  subject.read_groups = ['group-2', 'group-3']
584
- subject.rightsMetadata.groups.should == {'group-2' => 'read', 'group-3'=>'read', 'group-8' => 'edit'}
585
- subject.rightsMetadata.users.should == {"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'}
618
+ expect(subject.rightsMetadata.groups).to eq({'group-2' => 'read', 'group-3'=>'read', 'group-8' => 'edit'})
619
+ expect(subject.rightsMetadata.users).to eq({"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'})
586
620
  end
587
621
 
588
622
  it "should have read groups string writer" do
589
623
  subject.read_groups_string = 'umg/up.dlt.staff, group-3'
590
- subject.rightsMetadata.groups.should == {'umg/up.dlt.staff' => 'read', 'group-3'=>'read', 'group-8' => 'edit'}
591
- subject.rightsMetadata.users.should == {"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'}
624
+ expect(subject.rightsMetadata.groups).to eq({'umg/up.dlt.staff' => 'read', 'group-3'=>'read', 'group-8' => 'edit'})
625
+ expect(subject.rightsMetadata.users).to eq({"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'})
592
626
  end
593
627
  it "should only revoke eligible groups" do
594
628
  subject.set_read_groups(['group-2', 'group-3'], ['group-6'])
595
629
  # 'group-7' is not eligible to be revoked
596
- subject.rightsMetadata.groups.should == {'group-2' => 'read', 'group-3'=>'read', 'group-7' => 'read', 'group-8' => 'edit'}
597
- subject.rightsMetadata.users.should == {"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'}
630
+ expect(subject.rightsMetadata.groups).to eq({'group-2' => 'read', 'group-3'=>'read', 'group-7' => 'read', 'group-8' => 'edit'})
631
+ expect(subject.rightsMetadata.users).to eq({"person1"=>"read","person2"=>"read", 'jcoyne' => 'edit'})
598
632
  end
599
633
  end
600
634
  describe "permissions validation" do
@@ -634,66 +668,66 @@ describe GenericFile do
634
668
  end
635
669
  it "should work via permissions=()" do
636
670
  @file.permissions = {user: {'mjg36' => 'read'}}
637
- lambda { @file.save }.should_not raise_error
671
+ expect { @file.save }.not_to raise_error
638
672
  expect(@file).to be_new_record
639
- @file.errors.should include(:edit_users)
640
- @file.errors[:edit_users].should include('Depositor must have edit access')
673
+ expect(@file.errors).to include(:edit_users)
674
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
641
675
  expect(@file).to_not be_valid
642
676
  end
643
677
  it "should work via update_attributes" do
644
678
  # automatically triggers save
645
- lambda { @file.update_attributes(read_users_string: 'mjg36') }.should_not raise_error
679
+ expect { @file.update_attributes(read_users_string: 'mjg36') }.not_to raise_error
646
680
  expect(@file).to be_new_record
647
- @file.errors.should include(:edit_users)
648
- @file.errors[:edit_users].should include('Depositor must have edit access')
681
+ expect(@file.errors).to include(:edit_users)
682
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
649
683
  expect(@file).to_not be_valid
650
684
  end
651
685
  it "should work via update_indexed_attributes" do
652
686
  @rightsmd.update_indexed_attributes([:edit_access, :person] => '')
653
- lambda { @file.save }.should_not raise_error
687
+ expect { @file.save }.not_to raise_error
654
688
  expect(@file).to be_new_record
655
- @file.errors.should include(:edit_users)
656
- @file.errors[:edit_users].should include('Depositor must have edit access')
689
+ expect(@file.errors).to include(:edit_users)
690
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
657
691
  expect(@file).to_not be_valid
658
692
  end
659
693
  it "should work via permissions()" do
660
694
  @rightsmd.permissions({person: "mjg36"}, "read")
661
- lambda { @file.save }.should_not raise_error
695
+ expect { @file.save }.not_to raise_error
662
696
  expect(@file).to be_new_record
663
- @file.errors.should include(:edit_users)
664
- @file.errors[:edit_users].should include('Depositor must have edit access')
697
+ expect(@file.errors).to include(:edit_users)
698
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
665
699
  expect(@file).to_not be_valid
666
700
  end
667
701
  it "should work via update_permissions()" do
668
702
  @rightsmd.update_permissions({"person" => {"mjg36" => "read"}})
669
- lambda { @file.save }.should_not raise_error
703
+ expect { @file.save }.not_to raise_error
670
704
  expect(@file).to be_new_record
671
- @file.errors.should include(:edit_users)
672
- @file.errors[:edit_users].should include('Depositor must have edit access')
705
+ expect(@file.errors).to include(:edit_users)
706
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
673
707
  expect(@file).to_not be_valid
674
708
  end
675
709
  it "should work via content=()" do
676
710
  @rightsmd.content=(@rights_xml)
677
- lambda { @file.save }.should_not raise_error
711
+ expect { @file.save }.not_to raise_error
678
712
  expect(@file).to be_new_record
679
- @file.errors.should include(:edit_users)
680
- @file.errors[:edit_users].should include('Depositor must have edit access')
713
+ expect(@file.errors).to include(:edit_users)
714
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
681
715
  expect(@file).to_not be_valid
682
716
  end
683
717
  it "should work via ng_xml=()" do
684
718
  @rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
685
- lambda { @file.save }.should_not raise_error
719
+ expect { @file.save }.not_to raise_error
686
720
  expect(@file).to be_new_record
687
- @file.errors.should include(:edit_users)
688
- @file.errors[:edit_users].should include('Depositor must have edit access')
721
+ expect(@file.errors).to include(:edit_users)
722
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
689
723
  expect(@file).to_not be_valid
690
724
  end
691
725
  it "should work via update_values()" do
692
726
  @rightsmd.update_values([:edit_access, :person] => '')
693
- lambda { @file.save }.should_not raise_error
727
+ expect { @file.save }.not_to raise_error
694
728
  expect(@file).to be_new_record
695
- @file.errors.should include(:edit_users)
696
- @file.errors[:edit_users].should include('Depositor must have edit access')
729
+ expect(@file.errors).to include(:edit_users)
730
+ expect(@file.errors[:edit_users]).to include('Depositor must have edit access')
697
731
  expect(@file).to_not be_valid
698
732
  end
699
733
  end
@@ -734,66 +768,66 @@ describe GenericFile do
734
768
  end
735
769
  it "should work via permissions=()" do
736
770
  @file.permissions = {group: {'public' => 'edit'}}
737
- lambda { @file.save }.should_not raise_error
771
+ expect { @file.save }.not_to raise_error
738
772
  expect(@file).to be_new_record
739
- @file.errors.should include(:edit_groups)
740
- @file.errors[:edit_groups].should include('Public cannot have edit access')
773
+ expect(@file.errors).to include(:edit_groups)
774
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
741
775
  expect(@file).to_not be_valid
742
776
  end
743
777
  it "should work via update_attributes" do
744
778
  # automatically triggers save
745
- lambda { @file.update_attributes(edit_groups_string: 'public') }.should_not raise_error
779
+ expect { @file.update_attributes(edit_groups_string: 'public') }.not_to raise_error
746
780
  expect(@file).to be_new_record
747
- @file.errors.should include(:edit_groups)
748
- @file.errors[:edit_groups].should include('Public cannot have edit access')
781
+ expect(@file.errors).to include(:edit_groups)
782
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
749
783
  expect(@file).to_not be_valid
750
784
  end
751
785
  it "should work via update_indexed_attributes" do
752
786
  @rightsmd.update_indexed_attributes([:edit_access, :group] => 'public')
753
- lambda { @file.save }.should_not raise_error
787
+ expect { @file.save }.not_to raise_error
754
788
  expect(@file).to be_new_record
755
- @file.errors.should include(:edit_groups)
756
- @file.errors[:edit_groups].should include('Public cannot have edit access')
789
+ expect(@file.errors).to include(:edit_groups)
790
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
757
791
  expect(@file).to_not be_valid
758
792
  end
759
793
  it "should work via permissions()" do
760
794
  @rightsmd.permissions({group: "public"}, "edit")
761
- lambda { @file.save }.should_not raise_error
795
+ expect { @file.save }.not_to raise_error
762
796
  expect(@file).to be_new_record
763
- @file.errors.should include(:edit_groups)
764
- @file.errors[:edit_groups].should include('Public cannot have edit access')
797
+ expect(@file.errors).to include(:edit_groups)
798
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
765
799
  expect(@file).to_not be_valid
766
800
  end
767
801
  it "should work via update_permissions()" do
768
802
  @rightsmd.update_permissions({"group" => {"public" => "edit"}})
769
- lambda { @file.save }.should_not raise_error
803
+ expect { @file.save }.not_to raise_error
770
804
  expect(@file).to be_new_record
771
- @file.errors.should include(:edit_groups)
772
- @file.errors[:edit_groups].should include('Public cannot have edit access')
805
+ expect(@file.errors).to include(:edit_groups)
806
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
773
807
  expect(@file).to_not be_valid
774
808
  end
775
809
  it "should work via content=()" do
776
810
  @rightsmd.content=(@rights_xml)
777
- lambda { @file.save }.should_not raise_error
811
+ expect { @file.save }.not_to raise_error
778
812
  expect(@file).to be_new_record
779
- @file.errors.should include(:edit_groups)
780
- @file.errors[:edit_groups].should include('Public cannot have edit access')
813
+ expect(@file.errors).to include(:edit_groups)
814
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
781
815
  expect(@file).to_not be_valid
782
816
  end
783
817
  it "should work via ng_xml=()" do
784
818
  @rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
785
- lambda { @file.save }.should_not raise_error
819
+ expect { @file.save }.not_to raise_error
786
820
  expect(@file).to be_new_record
787
- @file.errors.should include(:edit_groups)
788
- @file.errors[:edit_groups].should include('Public cannot have edit access')
821
+ expect(@file.errors).to include(:edit_groups)
822
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
789
823
  expect(@file).to_not be_valid
790
824
  end
791
825
  it "should work via update_values()" do
792
826
  @rightsmd.update_values([:edit_access, :group] => 'public')
793
- lambda { @file.save }.should_not raise_error
827
+ expect { @file.save }.not_to raise_error
794
828
  expect(@file).to be_new_record
795
- @file.errors.should include(:edit_groups)
796
- @file.errors[:edit_groups].should include('Public cannot have edit access')
829
+ expect(@file.errors).to include(:edit_groups)
830
+ expect(@file.errors[:edit_groups]).to include('Public cannot have edit access')
797
831
  expect(@file).to_not be_valid
798
832
  end
799
833
  end
@@ -834,66 +868,66 @@ describe GenericFile do
834
868
  end
835
869
  it "should work via permissions=()" do
836
870
  @file.permissions = {group: {'registered' => 'edit'}}
837
- lambda { @file.save }.should_not raise_error
871
+ expect { @file.save }.not_to raise_error
838
872
  expect(@file).to be_new_record
839
- @file.errors.should include(:edit_groups)
840
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
873
+ expect(@file.errors).to include(:edit_groups)
874
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
841
875
  expect(@file).to_not be_valid
842
876
  end
843
877
  it "should work via update_attributes" do
844
878
  # automatically triggers save
845
- lambda { @file.update_attributes(edit_groups_string: 'registered') }.should_not raise_error
879
+ expect { @file.update_attributes(edit_groups_string: 'registered') }.not_to raise_error
846
880
  expect(@file).to be_new_record
847
- @file.errors.should include(:edit_groups)
848
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
881
+ expect(@file.errors).to include(:edit_groups)
882
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
849
883
  expect(@file).to_not be_valid
850
884
  end
851
885
  it "should work via update_indexed_attributes" do
852
886
  @rightsmd.update_indexed_attributes([:edit_access, :group] => 'registered')
853
- lambda { @file.save }.should_not raise_error
887
+ expect { @file.save }.not_to raise_error
854
888
  expect(@file).to be_new_record
855
- @file.errors.should include(:edit_groups)
856
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
889
+ expect(@file.errors).to include(:edit_groups)
890
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
857
891
  expect(@file).to_not be_valid
858
892
  end
859
893
  it "should work via permissions()" do
860
894
  @rightsmd.permissions({group: "registered"}, "edit")
861
- lambda { @file.save }.should_not raise_error
895
+ expect { @file.save }.not_to raise_error
862
896
  expect(@file).to be_new_record
863
- @file.errors.should include(:edit_groups)
864
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
897
+ expect(@file.errors).to include(:edit_groups)
898
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
865
899
  expect(@file).to_not be_valid
866
900
  end
867
901
  it "should work via update_permissions()" do
868
902
  @rightsmd.update_permissions({"group" => {"registered" => "edit"}})
869
- lambda { @file.save }.should_not raise_error
903
+ expect { @file.save }.not_to raise_error
870
904
  expect(@file).to be_new_record
871
- @file.errors.should include(:edit_groups)
872
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
905
+ expect(@file.errors).to include(:edit_groups)
906
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
873
907
  expect(@file).to_not be_valid
874
908
  end
875
909
  it "should work via content=()" do
876
910
  @rightsmd.content=(@rights_xml)
877
- lambda { @file.save }.should_not raise_error
911
+ expect { @file.save }.not_to raise_error
878
912
  expect(@file).to be_new_record
879
- @file.errors.should include(:edit_groups)
880
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
913
+ expect(@file.errors).to include(:edit_groups)
914
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
881
915
  expect(@file).to_not be_valid
882
916
  end
883
917
  it "should work via ng_xml=()" do
884
918
  @rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
885
- lambda { @file.save }.should_not raise_error
919
+ expect { @file.save }.not_to raise_error
886
920
  expect(@file).to be_new_record
887
- @file.errors.should include(:edit_groups)
888
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
921
+ expect(@file.errors).to include(:edit_groups)
922
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
889
923
  expect(@file).to_not be_valid
890
924
  end
891
925
  it "should work via update_values()" do
892
926
  @rightsmd.update_values([:edit_access, :group] => 'registered')
893
- lambda { @file.save }.should_not raise_error
927
+ expect { @file.save }.not_to raise_error
894
928
  expect(@file).to be_new_record
895
- @file.errors.should include(:edit_groups)
896
- @file.errors[:edit_groups].should include('Registered cannot have edit access')
929
+ expect(@file.errors).to include(:edit_groups)
930
+ expect(@file.errors[:edit_groups]).to include('Registered cannot have edit access')
897
931
  expect(@file).to_not be_valid
898
932
  end
899
933
  end
@@ -936,58 +970,58 @@ describe GenericFile do
936
970
  end
937
971
  it "should work via permissions=()" do
938
972
  @file.permissions = {group: {'registered' => 'read'}}
939
- lambda { @file.save }.should_not raise_error
973
+ expect { @file.save }.not_to raise_error
940
974
  expect(@file).to_not be_new_record
941
- @file.errors.should be_empty
975
+ expect(@file.errors).to be_empty
942
976
  expect(@file).to be_valid
943
977
  end
944
978
  it "should work via update_attributes" do
945
979
  # automatically triggers save
946
- lambda { @file.update_attributes(read_groups_string: 'registered') }.should_not raise_error
980
+ expect { @file.update_attributes(read_groups_string: 'registered') }.not_to raise_error
947
981
  expect(@file).to_not be_new_record
948
- @file.errors.should be_empty
982
+ expect(@file.errors).to be_empty
949
983
  expect(@file).to be_valid
950
984
  end
951
985
  it "should work via update_indexed_attributes" do
952
986
  @rightsmd.update_indexed_attributes([:read_access, :group] => 'registered')
953
- lambda { @file.save }.should_not raise_error
987
+ expect { @file.save }.not_to raise_error
954
988
  expect(@file).to_not be_new_record
955
- @file.errors.should be_empty
989
+ expect(@file.errors).to be_empty
956
990
  expect(@file).to be_valid
957
991
  end
958
992
  it "should work via permissions()" do
959
993
  @rightsmd.permissions({group: "registered"}, "read")
960
- lambda { @file.save }.should_not raise_error
994
+ expect { @file.save }.not_to raise_error
961
995
  expect(@file).to_not be_new_record
962
- @file.errors.should be_empty
996
+ expect(@file.errors).to be_empty
963
997
  expect(@file).to be_valid
964
998
  end
965
999
  it "should work via update_permissions()" do
966
1000
  @rightsmd.update_permissions({"group" => {"registered" => "read"}})
967
- lambda { @file.save }.should_not raise_error
1001
+ expect { @file.save }.not_to raise_error
968
1002
  expect(@file).to_not be_new_record
969
- @file.errors.should be_empty
1003
+ expect(@file.errors).to be_empty
970
1004
  expect(@file).to be_valid
971
1005
  end
972
1006
  it "should work via content=()" do
973
1007
  @rightsmd.content=(@rights_xml)
974
- lambda { @file.save }.should_not raise_error
1008
+ expect { @file.save }.not_to raise_error
975
1009
  expect(@file).to_not be_new_record
976
- @file.errors.should be_empty
1010
+ expect(@file.errors).to be_empty
977
1011
  expect(@file).to be_valid
978
1012
  end
979
1013
  it "should work via ng_xml=()" do
980
1014
  @rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
981
- lambda { @file.save }.should_not raise_error
1015
+ expect { @file.save }.not_to raise_error
982
1016
  expect(@file).to_not be_new_record
983
- @file.errors.should be_empty
1017
+ expect(@file.errors).to be_empty
984
1018
  expect(@file).to be_valid
985
1019
  end
986
1020
  it "should work via update_values()" do
987
1021
  @rightsmd.update_values([:read_access, :group] => 'registered')
988
- lambda { @file.save }.should_not raise_error
1022
+ expect { @file.save }.not_to raise_error
989
1023
  expect(@file).to_not be_new_record
990
- @file.errors.should be_empty
1024
+ expect(@file.errors).to be_empty
991
1025
  expect(@file).to be_valid
992
1026
  end
993
1027
  end
@@ -1002,7 +1036,7 @@ describe GenericFile do
1002
1036
  allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError, "A virus was found in #{f.path}: EL CRAPO VIRUS")
1003
1037
  subject.add_file(f, 'content', 'small_file.txt')
1004
1038
  subject.save
1005
- subject.should_not be_persisted
1039
+ expect(subject).not_to be_persisted
1006
1040
  expect(subject.errors.messages).to eq(base: ["A virus was found in #{f.path}: EL CRAPO VIRUS"])
1007
1041
  end
1008
1042
  it "does not save a new version of a GenericFile" do
@@ -1011,7 +1045,7 @@ describe GenericFile do
1011
1045
  allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError)
1012
1046
  subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt') , 'content', 'sufia_generic_stub.txt')
1013
1047
  subject.save
1014
- subject.reload.content.content.should == "small\n"
1048
+ expect(subject.reload.content.content).to eq("small\n")
1015
1049
  end
1016
1050
  end
1017
1051
  end
@@ -1043,12 +1077,12 @@ describe GenericFile do
1043
1077
  describe "public?" do
1044
1078
  context "when read group is set to public" do
1045
1079
  before { subject.read_groups = ['public'] }
1046
- it { should be_public }
1080
+ it { is_expected.to be_public }
1047
1081
  end
1048
1082
 
1049
1083
  context "when read group is not set to public" do
1050
1084
  before { subject.read_groups = ['foo'] }
1051
- it { should_not be_public }
1085
+ it { is_expected.not_to be_public }
1052
1086
  end
1053
1087
  end
1054
1088
  end