sufia 5.0.0 → 6.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -8
  3. data/Gemfile +3 -12
  4. data/History.md +0 -36
  5. data/LICENSE.md +14 -0
  6. data/README.md +4 -8
  7. data/SUFIA_VERSION +1 -1
  8. data/app/assets/javascripts/sufia.js +1 -17
  9. data/app/assets/javascripts/sufia/batch_edit.js +43 -28
  10. data/app/assets/javascripts/sufia/edit_metadata.js +9 -14
  11. data/app/assets/javascripts/sufia/multiForm.js +67 -0
  12. data/app/assets/javascripts/sufia/permissions.js +92 -35
  13. data/app/assets/stylesheets/sufia.css.scss +1 -6
  14. data/app/assets/stylesheets/sufia/_batch-edit.scss +0 -8
  15. data/app/assets/stylesheets/sufia/_dashboard.scss +1 -15
  16. data/app/assets/stylesheets/sufia/_file-listing.scss +1 -1
  17. data/app/assets/stylesheets/sufia/_settings.scss +0 -1
  18. data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +3 -10
  19. data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -8
  20. data/app/controllers/concerns/sufia/catalog.rb +1 -1
  21. data/app/controllers/concerns/sufia/controller.rb +3 -1
  22. data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +1 -1
  23. data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +1 -1
  24. data/app/controllers/concerns/sufia/files_controller_behavior.rb +16 -4
  25. data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
  26. data/app/controllers/concerns/sufia/my_controller_behavior.rb +2 -2
  27. data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +3 -4
  28. data/app/controllers/concerns/sufia/users_controller_behavior.rb +2 -7
  29. data/app/controllers/my/collections_controller.rb +3 -4
  30. data/app/controllers/my/highlights_controller.rb +2 -2
  31. data/app/controllers/my/shares_controller.rb +3 -3
  32. data/app/controllers/single_use_links_controller.rb +5 -9
  33. data/app/controllers/single_use_links_viewer_controller.rb +4 -4
  34. data/app/helpers/generic_file_helper.rb +9 -0
  35. data/app/helpers/sufia/records_helper_behavior.rb +16 -0
  36. data/app/helpers/sufia/sufia_helper_behavior.rb +0 -11
  37. data/app/jobs/content_depositor_change_event_job.rb +1 -1
  38. data/app/jobs/ingest_local_file_job.rb +2 -1
  39. data/app/models/concerns/sufia/solr_document_behavior.rb +10 -10
  40. data/app/models/featured_work_list.rb +7 -9
  41. data/app/presenters/sufia/version_list_presenter.rb +15 -0
  42. data/app/presenters/sufia/version_presenter.rb +30 -0
  43. data/app/views/batch/_metadata.html.erb +51 -29
  44. data/app/views/batch/_more_metadata.html.erb +1 -1
  45. data/app/views/batch/edit.html.erb +10 -8
  46. data/app/views/batch_edits/edit.html.erb +13 -9
  47. data/app/views/collections/_edit_descriptions.html.erb +1 -1
  48. data/app/views/collections/_form.html.erb +4 -4
  49. data/app/views/collections/_form_for_select_collection.html.erb +1 -1
  50. data/app/views/collections/_show_document_list_menu.html.erb +7 -5
  51. data/app/views/collections/_show_document_list_row.html.erb +2 -2
  52. data/app/views/collections/edit.html.erb +0 -1
  53. data/app/views/collections/edit_fields/_description.html.erb +4 -0
  54. data/app/views/collections/edit_fields/_title.html.erb +3 -0
  55. data/app/views/collections/show.html.erb +0 -1
  56. data/app/views/dashboard/_index_partials/_stats.html.erb +3 -3
  57. data/app/views/generic_files/_descriptions.html.erb +9 -9
  58. data/app/views/generic_files/_field_form.html.erb +11 -25
  59. data/app/views/generic_files/_permission.html.erb +6 -4
  60. data/app/views/generic_files/_permission_form.html.erb +15 -17
  61. data/app/views/generic_files/_show_details.html.erb +1 -11
  62. data/app/views/generic_files/_versioning.html.erb +5 -5
  63. data/app/views/generic_files/edit.html.erb +5 -4
  64. data/app/views/generic_files/show.html.erb +6 -6
  65. data/app/views/homepage/_featured_fields.html.erb +2 -2
  66. data/app/views/homepage/_recent_document.html.erb +1 -1
  67. data/app/views/layouts/_head_tag_content.html.erb +0 -2
  68. data/app/views/layouts/error.html.erb +0 -1
  69. data/app/views/my/_index_partials/_default_group.html.erb +1 -1
  70. data/app/views/my/_index_partials/_list_files.html.erb +1 -1
  71. data/app/views/my/index.html.erb +2 -2
  72. data/app/views/records/_edit_field.html.erb +17 -19
  73. data/app/views/records/edit_fields/_default.html.erb +10 -12
  74. data/app/views/records/edit_fields/_description.html.erb +10 -3
  75. data/app/views/records/edit_fields/_resource_type.html.erb +4 -5
  76. data/app/views/records/edit_fields/_rights.html.erb +9 -2
  77. data/app/views/records/edit_fields/_suffix.html.erb +10 -0
  78. data/app/views/records/edit_fields/_type.html.erb +8 -2
  79. data/app/views/records/show_fields/_based_near.html.erb +1 -1
  80. data/app/views/records/show_fields/_creator.html.erb +1 -1
  81. data/app/views/records/show_fields/_language.html.erb +1 -1
  82. data/app/views/records/show_fields/_publisher.html.erb +1 -1
  83. data/app/views/records/show_fields/_resource_type.html.erb +1 -1
  84. data/app/views/records/show_fields/_subject.html.erb +1 -1
  85. data/app/views/records/show_fields/_tag.html.erb +1 -1
  86. data/app/views/single_use_links/new_download.html.erb +2 -2
  87. data/app/views/users/_profile.html.erb +2 -1
  88. data/app/views/users/_social_media_info.html.erb +20 -0
  89. data/app/views/users/_user_info.html.erb +3 -20
  90. data/app/views/users/edit.html.erb +2 -11
  91. data/app/views/users/show.html.erb +1 -1
  92. data/bin/audit_repository +1 -1
  93. data/config/initializers/sufia_events.rb +4 -4
  94. data/config/locales/sufia.en.yml +0 -5
  95. data/config/routes.rb +1 -1
  96. data/lib/generators/sufia/install_generator.rb +0 -4
  97. data/lib/generators/sufia/templates/catalog_controller.rb +59 -59
  98. data/lib/sufia.rb +1 -4
  99. data/lib/sufia/version.rb +1 -1
  100. data/spec/actors/generic_file/actor_spec.rb +67 -8
  101. data/spec/controllers/batch_controller_spec.rb +72 -86
  102. data/spec/controllers/batch_edits_controller_spec.rb +17 -19
  103. data/spec/controllers/catalog_controller_spec.rb +16 -24
  104. data/spec/controllers/collections_controller_spec.rb +47 -74
  105. data/spec/controllers/downloads_controller_spec.rb +40 -35
  106. data/spec/controllers/generic_files_controller_spec.rb +363 -428
  107. data/spec/controllers/homepage_controller_spec.rb +12 -9
  108. data/spec/controllers/mailbox_controller_spec.rb +1 -4
  109. data/spec/controllers/my/files_controller_spec.rb +0 -10
  110. data/spec/controllers/single_use_links_controller_spec.rb +28 -35
  111. data/spec/controllers/single_use_links_viewer_controller_spec.rb +27 -41
  112. data/spec/controllers/transfers_controller_spec.rb +6 -6
  113. data/spec/controllers/users_controller_spec.rb +121 -124
  114. data/spec/factories/generic_files.rb +9 -17
  115. data/spec/features/browse_dashboard_files_spec.rb +8 -10
  116. data/spec/features/browse_files_spec.rb +12 -25
  117. data/spec/features/catalog_search_spec.rb +49 -49
  118. data/spec/features/collection_spec.rb +18 -24
  119. data/spec/features/contact_form_spec.rb +26 -20
  120. data/spec/features/ingest_upload_files_spec.rb +8 -6
  121. data/spec/features/ownership_transfer_spec.rb +2 -6
  122. data/spec/features/proxy_spec.rb +1 -1
  123. data/spec/features/search_spec.rb +2 -3
  124. data/spec/features/single_use_links_spec.rb +1 -1
  125. data/spec/features/users_spec.rb +1 -1
  126. data/spec/helpers/records_helper_spec.rb +24 -10
  127. data/spec/jobs/active_fedora_pid_based_job_spec.rb +1 -5
  128. data/spec/jobs/audit_job_spec.rb +66 -21
  129. data/spec/jobs/batch_update_job_spec.rb +49 -36
  130. data/spec/jobs/content_depositor_change_event_job_spec.rb +2 -4
  131. data/spec/jobs/create_derivatives_job_spec.rb +18 -19
  132. data/spec/jobs/event_jobs_spec.rb +17 -21
  133. data/spec/jobs/import_url_job_spec.rb +1 -6
  134. data/spec/jobs/ingest_local_file_job_spec.rb +0 -4
  135. data/spec/lib/sufia/breadcrumbs_spec.rb +8 -46
  136. data/spec/lib/sufia/id_service_spec.rb +8 -3
  137. data/spec/lib/sufia/user_stat_importer_spec.rb +18 -25
  138. data/spec/lib/sufia/writable_permissions_spec.rb +0 -4
  139. data/spec/models/ability_spec.rb +25 -18
  140. data/spec/models/batch_spec.rb +16 -45
  141. data/spec/models/characterization_spec.rb +1 -1
  142. data/spec/models/checksum_audit_log_spec.rb +51 -29
  143. data/spec/models/collection_spec.rb +0 -5
  144. data/spec/models/featured_work_list_spec.rb +2 -4
  145. data/spec/models/file_content_datastream_spec.rb +27 -60
  146. data/spec/models/file_usage_spec.rb +16 -21
  147. data/spec/models/fits_datastream_spec.rb +47 -2
  148. data/spec/models/generic_file/web_form_spec.rb +1 -1
  149. data/spec/models/generic_file_spec.rb +238 -735
  150. data/spec/models/local_authority_spec.rb +8 -13
  151. data/spec/models/proxy_deposit_request_spec.rb +3 -7
  152. data/spec/models/single_use_link_spec.rb +12 -16
  153. data/spec/models/solr_document_spec.rb +1 -1
  154. data/spec/models/trophy_spec.rb +1 -3
  155. data/spec/models/user_spec.rb +47 -75
  156. data/spec/presenters/sufia/version_list_presenter_spec.rb +22 -0
  157. data/spec/presenters/sufia/version_presenter_spec.rb +51 -0
  158. data/spec/services/generic_file_audit_service_spec.rb +85 -0
  159. data/spec/services/repository_audit_service_spec.rb +18 -0
  160. data/spec/spec_helper.rb +26 -7
  161. data/spec/support/fixture_helpers.rb +2 -4
  162. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -4
  163. data/spec/views/batch/edit.html.erb_spec.rb +17 -7
  164. data/spec/views/catalog/index.html.erb_spec.rb +8 -6
  165. data/spec/views/collections/_form.html.erb_spec.rb +4 -2
  166. data/spec/views/collections/_show_document_list.erb_spec.rb +31 -0
  167. data/spec/views/dashboard/index_spec.rb +2 -2
  168. data/spec/views/generic_file/edit.html.erb_spec.rb +20 -6
  169. data/spec/views/generic_file/show.html.erb_spec.rb +3 -3
  170. data/spec/views/users/show.html.erb_spec.rb +1 -1
  171. data/sufia-models/app/actors/sufia/generic_file/actor.rb +8 -10
  172. data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +2 -3
  173. data/sufia-models/app/jobs/audit_job.rb +46 -32
  174. data/sufia-models/app/jobs/batch_update_job.rb +9 -8
  175. data/sufia-models/app/jobs/import_url_job.rb +2 -2
  176. data/sufia-models/app/models/batch.rb +11 -12
  177. data/sufia-models/app/models/checksum_audit_log.rb +12 -10
  178. data/sufia-models/app/models/concerns/sufia/ability.rb +4 -6
  179. data/sufia-models/app/models/concerns/sufia/collection.rb +4 -5
  180. data/sufia-models/app/models/concerns/sufia/generic_file.rb +3 -86
  181. data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +29 -0
  182. data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +3 -3
  183. data/sufia-models/app/models/concerns/sufia/generic_file/content.rb +13 -0
  184. data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +5 -5
  185. data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +4 -0
  186. data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +2 -2
  187. data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +23 -0
  188. data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +80 -11
  189. data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +12 -3
  190. data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +4 -4
  191. data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +14 -6
  192. data/sufia-models/app/models/concerns/sufia/model_methods.rb +11 -9
  193. data/sufia-models/app/models/concerns/sufia/user.rb +11 -33
  194. data/sufia-models/app/models/datastreams/file_content_datastream.rb +1 -1
  195. data/sufia-models/app/models/datastreams/fits_datastream.rb +1 -1
  196. data/sufia-models/app/models/file_usage.rb +3 -3
  197. data/sufia-models/app/models/local_authority.rb +2 -2
  198. data/sufia-models/app/models/proxy_deposit_request.rb +1 -1
  199. data/sufia-models/app/services/sufia/generic_file_audit_service.rb +83 -0
  200. data/sufia-models/app/services/sufia/id_service.rb +5 -5
  201. data/sufia-models/app/services/sufia/noid.rb +10 -7
  202. data/sufia-models/app/services/sufia/repository_audit_service.rb +9 -0
  203. data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +47 -3
  204. data/sufia-models/lib/generators/sufia/models/install_generator.rb +31 -11
  205. data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +31 -2
  206. data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +10 -0
  207. data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +33 -2
  208. data/sufia-models/lib/sufia/models/engine.rb +13 -4
  209. data/sufia-models/lib/sufia/models/file_content/versions.rb +9 -11
  210. data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +5 -9
  211. data/sufia-models/lib/sufia/models/version.rb +1 -1
  212. data/sufia-models/lib/sufia/permissions/writable.rb +34 -16
  213. data/sufia-models/sufia-models.gemspec +4 -2
  214. data/sufia.gemspec +4 -5
  215. data/tasks/jetty.rake +0 -26
  216. data/tasks/sufia-dev.rake +14 -2
  217. metadata +49 -64
  218. data/LICENSE +0 -15
  219. data/app/assets/images/orcid.png +0 -0
  220. data/app/assets/javascripts/sufia/manage_repeating_fields.js +0 -74
  221. data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +0 -67
  222. data/app/inputs/multi_value_input.rb +0 -84
  223. data/app/views/records/_rights_modal.html.erb +0 -1
  224. data/config/initializers/simple_form.rb +0 -167
  225. data/config/initializers/simple_form_bootstrap.rb +0 -137
  226. data/config/locales/simple_form.en.yml +0 -31
  227. data/fedora_conf/conf/development/fedora.fcfg +0 -946
  228. data/fedora_conf/conf/test/fedora.fcfg +0 -946
  229. data/spec/models/generic_file/reload_on_save_spec.rb +0 -25
  230. data/spec/models/generic_file_rdf_datastream_spec.rb +0 -12
  231. data/spec/models/properties_datastream_spec.rb +0 -41
  232. data/spec/views/generic_file/_permission_form.html.erb_spec.rb +0 -19
  233. data/sufia-models/app/models/concerns/sufia/generic_file/audit.rb +0 -116
  234. data/sufia-models/app/models/concerns/sufia/generic_file/reload_on_save.rb +0 -18
  235. data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +0 -32
  236. data/sufia-models/app/models/datastreams/batch_rdf_datastream.rb +0 -6
  237. data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +0 -69
  238. data/sufia-models/app/models/datastreams/paranoid_rights_datastream.rb +0 -22
  239. data/sufia-models/app/models/datastreams/properties_datastream.rb +0 -4
  240. data/sufia-models/app/models/sufia/orcid_validator.rb +0 -8
  241. data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
  242. data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
  243. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
  244. data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +0 -31
