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,10 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GeoNamesResource, :type => :model do
4
-
5
- it "should find locations" do
6
- hits = GeoNamesResource.find_location("State")
3
+ describe GeoNamesResource, type: :model do
4
+ it "finds locations" do
5
+ hits = described_class.find_location("State")
7
6
  expect(hits).not_to be_nil
8
7
  end
9
8
  end
10
-
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe LocalAuthority, :type => :model do
4
-
3
+ describe LocalAuthority, type: :model do
5
4
  def harvest_nt
6
5
  LocalAuthority.harvest_rdf("genres", [fixture_path + '/genreForms.nt'])
7
6
  end
@@ -18,29 +17,28 @@ describe LocalAuthority, :type => :model do
18
17
  Object.send(:remove_const, :MyTestRdfDatastream)
19
18
  end
20
19
 
21
- it "should harvest an ntriples RDF vocab" do
20
+ it "harvests an ntriples RDF vocab" do
22
21
  harvest_nt
23
- expect(LocalAuthority.count).to eq(1)
22
+ expect(described_class.count).to eq(1)
24
23
  expect(LocalAuthorityEntry.count).to eq(6)
25
24
  end
26
- it "should harvest an RDF/XML vocab (w/ an alt predicate)" do
27
- LocalAuthority.harvest_rdf("langs", [fixture_path + '/lexvo.rdf'],
28
- format: 'rdfxml',
29
- predicate: ::RDF::URI("http://www.w3.org/2008/05/skos#prefLabel"))
30
- expect(LocalAuthority.count).to eq(1)
25
+ it "harvests an RDF/XML vocab (w/ an alt predicate)" do
26
+ described_class.harvest_rdf("langs", [fixture_path + '/lexvo.rdf'],
27
+ format: 'rdfxml',
28
+ predicate: ::RDF::URI("http://www.w3.org/2008/05/skos#prefLabel"))
29
+ expect(described_class.count).to eq(1)
31
30
  expect(LocalAuthorityEntry.count).to eq(35)
32
31
  end
33
- it "should harvest TSV vocabs" do
32
+ it "harvests TSV vocabs" do
34
33
  harvest_tsv
35
- expect(LocalAuthority.count).to eq(1)
36
- auth = LocalAuthority.where(name: "geo").first
34
+ expect(described_class.count).to eq(1)
35
+ auth = described_class.where(name: "geo").first
37
36
  expect(LocalAuthorityEntry.where(local_authority_id: auth.id).first.uri).to start_with('http://sws.geonames.org/')
38
37
  expect(LocalAuthorityEntry.count).to eq(149)
39
38
  end
40
39
 
41
40
  describe "when vocabs are harvested" do
42
-
43
- let(:num_auths) { LocalAuthority.count }
41
+ let(:num_auths) { described_class.count }
44
42
  let(:num_entries) { LocalAuthorityEntry.count }
45
43
 
46
44
  before do
@@ -48,50 +46,49 @@ describe LocalAuthority, :type => :model do
48
46
  harvest_tsv
49
47
  end
50
48
 
51
- it "should not have any initial domain terms" do
49
+ it "does not have any initial domain terms" do
52
50
  expect(DomainTerm.count).to eq(0)
53
51
  end
54
52
 
55
- it "should not harvest an RDF vocab twice" do
53
+ it "does not harvest an RDF vocab twice" do
56
54
  harvest_nt
57
- expect(LocalAuthority.count).to eq(num_auths)
55
+ expect(described_class.count).to eq(num_auths)
58
56
  expect(LocalAuthorityEntry.count).to eq(num_entries)
59
57
  end
60
- it "should not harvest a TSV vocab twice" do
58
+ it "does not harvest a TSV vocab twice" do
61
59
  harvest_tsv
62
- expect(LocalAuthority.count).to eq(num_auths)
60
+ expect(described_class.count).to eq(num_auths)
63
61
  expect(LocalAuthorityEntry.count).to eq(num_entries)
64
62
  end
65
- it "should register a vocab" do
66
- LocalAuthority.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
63
+ it "registers a vocab" do
64
+ described_class.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
67
65
  expect(DomainTerm.count).to eq(1)
