sufia 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +146 -0
  3. data/.travis.yml +4 -7
  4. data/Gemfile +2 -0
  5. data/History.md +29 -1
  6. data/README.md +25 -9
  7. data/SUFIA_VERSION +1 -1
  8. data/app/assets/stylesheets/sufia/_collections.scss +15 -0
  9. data/app/assets/stylesheets/sufia/_file-listing.scss +7 -0
  10. data/app/assets/stylesheets/sufia/_home-page.scss +10 -0
  11. data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +3 -5
  12. data/app/controllers/admin/stats_controller.rb +1 -76
  13. data/app/controllers/api/items_controller.rb +4 -6
  14. data/app/controllers/api/zotero_controller.rb +5 -5
  15. data/app/controllers/authorities_controller.rb +5 -1
  16. data/app/controllers/batch_edits_controller.rb +3 -3
  17. data/app/controllers/concerns/sufia/admin/depositor_stats.rb +41 -0
  18. data/app/controllers/concerns/sufia/admin/stats_behavior.rb +94 -0
  19. data/app/controllers/concerns/sufia/batch_controller_behavior.rb +16 -18
  20. data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +54 -56
  21. data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -6
  22. data/app/controllers/concerns/sufia/collections_controller_behavior.rb +39 -39
  23. data/app/controllers/concerns/sufia/controller.rb +10 -10
  24. data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +17 -18
  25. data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +9 -12
  26. data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +6 -7
  27. data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +39 -40
  28. data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -1
  29. data/app/controllers/concerns/sufia/files_controller_behavior.rb +109 -110
  30. data/app/controllers/concerns/sufia/homepage_controller.rb +8 -8
  31. data/app/controllers/concerns/sufia/my_controller_behavior.rb +13 -10
  32. data/app/controllers/concerns/sufia/single_use_links_controller_behavior.rb +11 -14
  33. data/app/controllers/concerns/sufia/single_use_links_viewer_controller_behavior.rb +27 -21
  34. data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +17 -17
  35. data/app/controllers/concerns/sufia/users_controller_behavior.rb +54 -54
  36. data/app/controllers/contact_form_controller.rb +1 -1
  37. data/app/controllers/content_blocks_controller.rb +11 -12
  38. data/app/controllers/directory_controller.rb +2 -3
  39. data/app/controllers/featured_work_lists_controller.rb +1 -1
  40. data/app/controllers/featured_works_controller.rb +2 -4
  41. data/app/controllers/homepage_controller.rb +1 -2
  42. data/app/controllers/mailbox_controller.rb +12 -32
  43. data/app/controllers/my/collections_controller.rb +3 -4
  44. data/app/controllers/my/files_controller.rb +4 -6
  45. data/app/controllers/my/highlights_controller.rb +4 -6
  46. data/app/controllers/my/shares_controller.rb +3 -5
  47. data/app/controllers/pages_controller.rb +1 -3
  48. data/app/controllers/single_use_links_controller.rb +0 -1
  49. data/app/controllers/single_use_links_viewer_controller.rb +0 -1
  50. data/app/controllers/static_controller.rb +1 -0
  51. data/app/forms/sufia/forms/collection_edit_form.rb +2 -2
  52. data/app/helpers/batch_edits_helper.rb +1 -3
  53. data/app/helpers/content_block_helper.rb +7 -8
  54. data/app/helpers/generic_file_helper.rb +23 -24
  55. data/app/helpers/sufia/blacklight_override.rb +6 -7
  56. data/app/helpers/sufia/dashboard_helper_behavior.rb +4 -7
  57. data/app/helpers/sufia/permissions_helper.rb +3 -4
  58. data/app/helpers/sufia/sufia_helper_behavior.rb +30 -29
  59. data/app/helpers/trophy_helper.rb +15 -15
  60. data/app/inputs/select_with_modal_help_input.rb +3 -3
  61. data/app/inputs/with_help_icon.rb +4 -4
  62. data/app/jobs/content_delete_event_job.rb +0 -1
  63. data/app/jobs/content_depositor_change_event_job.rb +1 -2
  64. data/app/jobs/event_job.rb +0 -1
  65. data/app/jobs/user_unfollow_event_job.rb +1 -0
  66. data/app/models/concerns/sufia/solr_document_behavior.rb +1 -2
  67. data/app/models/contact_form.rb +6 -6
  68. data/app/models/content_block.rb +1 -2
  69. data/app/models/featured_work_list.rb +3 -5
  70. data/app/models/user_mailbox.rb +44 -0
  71. data/app/presenters/sufia/collection_presenter.rb +6 -8
  72. data/app/presenters/sufia/generic_file_presenter.rb +2 -2
  73. data/app/presenters/sufia/presenter_renderer.rb +2 -2
  74. data/app/presenters/sufia/version_list_presenter.rb +1 -1
  75. data/app/presenters/sufia/version_presenter.rb +3 -6
  76. data/app/search_builders/deposit_search_builder.rb +19 -0
  77. data/app/search_builders/sufia/my_search_builder_behavior.rb +1 -2
  78. data/app/search_builders/sufia/search_builder.rb +1 -3
  79. data/app/uploaders/tinymce_asset_uploader.rb +0 -2
  80. data/app/views/_controls.html.erb +5 -5
  81. data/app/views/admin/stats/_deposits.html.erb +19 -0
  82. data/app/views/admin/stats/index.html.erb +2 -0
  83. data/app/views/batch_edits/edit.html.erb +2 -2
  84. data/app/views/collections/_edit_actions.html.erb +3 -3
  85. data/app/views/collections/_form_for_select_collection.html.erb +2 -2
  86. data/app/views/collections/_sort_and_per_page.html.erb +12 -9
  87. data/app/views/collections/_view_type_group.html.erb +1 -1
  88. data/app/views/collections/edit.html.erb +5 -5
  89. data/app/views/collections/show.html.erb +7 -6
  90. data/app/views/homepage/_announcement.html.erb +5 -0
  91. data/app/views/homepage/_home.html.erb +1 -0
  92. data/app/views/my/_sort_and_per_page.html.erb +14 -10
  93. data/app/views/my/index.html.erb +1 -1
  94. data/app/views/pages/show.html.erb +0 -2
  95. data/app/views/single_use_links/new_download.html.erb +1 -1
  96. data/app/views/single_use_links_viewer/show.html.erb +1 -1
  97. data/app/views/users/_notify_link.html.erb +1 -1
  98. data/app/views/users/_notify_number.html.erb +2 -2
  99. data/config/initializers/simple_form.rb +1 -1
  100. data/config/initializers/simple_form_bootstrap.rb +1 -1
  101. data/config/locales/sufia.en.yml +4 -0
  102. data/config/routes.rb +2 -3
  103. data/lib/generators/sufia/admin_stat_generator.rb +0 -3
  104. data/lib/generators/sufia/install_generator.rb +8 -9
  105. data/lib/generators/sufia/templates/catalog_controller.rb +2 -3
  106. data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +1 -0
  107. data/lib/generators/sufia/upgrade400_generator.rb +9 -9
  108. data/lib/generators/sufia/upgrade600_generator.rb +1 -4
  109. data/lib/sufia.rb +2 -2
  110. data/lib/sufia/arkivo/actor.rb +1 -1
  111. data/lib/sufia/arkivo/create_subscription_job.rb +30 -30
  112. data/lib/sufia/arkivo/metadata_munger.rb +7 -7
  113. data/lib/sufia/arkivo/schema_validator.rb +1 -1
  114. data/lib/sufia/single_use_error.rb +0 -1
  115. data/lib/sufia/version.rb +1 -1
  116. data/lib/sufia/zotero/config.rb +13 -13
  117. data/spec/actors/generic_file/actor_spec.rb +17 -18
  118. data/spec/controllers/admin_stats_controller_spec.rb +56 -5
  119. data/spec/controllers/api/zotero_controller_spec.rb +10 -9
  120. data/spec/controllers/authorities_controller_spec.rb +8 -8
  121. data/spec/controllers/batch_controller_spec.rb +19 -20
  122. data/spec/controllers/batch_edits_controller_spec.rb +8 -9
  123. data/spec/controllers/catalog_controller_spec.rb +7 -9
  124. data/spec/controllers/collections_controller_spec.rb +30 -32
  125. data/spec/controllers/content_blocks_controller_spec.rb +4 -4
  126. data/spec/controllers/dashboard_controller_spec.rb +12 -12
  127. data/spec/controllers/depositors_controller_spec.rb +8 -8
  128. data/spec/controllers/downloads_controller_spec.rb +10 -11
  129. data/spec/controllers/featured_work_lists_controller_spec.rb +4 -4
  130. data/spec/controllers/featured_works_controller_spec.rb +11 -12
  131. data/spec/controllers/generic_files_controller_spec.rb +154 -125
  132. data/spec/controllers/homepage_controller_spec.rb +22 -15
  133. data/spec/controllers/mailbox_controller_spec.rb +20 -36
  134. data/spec/controllers/my/collections_controller_spec.rb +4 -5
  135. data/spec/controllers/my/files_controller_spec.rb +10 -11
  136. data/spec/controllers/my/highlights_controller_spec.rb +4 -5
  137. data/spec/controllers/my/shares_controller_spec.rb +12 -14
  138. data/spec/controllers/my_controller_spec.rb +1 -3
  139. data/spec/controllers/pages_controller_spec.rb +4 -4
  140. data/spec/controllers/single_use_links_controller_spec.rb +1 -3
  141. data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -2
  142. data/spec/controllers/static_controller_spec.rb +1 -1
  143. data/spec/controllers/tinymce_assets_controller_spec.rb +8 -9
  144. data/spec/controllers/transfers_controller_spec.rb +19 -19
  145. data/spec/controllers/users_controller_spec.rb +33 -35
  146. data/spec/factories/api_items.rb +2 -2
  147. data/spec/factories/content_blocks.rb +1 -1
  148. data/spec/factories/featured_works.rb +1 -1
  149. data/spec/factories/generic_files.rb +3 -3
  150. data/spec/factories/users.rb +7 -8
  151. data/spec/features/browse_dashboard_files_spec.rb +14 -18
  152. data/spec/features/browse_files_spec.rb +3 -4
  153. data/spec/features/catalog_search_spec.rb +3 -5
  154. data/spec/features/cloud_upload_spec.rb +2 -2
  155. data/spec/features/collection_spec.rb +21 -21
  156. data/spec/features/contact_form_spec.rb +10 -11
  157. data/spec/features/display_dashboard_spec.rb +5 -9
  158. data/spec/features/edit_file_spec.rb +8 -9
  159. data/spec/features/featured_item_spec.rb +1 -1
  160. data/spec/features/ingest_upload_files_spec.rb +5 -5
  161. data/spec/features/notifications_spec.rb +2 -6
  162. data/spec/features/ownership_transfer_spec.rb +2 -2
  163. data/spec/features/proxy_spec.rb +2 -2
  164. data/spec/features/search_spec.rb +3 -4
  165. data/spec/features/single_use_links_spec.rb +1 -1
  166. data/spec/features/users_spec.rb +4 -5
  167. data/spec/forms/collection_edit_form_spec.rb +2 -2
  168. data/spec/forms/generic_file_edit_form_spec.rb +6 -7
  169. data/spec/helpers/batch_edits_helper_spec.rb +9 -13
  170. data/spec/helpers/content_block_helper_spec.rb +3 -3
  171. data/spec/helpers/dashboard_helper_spec.rb +19 -24
  172. data/spec/helpers/generic_file_helper_spec.rb +5 -7
  173. data/spec/helpers/sufia_helper_spec.rb +43 -54
  174. data/spec/helpers/trophy_helper_spec.rb +5 -5
  175. data/spec/inputs/multi_value_with_help_input_spec.rb +1 -2
  176. data/spec/inputs/select_with_help_input_spec.rb +19 -15
  177. data/spec/javascripts/jasmine_spec.rb +4 -5
  178. data/spec/javascripts/support/jasmine_helper.rb +9 -9
  179. data/spec/jobs/active_fedora_id_based_job_spec.rb +7 -5
  180. data/spec/jobs/audit_job_spec.rb +7 -7
  181. data/spec/jobs/batch_update_job_spec.rb +5 -6
  182. data/spec/jobs/characterize_job_spec.rb +1 -1
  183. data/spec/jobs/content_depositor_change_event_job_spec.rb +1 -1
  184. data/spec/jobs/create_derivatives_job_spec.rb +5 -5
  185. data/spec/jobs/event_jobs_spec.rb +16 -16
  186. data/spec/jobs/import_url_job_spec.rb +36 -5
  187. data/spec/jobs/ingest_local_file_job_spec.rb +31 -20
  188. data/spec/jobs/sufia_resque_queue_spec.rb +1 -1
  189. data/spec/lib/sufia/analytics_spec.rb +0 -1
  190. data/spec/lib/sufia/arkivo/actor_spec.rb +6 -6
  191. data/spec/lib/sufia/arkivo/schema_validator_spec.rb +18 -18
  192. data/spec/lib/sufia/breadcrumbs_spec.rb +5 -6
  193. data/spec/lib/sufia/messages_spec.rb +11 -12
  194. data/spec/lib/sufia/readable_permissions_spec.rb +8 -10
  195. data/spec/lib/sufia/upload_complete_behavior_spec.rb +6 -7
  196. data/spec/lib/sufia/user_stat_importer_spec.rb +30 -33
  197. data/spec/lib/sufia/writable_permissions_spec.rb +1 -3
  198. data/spec/lib/sufia/zotero/config_spec.rb +4 -6
  199. data/spec/models/ability_spec.rb +11 -9
  200. data/spec/models/batch_spec.rb +13 -13
  201. data/spec/models/characterization_spec.rb +2 -3
  202. data/spec/models/checksum_audit_log_spec.rb +18 -19
  203. data/spec/models/collection_spec.rb +11 -12
  204. data/spec/models/content_block_spec.rb +33 -22
  205. data/spec/models/download_spec.rb +3 -5
  206. data/spec/models/featured_work_list_spec.rb +3 -3
  207. data/spec/models/featured_work_spec.rb +12 -14
  208. data/spec/models/file_content_datastream_spec.rb +9 -7
  209. data/spec/models/file_download_stat_spec.rb +34 -40
  210. data/spec/models/file_usage_spec.rb +46 -52
  211. data/spec/models/file_view_stat_spec.rb +35 -41
  212. data/spec/models/fits_datastream_spec.rb +23 -25
  213. data/spec/models/generic_file/visibility_spec.rb +10 -5
  214. data/spec/models/generic_file_spec.rb +86 -88
  215. data/spec/models/geo_names_resource_spec.rb +3 -5
  216. data/spec/models/local_authority_spec.rb +30 -33
  217. data/spec/models/pageview_spec.rb +3 -3
  218. data/spec/models/proxy_deposit_request_spec.rb +3 -3
  219. data/spec/models/single_use_link_spec.rb +36 -36
  220. data/spec/models/solr_document_spec.rb +3 -6
  221. data/spec/models/trophy_spec.rb +8 -9
  222. data/spec/models/user_mailbox_spec.rb +62 -0
  223. data/spec/models/user_spec.rb +28 -29
  224. data/spec/presenters/presenter_renderer_spec.rb +1 -1
  225. data/spec/presenters/sufia/generic_file_presenter_spec.rb +5 -5
  226. data/spec/presenters/sufia/version_list_presenter_spec.rb +2 -2
  227. data/spec/presenters/sufia/version_presenter_spec.rb +1 -1
  228. data/spec/routing/featured_works_route_spec.rb +4 -4
  229. data/spec/routing/ownership_transfers_route_spec.rb +1 -1
  230. data/spec/routing/route_spec.rb +89 -89
  231. data/spec/services/generic_file_audit_service_spec.rb +8 -8
  232. data/spec/services/repository_audit_service_spec.rb +7 -3
  233. data/spec/spec_helper.rb +5 -4
  234. data/spec/support/features/session_helpers.rb +1 -1
  235. data/spec/support/input_support.rb +1 -2
  236. data/spec/support/rake.rb +1 -1
  237. data/spec/support/selectors.rb +1 -6
  238. data/spec/support/statistic_helper.rb +1 -1
  239. data/spec/support/uploaded_file_monkeypatch.rb +1 -1
  240. data/spec/tasks/rake_spec.rb +3 -5
  241. data/spec/views/admin/stats/index.html.erb_spec.rb +16 -16
  242. data/spec/views/batch/edit.html.erb_spec.rb +1 -3
  243. data/spec/views/batch_edits/check_all_spec.rb +5 -5
  244. data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -3
  245. data/spec/views/catalog/index.html.erb_spec.rb +1 -3
  246. data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +4 -5
  247. data/spec/views/collections/_form.html.erb_spec.rb +5 -3
  248. data/spec/views/collections/_show_descriptions.html.erb_spec.rb +7 -8
  249. data/spec/views/collections/_show_document_list.erb_spec.rb +4 -6
  250. data/spec/views/dashboard/index_spec.rb +14 -21
  251. data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +2 -2
  252. data/spec/views/generic_file/_permission_form.html.erb_spec.rb +8 -9
  253. data/spec/views/generic_file/edit.html.erb_spec.rb +7 -7
  254. data/spec/views/generic_file/show.html.erb_spec.rb +24 -25
  255. data/spec/views/generic_file/stats.html.erb_spec.rb +19 -19
  256. data/spec/views/homepage/_announcement.html.erb_spec.rb +51 -0
  257. data/spec/views/homepage/_featured_works.html.erb_spec.rb +5 -9
  258. data/spec/views/homepage/_home_header.html.erb_spec.rb +2 -2
  259. data/spec/views/my/facet.html.erb_spec.rb +4 -4
  260. data/spec/views/single_use_links/new_download.html.erb_spec.rb +28 -0
  261. data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +29 -0
  262. data/spec/views/users/_follower_modal.html.erb_spec.rb +7 -8
  263. data/spec/views/users/_following_modal.html.erb_spec.rb +4 -5
  264. data/spec/views/users/_notify_number.html.erb_spec.rb +2 -5
  265. data/spec/views/users/_user_util_links.html.erb_spec.rb +5 -8
  266. data/spec/views/users/index.html.erb_spec.rb +4 -6
  267. data/spec/views/users/show.html.erb_spec.rb +4 -7
  268. data/tasks/sufia-dev.rake +19 -3
  269. metadata +20 -5
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe DashboardController, :type => :controller do
3
+ describe DashboardController, type: :controller do
4
4
  context "with an unauthenticated user" do