@@ -14,43 +14,35 @@ FactoryGirl.define do
14
14
  factory :fixture do
15
15
  factory :public_pdf do
16
16
  transient do
17
- pid "sufia:fixture-pdf"
17
+ id "fixture-pdf"
18
18
  end
19
- initialize_with { new(pid: pid) }
19
+ initialize_with { new(id: id) }
20
20
  read_groups ["public"]
21
21
  resource_type ["Dissertation"]
22
22
  subject %w"lorem ipsum dolor sit amet"
23
+ title ["fake_document.pdf"]
23
24
  before(:create) do |gf|
24
- gf.apply_depositor_metadata "archivist1@example.com"
25
25
  gf.title = ["Fake Document Title"]
26
- gf.label = "fake_document.pdf"
27
26
  end
28
27
  end
29
28
  factory :public_mp3 do
30
29
  transient do
31
- pid "sufia:fixture-mp3"
30
+ id "fixture-mp3"
32
31
  end
33
- initialize_with { new(pid: pid) }
32
+ initialize_with { new(id: id) }
34
33
  subject %w"consectetur adipisicing elit"
35
- before(:create) do |gf|
36
- gf.apply_depositor_metadata "archivist1@example.com"
37
- gf.inner_object.pid = "sufia:fixture-mp3"
38
- gf.label = "Test Document MP3.mp3"
39
- end
34
+ title ["Test Document MP3.mp3"]
40
35
  read_groups ["public"]