68
66
  end
69
67
 
70
68
  describe "when vocabs are registered" do
71
-
72
69
  before do
73
- LocalAuthority.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
74
- LocalAuthority.register_vocabulary(MyTestRdfDatastream, "genre", "genres")
70
+ described_class.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
71
+ described_class.register_vocabulary(MyTestRdfDatastream, "genre", "genres")
75
72
  end
76
73
 
77
- it "should have some doamin terms" do
74
+ it "has some doamin terms" do
78
75
  expect(DomainTerm.count).to eq(2)
79
76
  end
80
77
 
81
- it "should return nil for empty queries" do
82
- expect(LocalAuthority.entries_by_term("my_test", "geographic", "")).to be_nil
78
+ it "returns nil for empty queries" do
79
+ expect(described_class.entries_by_term("my_test", "geographic", "")).to be_nil
83
80
  end
84
- it "should return an empty array for unregistered models" do
85
- expect(LocalAuthority.entries_by_term("my_foobar", "geographic", "E")).to eq([])
81
+ it "returns an empty array for unregistered models" do
82
+ expect(described_class.entries_by_term("my_foobar", "geographic", "E")).to eq([])
86
83
  end
87
- it "should return an empty array for unregistered terms" do
88
- expect(LocalAuthority.entries_by_term("my_test", "foobar", "E")).to eq([])
84
+ it "returns an empty array for unregistered terms" do
85
+ expect(described_class.entries_by_term("my_test", "foobar", "E")).to eq([])
89
86
  end
90
- it "should return entries by term" do
87
+ it "returns entries by term" do
91
88
  term = DomainTerm.where(model: "my_tests", term: "genre").first
92
89
  authorities = term.local_authorities.collect(&:id).uniq
93
90
  LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("label like ?", "A%").select("label, uri").limit(25)
94
- expect(LocalAuthority.entries_by_term("my_tests", "genre", "A").count).to eq(6)
91
+ expect(described_class.entries_by_term("my_tests", "genre", "A").count).to eq(6)
95
92
  end
96
93
  end
97
94
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Sufia::Pageview, :type => :model do
3
+ describe Sufia::Pageview, type: :model do
4
4
  before do
5
- @pageview = Sufia::Pageview
5
+ @pageview = described_class
6
6
  end
7
7
 
8
8
  it 'has a pageviews metric' do
9
- expect(@pageview.metrics).to be == Legato::ListParameter.new(:metrics, [:pageviews])
9
+ expect(@pageview.metrics).to be == Legato::ListParameter.new(:metrics, [:pageviews])
10
10
  end
11
11
 
12
12
  it 'has a date dimension' do
@@ -13,8 +13,8 @@ describe ProxyDepositRequest, type: :model do
13
13
  end
14
14
 
15
15
  subject do
16
- ProxyDepositRequest.new(generic_file_id: file.id, sending_user: sender,
17
- receiving_user: receiver, sender_comment: "please take this")
16
+ described_class.new(generic_file_id: file.id, sending_user: sender,
17
+ receiving_user: receiver, sender_comment: "please take this")
18
18
  end
19
19
 
20
20
  its(:status) { is_expected.to eq 'pending' }
@@ -92,7 +92,7 @@ describe ProxyDepositRequest, type: :model do
92
92
  end
93
93
 
94
94
  context 'when the file is already being transferred' do