5
5
  it "redirects to sign-in page" do
6
6
  get :index
@@ -36,11 +36,11 @@ describe DashboardController, :type => :controller do
36
36
  let(:another_user) { FactoryGirl.find_or_create(:archivist) }
37
37
  context 'when incoming' do
38
38
  let!(:incoming_file) do
39
- GenericFile.new.tap do |f|
40
- f.apply_depositor_metadata(another_user.user_key)
41
- f.save!
42
- f.request_transfer_to(user)
43
- end
39
+ GenericFile.new.tap do |f|
40
+ f.apply_depositor_metadata(another_user.user_key)
41
+ f.save!
42
+ f.request_transfer_to(user)
43
+ end
44
44
  end
45
45
 
46
46
  it 'assigns an instance variable' do
@@ -53,11 +53,11 @@ describe DashboardController, :type => :controller do
53
53
 
54
54
  context 'when outgoing' do
55
55
  let!(:outgoing_file) do
56
- GenericFile.new.tap do |f|
57
- f.apply_depositor_metadata(user.user_key)
58
- f.save!
59
- f.request_transfer_to(another_user)
60
- end
56
+ GenericFile.new.tap do |f|
57
+ f.apply_depositor_metadata(user.user_key)
58
+ f.save!
59
+ f.request_transfer_to(another_user)
60
+ end
61
61
  end