41
36
  end
42
37
  factory :public_wav do
43
38
  transient do
44
- pid "sufia:fixture-wav"
39
+ id "fixture-wav"
45
40
  end
46
- initialize_with { new(pid: pid) }
41
+ initialize_with { new(id: id) }
47
42
  resource_type ["Audio", "Dataset"]
48
43
  read_groups ["public"]
44
+ title ["Fake Wav File.wav"]
49
45
  subject %w"sed do eiusmod tempor incididunt ut labore"
50
- before(:create) do |gf|
51
- gf.apply_depositor_metadata "archivist1@example.com"
52
- gf.label = "Fake Wav File.wav"
53
- end
54
46
  end
55
47
  end
56
48
  end
@@ -2,19 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe "Browse Dashboard", :type => :feature do
4
4
 
5
- before :all do
6
- cleanup_jetty
7
- @fixtures = find_or_create_file_fixtures
8
- end
9
- after :all do
10
- cleanup_jetty
11
- end
12
-
5
+ let(:user) { FactoryGirl.create(:user) }
13
6
  before do
14
- sign_in FactoryGirl.create :user_with_fixtures
7
+ @fixtures = create_file_fixtures(user.user_key)
8
+ sign_in user
15
9
  end
16
10
 
17
- it "should search your files by deafult" do
11
+ it "should search your files by default" do
18
12
  visit "/dashboard"