95
- let(:subject2) {ProxyDepositRequest.new(generic_file_id: file.id, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this')}
95
+ let(:subject2) { described_class.new(generic_file_id: file.id, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this') }
96
96
 
97
97
  it 'raises an error' do
98
98
  subject.save!
@@ -10,56 +10,56 @@ describe SingleUseLink do
10
10
  let(:file) { @file }
11
11
 
12
12
  describe "create" do
13
- before do
13
+ before do
14
14
  @now = DateTime.now
15
15
  allow(DateTime).to receive(:now).and_return(@now)
16
- @hash = "sha2hash#{@now.to_f.to_s}"
16
+ @hash = "sha2hash#{@now.to_f}"
17
17
  expect(Digest::SHA2).to receive(:new).and_return(@hash)
18
- end
19
- it "should create show link" do
20
- su = SingleUseLink.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.generic_file_path(file.id)
18
+ end
19
+ it "creates show link" do
20
+ su = described_class.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.generic_file_path(file.id)
21
21
  expect(su.downloadKey).to eq(@hash)
22
22
  expect(su.itemId).to eq(file.id)
23
23
  expect(su.path).to eq(Sufia::Engine.routes.url_helpers.generic_file_path(file.id))
24
24
  su.delete
25
- end
26
- it "should create show download link" do
27
- su = SingleUseLink.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file.id)
25
+ end
26
+ it "creates show download link" do
27
+ su = described_class.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file.id)
28
28
  expect(su.downloadKey).to eq(@hash)
29
29
  expect(su.itemId).to eq(file.id)
30
30
  expect(su.path).to eq(Sufia::Engine.routes.url_helpers.download_path(file.id))
31
31
  su.delete
32
- end
32
+ end
33
33
  end
34
34
  describe "find" do
35
- describe "not expired" do
36
- before do
37
- @su = SingleUseLink.create(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file), expires: DateTime.now.advance(hours: 1))
38
- end
39
- it "should retrieve link" do
40
- link = SingleUseLink.where(downloadKey: 'sha2hashb').first
41
- expect(link.itemId).to eq(file.id)
42
- end
43
- it "should retrieve link with find_by" do
44
- link = SingleUseLink.find_by_downloadKey('sha2hashb')
45
- expect(link.itemId).to eq(file.id)
46
- end
47
- it "should expire link" do
48
- link = SingleUseLink.where(downloadKey: 'sha2hashb').first
49
- expect(link.expired?).to eq(false)
50
- end
51
- end
52
- describe "expired" do
53
- before do
54
- @su = SingleUseLink.create!(downloadKey: 'sha2hashb', itemId:file.id, path:Sufia::Engine.routes.url_helpers.download_path(file))
35
+ describe "not expired" do
36
+ before do
37
+ @su = described_class.create(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file), expires: DateTime.now.advance(hours: 1))
38
+ end
39
+ it "retrieves link" do
40
+ link = described_class.where(downloadKey: 'sha2hashb').first
41
+ expect(link.itemId).to eq(file.id)
42
+ end
43
+ it "retrieves link with find_by" do
44
+ link = described_class.find_by_downloadKey('sha2hashb')
45
+ expect(link.itemId).to eq(file.id)
46
+ end
47
+ it "expires link" do
48
+ link = described_class.where(downloadKey: 'sha2hashb').first
49
+ expect(link.expired?).to eq(false)
50
+ end
51
+ end
52
+ describe "expired" do
53
+ before do
54
+ @su = described_class.create!(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file))
55
55
 
56
- @su.update_attribute :expires, DateTime.now.advance(hours: -1)
57
- end
56
+ @su.update_attribute :expires, DateTime.now.advance(hours: -1)
57
+ end
58
58
 
59
- it "should expire link" do
60
- link = SingleUseLink.where(downloadKey: 'sha2hashb').first
61
- expect(link.expired?).to eq(true)
62
- end
63
- end
59
+ it "expires link" do
60
+ link = described_class.where(downloadKey: 'sha2hashb').first
61
+ expect(link.expired?).to eq(true)
62
+ end
63
+ end
64
64
  end
65
65
  end
@@ -1,12 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SolrDocument, type: :model do
4
-
5
4
  describe "date_uploaded" do
6
5
  before do
7
6
  subject['date_uploaded_dtsi'] = '2013-03-14T00:00:00Z'
8
7
  end
9
- it "should be a date" do
8
+ it "is a date" do
10
9
  expect(subject.date_uploaded).to eq '03/14/2013'
11
10
  end
12
11
  end
@@ -29,7 +28,7 @@ describe SolrDocument, type: :model do
29
28
  end
30
29
 
31
30
  context "when mime-type is 'office'" do
32
- it "should be office document" do
31
+ it "is office document" do
33
32
  Mimes.office_document_mime_types.each do |type|