62
62
 
63
63
  it 'assigns an instance variable' do
@@ -74,7 +74,7 @@ describe DashboardController, :type => :controller do
74
74
 
75
75
  before do
76
76
  allow(activity).to receive(:map).and_return(activity)
77
- allow_any_instance_of(User).to receive(:get_all_user_activity).and_return(activity)
77
+ allow_any_instance_of(User).to receive(:all_user_activity).and_return(activity)
78
78
  end
79
79
 
80
80
  it "gathers the user's recent activity within the default amount of time" do
@@ -10,13 +10,13 @@ describe DepositorsController do
10
10
  end
11
11
 
12
12
  describe "create" do
13
- it "should be successful" do
14
- expect { post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(1)
13
+ it "is successful" do
14
+ expect { post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(1)
15
15
  expect(response).to be_success
16
16
  end
17
17
 
18
- it "should not add current user" do
19
- expect { post :create, user_id: user.user_key, grantee_id: user.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(0)
18
+ it "does not add current user" do
19
+ expect { post :create, user_id: user.user_key, grantee_id: user.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(0)
20
20
  expect(response).to be_success
21
21
  expect(response.body).to be_blank
22
22
  end
@@ -26,8 +26,8 @@ describe DepositorsController do
26
26
  before do
27
27
  user.can_receive_deposits_from << grantee
28
28
  end
29
- it "should be successful" do
30
- expect { delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(-1)
29
+ it "is successful" do
30
+ expect { delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(-1)
31
31
  end
32
32
  end
33
33
  end
@@ -37,14 +37,14 @@ describe DepositorsController do
37
37
  sign_in FactoryGirl.create(:curator)
38
38
  end
39
39
  describe "create" do
40
- it "should not be successful" do
40
+ it "is not successful" do
41
41
  post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json'
42
42
  expect(response).to redirect_to root_path
43
43
  expect(flash[:alert]).to eq "You are not authorized to access this page."
44
44
  end
45
45
  end
46
46
  describe "destroy" do
47
- it "should not be successful" do
47
+ it "is not successful" do
48
48
  delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json'
49
49
  expect(response).to redirect_to root_path
50
50
  expect(flash[:alert]).to eq "You are not authorized to access this page."
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe DownloadsController, :type => :controller do
4
-
3
+ describe DownloadsController, type: :controller do
5
4
  describe "with a file" do
6
5
  let(:depositor) { FactoryGirl.find_or_create(:archivist) }
7
6
  let(:file) do
@@ -26,9 +25,9 @@ describe DownloadsController, :type => :controller do
26
25
  let(:expected_datastream) { object.content }
27
26
  let(:expected_content) { expected_datastream.content }
28
27
 
29
- it "should default to returning configured default download" do
30
- expect(DownloadsController.default_file_path).to eq "content"
31
- expect(controller).to receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
28
+ it "defaults to returning configured default download" do
29
+ expect(described_class.default_file_path).to eq "content"
30
+ expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: 'inline', type: 'image/png')
32
31
  get "show", id: file
33
32
  expect(response).to be_success
34
33
  expect(response.body).to eq expected_content
@@ -41,22 +40,22 @@ describe DownloadsController, :type => :controller do
41
40
  file.save!
42
41
  end
43
42
 
44
- it "should return requested datastreams" do
43
+ it "returns requested datastreams" do
45
44
  get "show", id: file, file: "characterization"
46
45
  expect(response).to be_success
47
46
  expect(response.body).to eq expected_content
48
47
  end
49
48
  end
50
49
 
51
- it "should support setting disposition to inline" do
52
- expect(controller).to receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
50
+ it "supports setting disposition to inline" do
51
+ expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: 'inline', type: 'image/png')
53
52
  get "show", id: file, disposition: "inline"
54
53
  expect(response.body).to eq expected_content
55
54
  expect(response).to be_success
56
55
  end
57
56
 
58
- it "should allow you to specify filename for download" do
59
- expect(controller).to receive(:send_file_headers!).with({filename: 'my%20dog.png', disposition: 'inline', type: 'image/png' })
57
+ it "allows you to specify filename for download" do
58
+ expect(controller).to receive(:send_file_headers!).with(filename: 'my%20dog.png', disposition: 'inline', type: 'image/png')
60
59
  get "show", id: file, "filename" => "my%20dog.png"
61
60
  expect(response.body).to eq expected_content
62
61
  expect(response).to be_success
@@ -70,7 +69,7 @@ describe DownloadsController, :type => :controller do
70
69
  end
71
70
 
72
71
  describe "show" do
73
- it "should deny access" do
72
+ it "denies access" do
74
73
  get "show", id: file
75
74
  expect(response).to redirect_to root_path
76
75
  expect(flash[:alert]).to eq 'You are not authorized to access this page.'
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FeaturedWorkListsController, :type => :controller do
3
+ describe FeaturedWorkListsController, type: :controller do
4
4
  describe "#create" do
5
5
  before do
6
6
  expect(controller).to receive(:authorize!).with(:update, FeaturedWork)
@@ -9,10 +9,10 @@ describe FeaturedWorkListsController, :type => :controller do
9
9
  let(:feature1) { FactoryGirl.create(:featured_work) }
10
10
  let(:feature2) { FactoryGirl.create(:featured_work) }
11
11
 
12
- it "should be successful" do
12
+ it "is successful" do
13
13
  post :create, format: :json, featured_work_list: {
14
- featured_works_attributes: [{id: feature1.id, order: "2"},
15
- {id: feature2.id, order: "1"}]
14
+ featured_works_attributes: [{ id: feature1.id, order: "2" },
15
+ { id: feature2.id, order: "1" }]
16
16
  }
17
17
  expect(feature1.reload.order).to eq 2
18
18
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FeaturedWorksController, :type => :controller do
3
+ describe FeaturedWorksController, type: :controller do
4
4
  describe "#create" do
5
5
  before do
6
6
  sign_in FactoryGirl.create(:user)
@@ -8,10 +8,10 @@ describe FeaturedWorksController, :type => :controller do
8
8
  end
9
9
 
10
10
  context "when there are no featured works" do
11
- it "should create one" do
12
- expect {
11
+ it "creates one" do
12
+ expect do
13
13
  post :create, id: '1234abcd', format: :json
14
- }.to change { FeaturedWork.count}.by(1)
14
+ end.to change { FeaturedWork.count }.by(1)
15
15
  expect(response).to be_successful
16
16
  end
17
17
  end
@@ -19,20 +19,19 @@ describe FeaturedWorksController, :type => :controller do
19
19
  context "when there are 5 featured works" do
20
20
  before do
21
21
  5.times do |n|
22
- FeaturedWork.create(generic_file_id:n.to_s)
22
+ FeaturedWork.create(generic_file_id: n.to_s)
23
23
  end
24
24
  end
25
- it "should not create another" do
26
- expect {
25
+ it "does not create another" do
26
+ expect do
27
27
  post :create, id: '1234abcd', format: :json
28
- }.to_not change { FeaturedWork.count}
28
+ end.to_not change { FeaturedWork.count }
29
29
  expect(response.status).to eq 422
30
30
  end
31
31
  end
32
32
  end
33
33
 
34
34
  describe "#destroy" do
35
-
36
35
  let!(:featured_work) { FactoryGirl.create(:featured_work, generic_file_id: '1234abcd') }
37
36
 
38
37
  before do
@@ -40,10 +39,10 @@ describe FeaturedWorksController, :type => :controller do
40
39
  expect(controller).to receive(:authorize!).with(:destroy, FeaturedWork).and_return(true)
41
40
  end
42
41
 
43
- it "should remove it" do
44
- expect {
42
+ it "removes it" do
43
+ expect do
45
44
  delete :destroy, id: '1234abcd', format: :json
46
- }.to change { FeaturedWork.count}.by(-1)
45
+ end.to change { FeaturedWork.count }.by(-1)
47
46
  expect(response.status).to eq 204
48
47
  end
49
48
  end
@@ -15,14 +15,14 @@ describe GenericFilesController do
15
15
  let(:mock) { GenericFile.new(id: 'test123') }
16
16
  let(:batch) { Batch.create }
17
17
  let(:batch_id) { batch.id }
18
- let(:file) { fixture_file_upload('/world.png','image/png') }
18
+ let(:file) { fixture_file_upload('/world.png', 'image/png') }
19
19
 
20
20
  before do
21
21
  allow(GenericFile).to receive(:new).and_return(mock)
22
22
  end
23
23
 
24
- it "should record on_behalf_of" do
25
- file = fixture_file_upload('/world.png','image/png')
24
+ it "records on_behalf_of" do
25
+ file = fixture_file_upload('/world.png', 'image/png')
26
26
  xhr :post, :create, files: [file], Filename: 'The world', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'
27
27
  expect(response).to be_success
28
28
  saved_file = GenericFile.find('test123')
@@ -32,8 +32,8 @@ describe GenericFilesController do
32
32
  context "when the file submitted isn't a file" do
33
33
  let(:file) { 'hello' }
34
34
 
35
- it "should render 422 error" do
36
- xhr :post, :create, files: [file], Filename: "The World", batch_id: 'sample_batch_id', permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
35
+ it "renders 422 error" do
36
+ xhr :post, :create, files: [file], Filename: "The World", batch_id: 'sample_batch_id', permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
37
37
  expect(response.status).to eq 422
38
38
  expect(JSON.parse(response.body).first['error']).to match(/no file for upload/i)
39
39
  end
@@ -43,18 +43,18 @@ describe GenericFilesController do
43
43
  render_views
44
44
  it "spawns a content deposit event job" do
45
45
  expect_any_instance_of(Sufia::GenericFile::Actor).to receive(:create_content).with(file, 'world.png', 'content', 'image/png').and_return(true)
46
- xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: {group: { public: 'read' } }, terms_of_service: '1'
46
+ xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: { group: { public: 'read' } }, terms_of_service: '1'
47
47
  expect(response.body).to eq '[{"name":null,"size":null,"url":"/files/test123","thumbnail_url":"test123","delete_url":"deleteme","delete_type":"DELETE"}]'
48
48
  expect(flash[:error]).to be_nil
49
49
  end
50
50
 
51
- it "should create and save a file asset from the given params" do
51
+ it "creates and save a file asset from the given params" do
52
52
  date_today = DateTime.now
53
53
  allow(DateTime).to receive(:now).and_return(date_today)
54
- expect {
54
+ expect do
55
55
  xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id,
56
- permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
57
- }.to change { GenericFile.count }.by(1)
56
+ permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
57
+ end.to change { GenericFile.count }.by(1)
58
58
  expect(response).to be_success
59
59
 
60
60
  saved_file = GenericFile.find('test123')
@@ -62,19 +62,19 @@ describe GenericFilesController do
62
62
  # This is confirming that the correct file was attached
63
63
  expect(saved_file.label).to eq 'world.png'
64
64
  file.rewind
65
- expect(saved_file.content.content).to eq (file.read)
65
+ expect(saved_file.content.content).to eq(file.read)
66
66
  # Confirming that date_uploaded and date_modified were set
67
67
  expect(saved_file.date_uploaded).to eq date_today.new_offset(0)
68
68
  expect(saved_file.date_modified).to eq date_today.new_offset(0)
69
69
  end
70
70
 
71
- it "should record what user created the first version of content" do
72
- xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
71
+ it "records what user created the first version of content" do
72
+ xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
73
73
  expect(VersionCommitter.pluck(:committer_login).last).to eq user.user_key
74
74
  end
75
75
 
76
- it "should set the depositor id" do
77
- xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
76
+ it "sets the depositor id" do
77
+ xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
78
78
  expect(response).to be_success
79
79
 
80
80
  saved_file = GenericFile.find('test123')
@@ -87,18 +87,18 @@ describe GenericFilesController do
87
87
  context "when the file has a virus" do
88
88
  it "displays a flash error when file has a virus" do
89
89
  expect(Sufia::GenericFile::Actor).to receive(:virus_check).with(file.path).and_raise(Sufia::VirusFoundError.new('A virus was found'))
90
- xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
90
+ xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
91
91
  expect(flash[:error]).not_to be_blank
92
92
  expect(flash[:error]).to include('A virus was found')
93
93
  end
94
94
  end
95
95
 
96
96
  context "when solr continuously has errors" do
97
- it "should error out of create and save after on continuos rsolr error" do
98
- allow_any_instance_of(GenericFile).to receive(:save).and_raise(RSolr::Error::Http.new({},{}))
97
+ it "errors out of create and save after on continuos rsolr error" do
98
+ allow_any_instance_of(GenericFile).to receive(:save).and_raise(RSolr::Error::Http.new({}, {}))
99
99
 
100
- file = fixture_file_upload('/world.png','image/png')
101
- xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
100
+ file = fixture_file_upload('/world.png', 'image/png')
101
+ xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
102
102
  expect(response.body).to include("Error occurred while creating generic file.")
103
103
  end
104
104
  end
@@ -109,100 +109,130 @@ describe GenericFilesController do
109
109
  let(:batch_id) { batch.id }
110
110
 
111
111
  before do
112
- @json_from_browse_everything = {"0"=>{"url"=>"https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt", "expires"=>"2014-03-31T20:37:36.214Z", "file_name"=>"filepicker-demo.txt.txt"}, "1"=>{"url"=>"https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "expires"=>"2014-03-31T20:37:36.731Z", "file_name"=>"Getting+Started.pdf"}}
112
+ @json_from_browse_everything = { "0" => { "url" => "https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt", "expires" => "2014-03-31T20:37:36.214Z", "file_name" => "filepicker-demo.txt.txt" }, "1" => { "url" => "https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "expires" => "2014-03-31T20:37:36.731Z", "file_name" => "Getting+Started.pdf" } }
113
113
  end
114
- it "should ingest files from provide URLs" do
115
- expect(ImportUrlJob).to receive(:new).twice {"ImportJob"}
114
+ it "ingests files from provide URLs" do
115
+ expect(ImportUrlJob).to receive(:new).twice { "ImportJob" }
116
116
  expect(Sufia.queue).to receive(:push).with("ImportJob").twice
117
117
  expect { post :create, selected_files: @json_from_browse_everything, batch_id: batch_id }.to change(GenericFile, :count).by(2)
118
118
  created_files = GenericFile.all
119
119
  ["https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt"].each do |url|
120
- expect(created_files.map {|f| f.import_url}).to include(url)
120
+ expect(created_files.map(&:import_url)).to include(url)
121
121
  end
122
- ["filepicker-demo.txt.txt","Getting+Started.pdf"].each do |filename|
123
- expect(created_files.map {|f| f.label}).to include(filename)
122
+ ["filepicker-demo.txt.txt", "Getting+Started.pdf"].each do |filename|
123
+ expect(created_files.map(&:label)).to include(filename)
124
124
  end
125
125
  end
126
126
  end
127
127
 
128
128
  context "with local_file" do
129
- let(:mock_url) {"http://example.com"}
129
+ let(:mock_url) { "http://example.com" }
130
130
  let(:mock_upload_directory) { 'spec/mock_upload_directory' }
131
131
  let(:batch) { Batch.create }
132
132
  let(:batch_id) { batch.id }
133
133
 
134
- before do
135
- Sufia.config.enable_local_ingest = true
136
- FileUtils.mkdir_p([File.join(mock_upload_directory, "import/files"), File.join(mock_upload_directory, "import/metadata")])
137
- FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
138
- FileUtils.copy(File.expand_path('../../fixtures/image.jpg', __FILE__), mock_upload_directory)
139
- FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(mock_upload_directory, "import/metadata"))
140
- FileUtils.copy(File.expand_path('../../fixtures/icons.zip', __FILE__), File.join(mock_upload_directory, "import/files"))
141
- FileUtils.copy(File.expand_path('../../fixtures/Example.ogg', __FILE__), File.join(mock_upload_directory, "import/files"))
142
- end
143
-
144
- after do
145
- Sufia.config.enable_local_ingest = false
146
- allow_any_instance_of(FileContentDatastream).to receive(:live?).and_return(true)
147
- end
148
-
149
134
  context "when User model defines a directory path" do
150
135
  before do
136
+ Sufia.config.enable_local_ingest = true
137
+ FileUtils.mkdir_p([File.join(mock_upload_directory, "import/files"), File.join(mock_upload_directory, "import/metadata")])
138
+ FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
139
+ FileUtils.copy(File.expand_path('../../fixtures/image.jpg', __FILE__), mock_upload_directory)
140
+ FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(mock_upload_directory, "import/metadata"))
141
+ FileUtils.copy(File.expand_path('../../fixtures/icons.zip', __FILE__), File.join(mock_upload_directory, "import/files"))
142
+ FileUtils.copy(File.expand_path('../../fixtures/Example.ogg', __FILE__), File.join(mock_upload_directory, "import/files"))
143
+
151
144
  allow_any_instance_of(User).to receive(:directory).and_return(mock_upload_directory)
152
145
  end
153
146
 
154
- it "should ingest files from the filesystem" do
155
- expect {
156
- post :create, local_file: ["world.png", "image.jpg"], batch_id: batch_id
157
- }.to change(GenericFile, :count).by(2)
147
+ after do
148
+ Sufia.config.enable_local_ingest = false
149
+ allow_any_instance_of(FileContentDatastream).to receive(:live?).and_return(true)
150
+ FileUtils.remove_dir(File.join(mock_upload_directory, "import/files"), true)
151
+ FileUtils.remove_dir(File.join(mock_upload_directory, "import/metadata"), true)
152
+ end
153
+
154
+ let!(:actor) { Sufia::GenericFile::Actor.new(nil, nil) }
155
+
156
+ it "ingests files from the filesystem" do
157
+ # no need to save the files to fedora we justwant to know they were created
158
+ allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
159
+
160
+ # allow random GenericFiles to be created
161
+ allow(GenericFile).to receive(:new).with({}).and_call_original
162
+
163
+ # expect each file to be created
164
+ expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
165
+ expect(GenericFile).to receive(:new).with(label: "image.jpg").and_call_original
166
+
167
+ # expect metadata to be appplied to each file
168
+ expect(Sufia::GenericFile::Actor).to receive(:new).exactly(2).times.and_return(actor)
169
+ expect(actor).to receive(:create_metadata).exactly(2).times
170
+
171
+ # expect each file to be ingested
172
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
173
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "image.jpg", user.user_key)
174
+ expect(Sufia.queue).to receive(:push).exactly(2).times
175
+
176
+ post :create, local_file: ["world.png", "image.jpg"], batch_id: batch_id
177
+
158
178
  expect(response).to redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path(batch_id)
159
- # These files should have been moved out of the upload directory
160
- expect(File).not_to exist("#{mock_upload_directory}/image.jpg")
161
- expect(File).not_to exist("#{mock_upload_directory}/world.png")
162
- # And into the storage directory
163
- files = Batch.find(batch_id).generic_files
164
- expect(files.first.label).to eq('world.png')
165
- expect(files.to_a.map(&:label)).to eq ['world.png', 'image.jpg']
166
179
  end
167
180
 
168
- it "should ingest redirect to another location" do
169
- expect(GenericFilesController).to receive(:upload_complete_path).and_return(mock_url)
170
- expect {
171
- post :create, local_file: ["world.png"], batch_id: batch_id
172
- }.to change(GenericFile, :count).by(1)
181
+ it "ingests redirect to another location" do
182
+ # no need to save the files to fedora we justwant to know they were created
183
+ allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
184
+
185
+ # allow random GenericFiles to be created
186
+ allow(GenericFile).to receive(:new).with({}).and_call_original
187
+
188
+ # expect each file to be created
189
+ expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
190
+
191
+ # expect metadata to be appplied to each file
192
+ expect(Sufia::GenericFile::Actor).to receive(:new).exactly(1).times.and_return(actor)
193
+ expect(actor).to receive(:create_metadata).exactly(1).times
194
+
195
+ # expect each file to be ingested
196
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
197
+ expect(Sufia.queue).to receive(:push).exactly(1).times
198
+ expect(described_class).to receive(:upload_complete_path).and_return(mock_url)
199
+
200
+ post :create, local_file: ["world.png"], batch_id: batch_id
173
201
  expect(response).to redirect_to mock_url
174
- # These files should have been moved out of the upload directory
175
- expect(File).not_to exist("#{mock_upload_directory}/world.png")
176
- # And into the storage directory
177
- files = Batch.find(batch_id).generic_files
178
- expect(files.first.label).to eq 'world.png'
179
202
  end
180
203
 
181
- it "should ingest directories from the filesystem" do
182
- expect {
183
- post :create, local_file: ["world.png", "import"], batch_id: batch_id
184
- }.to change(GenericFile, :count).by(4)
185
- expect(response).to redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path(batch_id)
186
- # These files should have been moved out of the upload directory
187
- expect(File).not_to exist("#{mock_upload_directory}/import/files/icons.zip")
188
- expect(File).not_to exist("#{mock_upload_directory}/import/metadata/dublin_core_rdf_descMetadata.nt")
189
- expect(File).not_to exist("#{mock_upload_directory}/world.png")
190
- # And into the storage directory
191
- files = Batch.find(batch_id).generic_files
192
- expect(files.first.label).to eq 'world.png'
193
- # TODO: use files.select once projecthydra/active_fedora#609 is fixed
194
- ['icons.zip', 'Example.ogg'].each do |filename|
195
- expect(files.map { |f| f.relative_path if f.label.match(filename) }.compact.first).to eq "import/files/#{filename}"
196
- end
197
- expect(files.map { |f| f.relative_path if f.label.match("dublin_core_rdf_descMetadata.nt") }.compact.first).to eq 'import/metadata/dublin_core_rdf_descMetadata.nt'
204
+ it "ingests directories from the filesystem" do
205
+ # no need to save the files to fedora we justwant to know they were created
206
+ allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
207
+
208
+ # allow random GenericFiles to be created
209
+ allow(GenericFile).to receive(:new).with({}).and_call_original
210
+
211
+ # expect each file to be created
212
+ expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
213
+ expect(GenericFile).to receive(:new).with(label: "icons.zip").and_call_original
214
+ expect(GenericFile).to receive(:new).with(label: "Example.ogg").and_call_original
215
+ expect(GenericFile).to receive(:new).with(label: "dublin_core_rdf_descMetadata.nt").and_call_original
216
+
217
+ # expect metadata to be appplied to each file
218
+ expect(Sufia::GenericFile::Actor).to receive(:new).exactly(4).times.and_return(actor)
219
+ expect(actor).to receive(:create_metadata).exactly(4).times
220
+
221
+ # expect each file to be ingested
222
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
223
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/files/icons.zip", user.user_key)
224
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/files/Example.ogg", user.user_key)
225
+ expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/metadata/dublin_core_rdf_descMetadata.nt", user.user_key)
226
+ expect(Sufia.queue).to receive(:push).exactly(4).times
227
+ post :create, local_file: ["world.png", "import"], batch_id: batch_id
198
228
  end
199
229
  end
200
230
 
201
231
  context "when User model does not define directory path" do
202
- it "should return an error message and redirect to file upload page" do
203
- expect {
232
+ it "returns an error message and redirect to file upload page" do
233
+ expect do
204
234
  post :create, local_file: ["world.png", "image.jpg"], batch_id: batch_id
205
- }.to_not change(GenericFile, :count)
235
+ end.to_not change(GenericFile, :count)
206
236
  expect(response).to render_template :new
207
237
  expect(flash[:alert]).to eq 'Your account is not configured for importing files from a user-directory on the server.'
208
238
  end
@@ -218,7 +248,7 @@ describe GenericFilesController do
218
248
  end
219
249
  end
220
250
 
221
- it "should return json with the result" do
251
+ it "returns json with the result" do
222
252
  xhr :post, :audit, id: generic_file
223
253
  expect(response).to be_success
224
254
  json = JSON.parse(response.body)
@@ -238,11 +268,11 @@ describe GenericFilesController do
238
268
  allow(ContentDeleteEventJob).to receive(:new).with(generic_file.id, user.user_key).and_return(delete_message)
239
269
  end
240
270
  let(:delete_message) { double('delete message') }
241
- it "should delete the file" do
271
+ it "deletes the file" do
242
272
  expect(Sufia.queue).to receive(:push).with(delete_message)
243
- expect {
273
+ expect do
244
274
  delete :destroy, id: generic_file
245
- }.to change { GenericFile.exists?(generic_file.id) }.from(true).to(false)
275
+ end.to change { GenericFile.exists?(generic_file.id) }.from(true).to(false)
246
276
  end
247
277
 
248
278
  context "when the file is featured" do
@@ -250,7 +280,7 @@ describe GenericFilesController do
250
280
  FeaturedWork.create(generic_file_id: generic_file.id)
251
281
  expect(Sufia.queue).to receive(:push).with(delete_message)
252
282
  end
253
- it "should make the file not featured" do
283
+ it "makes the file not featured" do
254
284
  expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to include(generic_file.id)
255
285
  delete :destroy, id: generic_file.id
256
286
  expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to_not include(generic_file.id)
@@ -270,11 +300,11 @@ describe GenericFilesController do
270
300
  sign_in user
271
301
  mock_query = double('query')
272
302
  allow(mock_query).to receive(:for_path).and_return([
273
- OpenStruct.new(date: '2014-01-01', pageviews: 4),
274
- OpenStruct.new(date: '2014-01-02', pageviews: 8),
275
- OpenStruct.new(date: '2014-01-03', pageviews: 6),
276
- OpenStruct.new(date: '2014-01-04', pageviews: 10),
277
- OpenStruct.new(date: '2014-01-05', pageviews: 2)])
303
+ OpenStruct.new(date: '2014-01-01', pageviews: 4),
304
+ OpenStruct.new(date: '2014-01-02', pageviews: 8),
305
+ OpenStruct.new(date: '2014-01-03', pageviews: 6),
306
+ OpenStruct.new(date: '2014-01-04', pageviews: 10),
307
+ OpenStruct.new(date: '2014-01-05', pageviews: 2)])
278
308
  allow(mock_query).to receive(:map).and_return(mock_query.for_path.map(&:marshal_dump))
279
309
  profile = double('profile')
280
310
  allow(profile).to receive(:sufia__pageview).and_return(mock_query)
@@ -331,7 +361,7 @@ describe GenericFilesController do
331
361
  end
332
362
  end
333
363
 
334
- it "should set the breadcrumbs and versions presenter" do
364
+ it "sets the breadcrumbs and versions presenter" do
335
365
  allow(controller.request).to receive(:referer).and_return('foo')
336
366
  expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
337
367
  expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
@@ -359,10 +389,10 @@ describe GenericFilesController do
359
389
  allow(ContentUpdateEventJob).to receive(:new).with(generic_file.id, 'jilluser@example.com').and_return(update_message)
360
390
  end
361
391
 
362
- it "should spawn a content update event job" do
392
+ it "spawns a content update event job" do
363
393
  expect(Sufia.queue).to receive(:push).with(update_message)
364
394
  post :update, id: generic_file, generic_file: { title: ['new_title'], tag: [''],
365
- permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit'}] }
395
+ permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }] }
366
396
  end
367
397
 
368
398
  it "spawns a content new version event job" do
@@ -374,7 +404,7 @@ describe GenericFilesController do
374
404
  allow(CharacterizeJob).to receive(:new).with(generic_file.id).and_return(s2)
375
405
  expect(Sufia.queue).to receive(:push).with(s2).once
376
406
  file = fixture_file_upload('/world.png', 'image/png')
377
- post :update, id: generic_file, filedata: file, generic_file: {tag: [''], permissions: { new_user_name: {archivist1: 'edit' } } }
407
+ post :update, id: generic_file, filedata: file, generic_file: { tag: [''], permissions: { new_user_name: { archivist1: 'edit' } } }
378
408
  end
379
409
  end
380
410
 
@@ -389,13 +419,12 @@ describe GenericFilesController do
389
419
  expect(Sufia.queue).to receive(:push).with(s2).once
390
420
 
391
421
  file = fixture_file_upload('/world.png', 'image/png')
392
- post :update, id: generic_file, filedata: file, generic_file: {tag: [''],
393
- permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit'}] }
422
+ post :update, id: generic_file, filedata: file, generic_file: { tag: [''],
423
+ permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit' }] }
394
424
  end
395
425
  end
396
426
 
397
427
  context "with two existing versions from different users" do
398
-
399
428
  let(:file1) { "world.png" }
400
429
  let(:file1_type) { "image/png" }
401
430
  let(:file2) { "image.jpg" }
@@ -422,7 +451,7 @@ describe GenericFilesController do
422
451
  let(:versions) { restored_content.versions }
423
452
  let(:latest_version) { restored_content.latest_version }
424
453
 
425
- it "should restore the first versions's content and metadata" do
454
+ it "restores the first versions's content and metadata" do
426
455
  expect(restored_content.mime_type).to eq file1_type
427
456
  expect(restored_content.original_name).to eq file1
428
457
  expect(versions.all.count).to eq 3
@@ -435,7 +464,7 @@ describe GenericFilesController do
435
464
  before do
436
465
  sign_in second_user
437
466
  end
438
- it "should not create a new version" do
467
+ it "does not create a new version" do
439
468
  post :update, id: generic_file, revision: version1
440
469
  expect(response).to be_redirect
441
470
  end
@@ -443,27 +472,27 @@ describe GenericFilesController do
443
472
  end
444
473
  end
445
474
 
446
- it "should add new groups and users" do
475
+ it "adds new groups and users" do
447
476
  post :update, id: generic_file,
448
- generic_file: { tag: [''],
449
- permissions_attributes: [
450
- { type: 'person', name: 'user1', access: 'edit' },
451
- { type: 'group', name: 'group1', access: 'read' }
452
- ]
477
+ generic_file: { tag: [''],
478
+ permissions_attributes: [
479
+ { type: 'person', name: 'user1', access: 'edit' },
480
+ { type: 'group', name: 'group1', access: 'read' }
481
+ ]
453
482
  }
454
483
 
455
484
  expect(assigns[:generic_file].read_groups).to eq ["group1"]
456
485
  expect(assigns[:generic_file].edit_users).to include("user1", user.user_key)
457
486
  end
458
487
 
459
- it "should update existing groups and users" do
488
+ it "updates existing groups and users" do
460
489
  generic_file.edit_groups = ['group3']
461
490
  generic_file.save
462
491
  post :update, id: generic_file,
463
- generic_file: { tag: [''],
464
- permissions_attributes: [
465
- { id: generic_file.permissions.last.id, type: 'group', name: 'group3', access: 'read'}
466
- ]
492
+ generic_file: { tag: [''],
493
+ permissions_attributes: [
494
+ { id: generic_file.permissions.last.id, type: 'group', name: 'group3', access: 'read' }
495
+ ]
467
496
  }
468
497
 
469
498
  expect(assigns[:generic_file].read_groups).to eq(["group3"])
@@ -481,8 +510,8 @@ describe GenericFilesController do
481
510
  expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
482
511
  expect(Sufia.queue).to receive(:push).with(s2).once
483
512
  post :update, id: generic_file.id, filedata: file, 'Filename' => 'The world',
484
- generic_file: { tag: [''],
485
- permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit' }] }
513
+ generic_file: { tag: [''],
514
+ permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit' }] }
486
515
  end
487
516
 
488
517
  context "when there's an error saving" do
@@ -493,7 +522,7 @@ describe GenericFilesController do
493
522
  end
494
523
  it "redirects to edit" do
495
524
  expect_any_instance_of(GenericFile).to receive(:valid?).and_return(false)
496
- post :update, id: generic_file, generic_file: {:tag=>['']}
525
+ post :update, id: generic_file, generic_file: { tag: [''] }
497
526
  expect(response).to be_successful
498
527
  expect(response).to render_template('edit')
499
528
  expect(assigns[:generic_file]).to eq generic_file
@@ -513,7 +542,7 @@ describe GenericFilesController do
513
542
  end
514
543
 
515
544
  describe "edit" do
516
- it "should give me a flash error" do
545
+ it "gives me a flash error" do
517
546
  get :edit, id: generic_file
518
547
  expect(response).to redirect_to @routes.url_helpers.generic_file_path('test5')
519
548
  expect(flash[:alert]).not_to be_nil
@@ -523,7 +552,7 @@ describe GenericFilesController do
523
552
  end
524
553
 
525
554
  describe "#show" do
526
- it "should show me the file and set breadcrumbs" do
555
+ it "shows me the file and set breadcrumbs" do
527
556
  expect(GenericFile).not_to receive(:find)
528
557
  expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
529
558
  get :show, id: generic_file
@@ -541,13 +570,13 @@ describe GenericFilesController do
541
570
  end
542
571
 
543
572
  describe "flash" do
544
- it "should not let the user submit if they logout" do
573
+ it "does not let the user submit if they logout" do
545
574
  sign_out user
546
575
  get :new
547
576
  expect(response).to_not be_success
548
577
  expect(flash[:alert]).to include("You need to sign in or sign up before continuing")
549
578
  end
550
- it "should filter flash if they signin" do
579
+ it "filters flash if they signin" do
551
580
  sign_in user
552
581
  get :new
553
582
  expect(flash[:alert]).to be_nil
@@ -558,7 +587,7 @@ describe GenericFilesController do
558
587
  before do
559
588
  User.audituser.send_message(user, "Test message", "Test subject")
560
589
  end
561
- it "should display notifications" do
590
+ it "displays notifications" do
562
591
  get :new
563
592
  expect(assigns[:notify_number]).to eq 1
564
593
  expect(user.mailbox.inbox[0].messages[0].subject).to eq "Test subject"
@@ -568,16 +597,16 @@ describe GenericFilesController do
568
597
  describe "batch creation" do
569
598
  context "when uploading a file" do
570
599
  let(:batch_id) { ActiveFedora::Noid::Service.new.mint }
571
- let(:file1) { fixture_file_upload('/world.png','image/png') }
572
- let(:file2) { fixture_file_upload('/image.jpg','image/png') }
600
+ let(:file1) { fixture_file_upload('/world.png', 'image/png') }
601
+ let(:file2) { fixture_file_upload('/image.jpg', 'image/png') }
573
602
 
574
- it "should not create the batch on HTTP GET " do
603
+ it "does not create the batch on HTTP GET" do
575
604
  expect(Batch).to_not receive(:create)
576
605
  xhr :get, :new
577
606
  expect(response).to be_success
578
607
  end
579
608
 
580
- it "should create the batch on HTTP POST with multiple files" do
609
+ it "creates the batch on HTTP POST with multiple files" do
581
610
  expect(GenericFile).to receive(:new).twice
582
611
  expect(Batch).to receive(:find_or_create).twice
583
612
  xhr :post, :create, files: [file1], Filename: 'The world 1', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'