19
13
  fill_in "q", with: "PDF"
20
14
  click_button "search-submit-header"
@@ -28,6 +22,7 @@ describe "Browse Dashboard", :type => :feature do
28
22
  end
29
23
 
30
24
  it "should display all the necessary information" do
25
+ # TODO this would make a good view test.
31
26
  within("#document_#{@fixtures.first.noid}") do
32
27
  click_button("Select an action")
33
28
  end
@@ -64,6 +59,7 @@ describe "Browse Dashboard", :type => :feature do
64
59
  end
65
60
 
66
61
  it "should allow me to edit files (from the fixtures)" do
62
+ # TODO this would make a good view test.
67
63
  fill_in "q", with: "Wav"
68
64
  click_button "search-submit-header"
69
65
  click_button "Select an action"
@@ -72,6 +68,7 @@ describe "Browse Dashboard", :type => :feature do
72
68
  end
73
69
 
74
70
  it "should refresh the page of files" do
71
+ # TODO this would make a good view test.
75
72
  click_button "Refresh"
76
73
  within("#document_#{@fixtures.first.noid}") do
77
74
  click_button("Select an action")
@@ -87,6 +84,7 @@ describe "Browse Dashboard", :type => :feature do
87
84
  end
88
85
 
89
86
  it "should link to my other tabs" do