34
33
  subject['mime_type_tesim'] = [type]
35
34
  expect(subject).to be_office_document
@@ -38,14 +37,12 @@ describe SolrDocument, type: :model do
38
37
  end
39
38
 
40
39
  describe "when mime-type is 'video'" do
41
- it "should be office" do
40
+ it "is office" do
42
41
  Mimes.video_mime_types.each do |type|
43
42
  subject['mime_type_tesim'] = [type]
44
43
  expect(subject).to be_video
45
44
  end
46
45
  end
47
46
  end
48
-
49
47
  end
50
-
51
48
  end
@@ -1,24 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Trophy, :type => :model do
3
+ describe Trophy, type: :model do
4
4
  before(:all) do
5
- @trophy = Trophy.create(user_id:99,generic_file_id:"99")
5
+ @trophy = described_class.create(user_id: 99, generic_file_id: "99")
6
6
  end
7
7
 
8
- it "should have a user" do
8
+ it "has a user" do
9
9
  expect(@trophy).to respond_to(:user_id)
10
10
  expect(@trophy.user_id).to eq(99)
11
11
  end
12
12
 
13
- it "should have a file" do
13
+ it "has a file" do
14
14
  expect(@trophy).to respond_to(:generic_file_id)
15
15
  expect(@trophy.generic_file_id).to eq("99")
16
16
  end
17
17
 
18
- it "should not allow six trophies" do
19
- (1..6).each { |n| Trophy.create(user_id:120,generic_file_id:n.to_s) }
20
- expect(Trophy.where(user_id:120).count).to eq(5)
21
- Trophy.where(user_id:120).map(&:delete)
18
+ it "does not allow six trophies" do
19
+ (1..6).each { |n| described_class.create(user_id: 120, generic_file_id: n.to_s) }
20
+ expect(described_class.where(user_id: 120).count).to eq(5)
21
+ described_class.where(user_id: 120).map(&:delete)
22
22
  end
23
23
  end
24
-
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserMailbox do
4
+ let(:user) { FactoryGirl.find_or_create(:jill) }
5
+ let(:another_user) { FactoryGirl.find_or_create(:archivist) }
6
+ before do
7
+ another_user.send_message(user, "Test Message", "Test Subject")
8
+ user.send_message(another_user, "Test Message", "Test Subject")
9
+ end
10
+
11
+ subject { described_class.new(user) }
12
+
13
+ describe "#inbox" do
14
+ subject { described_class.new(user).inbox.first.last_message }
15
+ it "has mail" do
16
+ expect(subject.body).to eq('Test Message')
17
+ expect(subject.subject).to eq('Test Subject')
18
+ expect(user.mailbox.inbox(unread: true).count).to eq(0)
19
+ end
20
+ end
21
+
22
+ describe "#delete_all" do
23
+ before do
24
+ another_user.send_message(user, 'message 2', 'subject 2')
25
+ another_user.send_message(user, 'message 3', 'subject 3')
26
+ end
27
+ it "deletes all messages" do
28
+ expect(user.mailbox.inbox.count).to eq(3)
29
+ subject.delete_all
30
+ expect(user.mailbox.inbox.count).to eq(0)
31
+ end
32
+ end
33
+
34
+ describe "#delete" do
35
+ let(:rec) { another_user.send_message(user, 'message 2', 'subject 2') }
36
+ let!(:message_id) { rec.conversation.id }
37
+
38
+ it "deletes a message" do
39
+ subject.destroy message_id
40
+ expect { Mailboxer::Conversation.find(message_id) }.to raise_error(ActiveRecord::RecordNotFound)
41
+ end
42
+
43
+ context "non-existing conversation" do
44
+ let!(:message_id) { -99 }
45
+ it "raises an error" do
46
+ expect { subject.destroy message_id }.to raise_error(ActiveRecord::RecordNotFound)
47
+ end
48
+ end
49
+
50
+ context "deleting a message from a third party" do
51
+ let(:curator) { FactoryGirl.find_or_create(:curator) }
52
+ let(:message) { another_user.send_message(curator, 'message 3', 'subject 3') }
53
+ let!(:message_id) { message.conversation.id }
54
+
55
+ it "does not delete the message" do
56
+ subject.destroy message_id
57
+ expect(subject.destroy(message_id)).to eq "You do not have privileges to delete the notification..."
58
+ expect(Mailboxer::Conversation.find(message_id).id).to eq message_id
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe User, :type => :model do
3
+ describe User, type: :model do
4
4
  let(:user) { FactoryGirl.build(:user) }