87
+ # TODO this would make a good view test.
90
88
  ["My Collections", "My Highlights", "Files Shared with Me"].each do |tab|
91
89
  within("#my_nav") do
92
90
  click_link(tab)
@@ -2,23 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe "Browse files", :type => :feature do
4
4
 
5
- before :all do
6
- cleanup_jetty
7
- @fixtures = find_or_create_file_fixtures
5
+ before do
6
+ allow(User).to receive(:find_by_user_key).and_return(stub_model(User, twitter_handle: 'bob'))
7
+ end
8
+
9
+ before do
10
+ @fixtures = create_file_fixtures
8
11
  @fixtures[0].tag = ["key"]
9
12
  (1..25).each do |i|
10
- @fixtures[0].tag << "key_#{i}"
13
+ @fixtures[0].tag << i.to_s
11
14
  end
12
- @fixtures[1].tag = ["key"]
13
15
  @fixtures[0].save
14
- (1..20).each do |i|
15
- @fixtures[1].tag << "key_#{i}"
16
- end
17
- @fixtures[1].save
18
- end
19
-
20
- after :all do
21
- cleanup_jetty
22
16
  end
23
17
 
24
18
  before do
@@ -28,30 +22,23 @@ describe "Browse files", :type => :feature do
28
22
  click_button "search-submit-header"
29
23
  click_link "Keyword"
30
24
  click_link "more Keywords»"
31
- expect(page).to have_css "h3", text: "Keyword"
32
25
  end
33
26
 
34
27
  describe "when not logged in" do
35
28
  it "should let us browse some of the fixtures" do
36
- click_link "18"
29
+ click_link "13"
37
30
  expect(page).to have_content "Search Results"
38
- expect(page).to have_css "a", text: @fixtures[0].title[0]
39
31
  click_link @fixtures[0].title[0]
40
32
  expect(page).to have_content "Download"
41
33
  expect(page).not_to have_content "Edit"
42
34
  end
43
35
  it "should allow you to click next" do
44
- expect(page).to have_content "Numerical Sort"
45
- expect(page).to have_css "a.sort_change", text:"A-Z Sort"
46
- within(".modal-body") do
47
- expect(page).to have_content "key_1 "
48
- expect(page).not_to have_content "key_25 "
36
+ within('.bottom') do
37
+ click_link 'Next »'
49
38
  end
50
- click_link 'Next »'
51
- expect(page).to have_css "a.btn-link", text:"« Previous", wait: Capybara.default_wait_time*4
52
39
  within(".modal-body") do
53
- expect(page).to have_content "key_25 "
54
- expect(page).not_to have_content "key_1 "
40
+ expect(page).to have_content "5"
41
+ expect(page).not_to have_content "11"
55
42
  end
56
43
  end
57
44
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'catalog searching', :type => :feature do
4
4
 
5
- before(:all) do
5
+ before do
6
6
  @gf1 = GenericFile.new.tap do |f|
7
7
  f.title = ['title 1']
8
8
  f.tag = ["tag1", "tag2"]
@@ -10,26 +10,6 @@ describe 'catalog searching', :type => :feature do
10
10
  f.read_groups = ['public']
11
11
  f.save!
12
12
  end
13
- @gf2 = GenericFile.new.tap do |f|
14
- f.title = ['title 2']
15
- f.tag = ["tag2", "tag3"]
16
- f.apply_depositor_metadata('jilluser')
17
- f.read_groups = ['public']
18
- f.save!
19
- end
20
- @col = Collection.new.tap do |f|
21
- f.title = 'title 3'
22
- f.tag = ["tag3", "tag4"]
23
- f.apply_depositor_metadata('jilluser')
24
- f.read_groups = ['public']
25
- f.save!
26
- end
27
- end
28
-
29
- after(:all) do
30
- User.destroy_all
31
- GenericFile.destroy_all
32
- Collection.destroy_all
33
13
  end
34
14
 
35
15
  before do
@@ -38,45 +18,65 @@ describe 'catalog searching', :type => :feature do
38
18
  visit '/'
39
19
  end
40
20
 
41
- it "finds multiple files" do
42
- within('#masthead_controls') do
43
- fill_in('search-field-header', with: "tag2")
44
- click_button("Go")
21
+ context "with files and collections" do
22
+ before do
23
+ @gf2 = GenericFile.new.tap do |f|
24
+ f.title = ['title 2']
25
+ f.tag = ["tag2", "tag3"]
26
+ f.apply_depositor_metadata('jilluser')
27
+ f.read_groups = ['public']
28
+ f.save!
29
+ end
30
+ @col = Collection.new.tap do |f|
31
+ f.title = 'title 3'
32
+ f.tag = ["tag3", "tag4"]
33
+ f.apply_depositor_metadata('jilluser')
34
+ f.read_groups = ['public']
35
+ f.save!
36
+ end
45
37
  end
46
- expect(page).to have_content('Search Results')
47
- expect(page).to have_content(@gf1.title.first)
48
- expect(page).to have_content(@gf2.title.first)
49
- expect(page).to_not have_content(@col.title)
50
- end
51
38
 
52
- it "finds files and collections" do
53
- within('#masthead_controls') do
54
- fill_in('search-field-header', with: "tag3")
55
- click_button("Go")
39
+ # TODO most of these tests could be controller tests.
40
+ it "finds multiple files" do
41
+ within('#masthead_controls') do
42
+ fill_in('search-field-header', with: "tag2")
43
+ click_button("Go")
44
+ end
45
+ expect(page).to have_content('Search Results')
46
+ expect(page).to have_content(@gf1.title.first)
47
+ expect(page).to have_content(@gf2.title.first)
48
+ expect(page).to_not have_content(@col.title)
56
49
  end