5
5
  let(:another_user) { FactoryGirl.build(:user) }
6
6
 
7
- it "should have an email" do
7
+ it "has an email" do
8
8
  expect(user.user_key).to be_kind_of String
9
9
  end
10
- it "should have activity stream-related methods defined" do
10
+ it "has activity stream-related methods defined" do
11
11
  expect(user).to respond_to(:stream)
12
12
  expect(user).to respond_to(:events)
13
13
  expect(user).to respond_to(:profile_events)
@@ -15,7 +15,7 @@ describe User, :type => :model do
15
15
  expect(user).to respond_to(:log_event)
16
16
  expect(user).to respond_to(:log_profile_event)
17
17
  end
18
- it "should have social attributes" do
18
+ it "has social attributes" do
19
19
  expect(user).to respond_to(:twitter_handle)
20
20
  expect(user).to respond_to(:facebook_handle)
21
21
  expect(user).to respond_to(:googleplus_handle)
@@ -25,7 +25,7 @@ describe User, :type => :model do
25
25
 
26
26
  describe 'Arkivo and Zotero integration' do
27
27
  it 'sets an Arkivo token after_initialize if API is enabled' do
28
- expect(User.new).to respond_to(:arkivo_token)
28
+ expect(described_class.new).to respond_to(:arkivo_token)
29
29
  end
30
30
 
31
31
  describe 'Arkivo token generation' do
@@ -37,9 +37,9 @@ describe User, :type => :model do
37
37
  let(:token2) { 'token2' }
38
38
 
39
39
  it 'generates a new token if a user is found with the existing token' do
40
- user1 = User.create(email: 'foo@example.org', password: 'foobarbaz')
40
+ user1 = described_class.create(email: 'foo@example.org', password: 'foobarbaz')
41
41
  expect(user1.arkivo_token).to eq token1
42
- user2 = User.create(email: 'bar@example.org', password: 'bazquuxquuux')
42
+ user2 = described_class.create(email: 'bar@example.org', password: 'bazquuxquuux')
43
43
  expect(user2.arkivo_token).to eq token2
44
44
  end
45
45
  end
@@ -49,7 +49,7 @@ describe User, :type => :model do
49
49
 
50
50
  it 'has a custom getter/setter for Zotero request tokens' do
51
51
  user.zotero_token = token
52
- expect(user.read_attribute(:zotero_token)).to eq Marshal::dump(token)
52
+ expect(user.read_attribute(:zotero_token)).to eq Marshal.dump(token)
53
53
  expect(user.zotero_token).to eq token
54
54
  end
55
55
  end
@@ -84,17 +84,17 @@ describe User, :type => :model do
84
84
  end
85
85
 
86
86
  describe "#to_param" do
87
- let(:user) { User.new(email: 'jilluser@example.com') }
87
+ let(:user) { described_class.new(email: 'jilluser@example.com') }
88
88
 
89
- it "should override to_param to make keys more recognizable in redis (and useable within Rails URLs)" do
89
+ it "overrides to_param to make keys more recognizable in redis (and useable within Rails URLs)" do
90
90
  expect(user.to_param).to eq("jilluser@example-dot-com")
91
91
  end
92
92
  end
93
93
 
94
- it "should have a cancan ability defined" do
94
+ it "has a cancan ability defined" do
95
95
  expect(user).to respond_to(:can?)
96
96
  end
97
- it "should not have any followers" do
97
+ it "does not have any followers" do
98
98
  expect(user.followers_count).to eq(0)
99
99
  expect(another_user.follow_count).to eq(0)
100
100
  end
@@ -105,13 +105,13 @@ describe User, :type => :model do
105
105
  user.follow(another_user)