57
- expect(page).to have_content('Search Results')
58
- expect(page).to have_content(@col.title)
59
- expect(page).to have_content(@gf2.title.first)
60
- expect(page).to_not have_content(@gf1.title.first)
61
- end
62
50
 
63
- it "finds collections" do
64
- within('#masthead_controls') do
65
- fill_in('search-field-header', with: "tag4")
66
- click_button("Go")
51
+ it "finds files and collections" do
52
+ within('#masthead_controls') do
53
+ fill_in('search-field-header', with: "tag3")
54
+ click_button("Go")
55
+ end
56
+ expect(page).to have_content('Search Results')
57
+ expect(page).to have_content(@col.title)
58
+ expect(page).to have_content(@gf2.title.first)
59
+ expect(page).to_not have_content(@gf1.title.first)
60
+ end
61
+
62
+ it "finds collections" do
63
+ within('#masthead_controls') do
64
+ fill_in('search-field-header', with: "tag4")
65
+ click_button("Go")
66
+ end
67
+ expect(page).to have_content('Search Results')
68
+ expect(page).to have_content(@col.title)
69
+ expect(page).to_not have_content(@gf2.title.first)
70
+ expect(page).to_not have_content(@gf1.title.first)
67
71
  end
68
- expect(page).to have_content('Search Results')
69
- expect(page).to have_content(@col.title)
70
- expect(page).to_not have_content(@gf2.title.first)
71
- expect(page).to_not have_content(@gf1.title.first)
72
72
  end
73
73
 
74
74
  context "many tags" do
75
75
  before do
76
76
  (1..25).each do |i|
77
- @gf1.tag << "tag#{i.to_s}"
77
+ @gf1.tag += ["tag#{sprintf('%02d', i)}"]
78
78
  end
79
- @gf1.save
79
+ @gf1.save!
80
80
  within('#masthead_controls') do
81
81
  fill_in('search-field-header', with: "tag1")
82
82
  click_button("Go")
@@ -5,13 +5,6 @@ describe 'collection', :type => :feature do
5
5
  visit '/dashboard'
6
6
  first('#hydra-collection-add').click
7
7
  expect(page).to have_content 'Create New Collection'
8
-
9
- # Creator is a multi-value field, so it should have button to add more fields
10
- expect(page).to have_selector "div.collection_creator .input-append button.add"
11
-
12
- # Title is a single-value field, so it should not have the adder button
13
- expect(page).to_not have_selector "div.collection_title .input-append button.add"
14
-
15
8
  fill_in('Title', with: title)
16
9
  fill_in('Abstract or Summary', with: description)
17
10
  click_button("Create Collection")
@@ -27,12 +20,11 @@ describe 'collection', :type => :feature do
27
20
 
28
21
  let(:user) { FactoryGirl.find_or_create(:archivist) }
29
22
 
30
- before(:all) do
23
+ before do
31
24
  @gfs = []
32
- (0..12).each do |x|
33
- @gfs[x] = GenericFile.new.tap do |f|
34
- f.title = ["title #{x}"]
35
- f.apply_depositor_metadata('archivist1@example.com')
25
+ (0..1).each do |x|
26
+ @gfs[x] = GenericFile.new(title: ["title #{x}"]).tap do |f|
27
+ f.apply_depositor_metadata(user.user_key)
36
28
  f.save!
37
29
  end
38
30
  end
@@ -40,15 +32,11 @@ describe 'collection', :type => :feature do
40
32
  @gf2 = @gfs[1]
41
33
  end
42
34
 
43
- after(:all) do
44
- ActiveFedora::Base.destroy_all
45
- end
46
-
47
35
  describe 'create collection' do
48
36
  before do
49
37
  sign_in user
50
- visit '/dashboard/collections'
51
38
  end
39
+
52
40
  it "should create collection from the dashboard and include files", js: true do
53
41
  create_collection(title2, description2)
54
42
  visit '/dashboard/files'
@@ -58,13 +46,14 @@ describe 'collection', :type => :feature do
58
46
  click_button "Update Collection"
59
47
  expect(page).to have_content "Items in this Collection"
60
48
  # There are two rows in the table per document (one for the general info, one for the details)