106
106
  end
107
107
 
108
- it "should be able to follow another user" do
108
+ it "is able to follow another user" do
109
109
  expect(user).to be_following(another_user)
110
110
  expect(another_user).to_not be_following(user)
111
111
  expect(another_user).to be_followed_by(user)
112
112
  expect(user).to_not be_followed_by(another_user)
113
113
  end
114
- it "should be able to unfollow another user" do
114
+ it "is able to unfollow another user" do
115
115
  user.stop_following(another_user)
116
116
  expect(user).to_not be_following(another_user)
117
117
  expect(another_user).to_not be_followed_by(user)
@@ -127,21 +127,20 @@ describe User, :type => :model do
127
127
  let!(:trophy2) { user.trophies.create!(generic_file_id: file2.id) }
128
128
  let!(:trophy3) { user.trophies.create!(generic_file_id: file3.id) }
129
129
 
130
- it "should return a list of generic files" do
130
+ it "returns a list of generic files" do
131
131
  expect(user.trophy_files).to eq [file1, file2, file3]
132
132
  end
133
-
134
133
  end
135
134
 
136
135
  describe "activity streams" do
137
136
  let(:now) { DateTime.now.to_i }
138
- let(:activities) {
139
- [{ action: 'so and so edited their profile', timestamp: now },
140
- { action: 'so and so uploaded a file', timestamp: (now - 360 ) }]
141
- }
142
- let(:file_activities) {
137
+ let(:activities) do
138
+ [{ action: 'so and so edited their profile', timestamp: now },
139
+ { action: 'so and so uploaded a file', timestamp: (now - 360) }]
140
+ end
141
+ let(:file_activities) do
143
142
  [{ action: 'uploaded a file', timestamp: now + 1 }]
144
- }
143
+ end
145
144
 
146
145
  before do
147
146
  allow(user).to receive(:events).and_return(activities)
@@ -149,11 +148,11 @@ describe User, :type => :model do
149
148
  end
150
149
 
151
150
  it "gathers the user's recent activity within the default amount of time" do
152
- expect(user.get_all_user_activity).to eq(file_activities.concat(activities))
151
+ expect(user.all_user_activity).to eq(file_activities.concat(activities))
153
152
  end
154
153
 
155
154
  it "gathers the user's recent activity within a given timestamp" do
156
- expect(user.get_all_user_activity(now-60)).to eq(file_activities.concat([activities.first]))
155
+ expect(user.all_user_activity(now - 60)).to eq(file_activities.concat([activities.first]))
157
156
  end
158
157
  end
159
158
  describe "proxy_deposit_rights" do
@@ -174,23 +173,23 @@ describe User, :type => :model do
174
173
  end
175
174
  describe "class methods" do
176
175
  describe "recent_users" do
177
- let(:new_users) { User.all.order(created_at: :desc) }
176
+ let(:new_users) { described_class.all.order(created_at: :desc) }
178
177
 
179
178
  before do
180
- (1..3).each {|i| User.create(email: "abc#{i}@blah.frg", password: "blarg1234", created_at:DateTime.now - i.days) }
179
+ (1..3).each { |i| described_class.create(email: "abc#{i}@blah.frg", password: "blarg1234", created_at: DateTime.now - i.days) }
181
180
  end
182
181
 
183
182
  context "when has a start date" do
184
- subject { User.recent_users(Date.today - 2.days) }
183
+ subject { described_class.recent_users(Date.today - 2.days) }
185
184
  it "returns valid data" do
186
185
  expect(subject.count).to eq 2
187
- is_expected.to include(new_users[0],new_users[1])
186
+ is_expected.to include(new_users[0], new_users[1])
188
187
  is_expected.not_to include(new_users[2])
189
188
  end
190
189
  end
191
190
 
192
191
  context "when has start and end date" do
193
- subject { User.recent_users(Date.today - 2.days, Date.today - 1.days) }
192
+ subject { described_class.recent_users(Date.today - 2.days, Date.today - 1.days) }
194
193
  it "returns valid data" do
195
194
  expect(subject.count).to eq 1
196
195
  is_expected.to include(new_users[1])