61
- # Make sure we have at least 9 documents (18 table rows)
62
- expect(page).to have_selector "table.table-zebra-striped tr:nth-child(18)"
49
+ # Make sure we have at least 2 documents
50
+ expect(page).to have_selector "table.table-zebra-striped tr#document_#{@gf1.id}"
51
+ expect(page).to have_selector "table.table-zebra-striped tr#document_#{@gf2.id}"
63
52
  end
64
53
  end
65
54
 
66
55
  describe 'delete collection' do
67
- before (:each) do
56
+ before do
68
57
  @collection = Collection.new title:'collection title'
69
58
  @collection.description = 'collection description'
70
59
  @collection.apply_depositor_metadata(user.user_key)
@@ -141,7 +130,7 @@ describe 'collection', :type => :feature do
141
130
  end
142
131
 
143
132
  describe 'edit collection' do
144
- before (:each) do
133
+ before do
145
134
  @collection = Collection.new(title: 'collection title')
146
135
  @collection.description = 'collection description'
147
136
  @collection.apply_depositor_metadata(user.user_key)
@@ -219,9 +208,14 @@ describe 'collection', :type => :feature do
219
208
  end
220
209
 
221
210
  describe 'show pages of a collection' do
222
- before (:each) do
223
- @collection = Collection.new title:'collection title'
224
- @collection.description = 'collection description'
211
+ before do
212
+ (2..12).each do |x|
213
+ @gfs[x] = GenericFile.new(title: ["title #{x}"]).tap do |f|
214
+ f.apply_depositor_metadata(user.user_key)
215
+ f.save!
216
+ end
217
+ end
218
+ @collection = Collection.new title: 'collection title', description: 'collection description'
225
219
  @collection.apply_depositor_metadata(user.user_key)
226
220
  @collection.members = @gfs
227
221
  @collection.save!
@@ -59,28 +59,34 @@ describe "Sending an email via the contact form", :type => :feature do
59
59
  expect(page).to have_content "Sorry, this message was not delivered"
60
60
  end
61
61
 
62
- it "should give an error when I don't provide a subject" do
63
- visit '/'
64
- click_link "Contact"
65
- expect(page).to have_content "Contact Form"
66
- fill_in "contact_form_name", with: "Test McPherson"
67
- fill_in "contact_form_email", with: "archivist1@example.com"
68
- fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
69
- select "Depositing content", from: "contact_form_category"
70
- expect_any_instance_of(ContactForm).not_to receive(:deliver)
71
- click_button "Send"
62
+ context "when I don't provide a subject", :js do
63
+ it "should give an error" do
64
+ # TODO this should be a controller test, because that any_instance will be in a different thread
65
+ visit '/'
66
+ click_link "Contact"
67
+ expect(page).to have_content "Contact Form"
68
+ fill_in "contact_form_name", with: "Test McPherson"
69
+ fill_in "contact_form_email", with: "archivist1@example.com"
70
+ fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
71
+ select "Depositing content", from: "contact_form_category"
72
+ expect_any_instance_of(ContactForm).not_to receive(:deliver)
73
+ click_button "Send"
74
+ end
72
75
  end
73
76
 
74
- it "should give an error when I don't provide a message" do
75
- visit '/'
76
- click_link "Contact"
77
- expect(page).to have_content "Contact Form"
78
- fill_in "contact_form_name", with: "Test McPherson"
79
- fill_in "contact_form_email", with: "archivist1@example.com"
80
- fill_in "contact_form_subject", with: "My Subject is Cool"
81
- select "Depositing content", from: "contact_form_category"
82
- expect_any_instance_of(ContactForm).not_to receive(:deliver)
83
- click_button "Send"
77
+ context "when I don't provide a message", :js do
78
+ it "should give an error" do
79
+ # TODO this should be a controller test, because that any_instance will be in a different thread
80
+ visit '/'
81
+ click_link "Contact"
82
+ expect(page).to have_content "Contact Form"
83
+ fill_in "contact_form_name", with: "Test McPherson"
84
+ fill_in "contact_form_email", with: "archivist1@example.com"
85
+ fill_in "contact_form_subject", with: "My Subject is Cool"
86
+ select "Depositing content", from: "contact_form_category"
87
+ expect_any_instance_of(ContactForm).not_to receive(:deliver)
88
+ click_button "Send"
89
+ end
84
90
  end
85
91
 
86
92
  it "should give an error when I provide an invalid captcha" do