sufia 4.0.0.rc1 → 4.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +2 -2
  4. data/Gemfile +9 -17
  5. data/README.md +18 -9
  6. data/Rakefile +10 -5
  7. data/SUFIA_VERSION +1 -1
  8. data/app/assets/javascripts/jquery.blacklightTagCloud.js +1 -1
  9. data/app/assets/javascripts/sufia.js +5 -22
  10. data/app/assets/javascripts/sufia/batch.js +8 -0
  11. data/app/assets/javascripts/sufia/batch_edit.js +19 -3
  12. data/app/assets/javascripts/sufia/dashboard_actions.js +23 -10
  13. data/app/assets/javascripts/sufia/multiForm.js +2 -2
  14. data/app/assets/javascripts/sufia/permissions.js +10 -9
  15. data/app/assets/javascripts/sufia/tabs.js +20 -0
  16. data/app/assets/stylesheets/catalog.css.scss +5 -0
  17. data/app/assets/stylesheets/collections.css.scss +40 -0
  18. data/app/assets/stylesheets/file-listing.css.scss +37 -13
  19. data/app/assets/stylesheets/generic_files.css.erb +5 -0
  20. data/app/assets/stylesheets/header.css.scss +1 -4
  21. data/app/assets/stylesheets/settings.css.scss +6 -0
  22. data/app/assets/stylesheets/styles.css.scss +4 -3
  23. data/app/assets/stylesheets/sufia-audio-overrides.css +2 -2
  24. data/app/assets/stylesheets/sufia.css.scss +27 -5
  25. data/app/assets/stylesheets/tagcloud.css +5 -1
  26. data/app/controllers/batch_controller.rb +3 -3
  27. data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +14 -1
  28. data/app/controllers/concerns/sufia/catalog.rb +0 -1
  29. data/app/controllers/concerns/sufia/controller.rb +5 -0
  30. data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +2 -9
  31. data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +3 -3
  32. data/app/controllers/concerns/sufia/files_controller_behavior.rb +5 -1
  33. data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
  34. data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
  35. data/app/helpers/batch_edits_helper.rb +6 -0
  36. data/app/helpers/generic_file_helper.rb +15 -0
  37. data/app/helpers/sufia/blacklight_override.rb +19 -3
  38. data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -3
  39. data/app/helpers/sufia/records_helper_behavior.rb +13 -5
  40. data/app/helpers/sufia/sufia_helper_behavior.rb +15 -12
  41. data/app/models/concerns/sufia/solr_document_behavior.rb +5 -36
  42. data/app/views/_masthead.html.erb +1 -1
  43. data/app/views/_user_util_links.html.erb +6 -4
  44. data/app/views/advanced/_advanced_search_fields.html.erb +4 -4
  45. data/app/views/advanced/_advanced_search_form.html.erb +14 -17
  46. data/app/views/advanced/index.html.erb +3 -3
  47. data/app/views/batch/_metadata.html.erb +22 -24
  48. data/app/views/batch/_more_metadata.html.erb +1 -1
  49. data/app/views/batch/edit.html.erb +2 -2
  50. data/app/views/batch_edits/_check_all.html.erb +7 -9
  51. data/app/views/batch_edits/_delete_selected.html.erb +1 -0
  52. data/app/views/batch_edits/edit.html.erb +25 -26
  53. data/app/views/batch_edits/update_edit.js.erb +1 -1
  54. data/app/views/catalog/_facet_limit.html.erb +4 -12
  55. data/app/views/catalog/_search_form.html.erb +8 -13
  56. data/app/views/collections/_action_menu.html.erb +2 -2
  57. data/app/views/collections/_collection.html.erb +10 -31
  58. data/app/views/collections/_document_list.html.erb +1 -1
  59. data/app/views/collections/_edit_actions.html.erb +2 -2
  60. data/app/views/collections/_edit_descriptions.html.erb +3 -5
  61. data/app/views/collections/_form.html.erb +8 -10
  62. data/app/views/collections/_media_display.html.erb +1 -1
  63. data/app/views/collections/_show_actions.html.erb +5 -5
  64. data/app/views/collections/_show_descriptions.html.erb +13 -8
  65. data/app/views/collections/_show_document_list.html.erb +17 -0
  66. data/app/views/collections/_show_document_list_menu.html.erb +24 -0
  67. data/app/views/collections/_show_document_list_row.html.erb +63 -0
  68. data/app/views/collections/edit.html.erb +2 -2
  69. data/app/views/collections/show.html.erb +28 -19
  70. data/app/views/contact_form/new.html.erb +21 -29
  71. data/app/views/dashboard/_index_partials/_contents.html.erb +14 -0
  72. data/app/views/dashboard/_index_partials/_heading_actions.html.erb +18 -0
  73. data/app/views/dashboard/_index_partials/_heading_greetings.html.erb +8 -0
  74. data/app/views/dashboard/_index_partials/_stats.html.erb +6 -2
  75. data/app/views/dashboard/index.html.erb +5 -37
  76. data/app/views/generic_files/_breadcrumbs.html.erb +2 -0
  77. data/app/views/generic_files/_browse_everything.html.erb +2 -2
  78. data/app/views/generic_files/_descriptions.html.erb +4 -6
  79. data/app/views/generic_files/_field_form.html.erb +2 -2
  80. data/app/views/generic_files/_generic_file.html.erb +8 -29
  81. data/app/views/generic_files/_groups_description.html.erb +5 -4
  82. data/app/views/generic_files/_permission.html.erb +2 -2
  83. data/app/views/generic_files/_permission_form.html.erb +62 -77
  84. data/app/views/generic_files/_rights_modal.html.erb +0 -2
  85. data/app/views/generic_files/_share_with.html.erb +14 -0
  86. data/app/views/generic_files/_show_actions.html.erb +1 -1
  87. data/app/views/generic_files/_show_collections.html.erb +17 -0
  88. data/app/views/generic_files/_show_descriptions.html.erb +2 -2
  89. data/app/views/generic_files/_versioning.html.erb +2 -2
  90. data/app/views/generic_files/_visibility.html.erb +17 -0
  91. data/app/views/generic_files/show.html.erb +39 -2
  92. data/app/views/generic_files/stats.html.erb +1 -1
  93. data/app/views/generic_files/upload/_form_fields.html.erb +2 -2
  94. data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
  95. data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
  96. data/app/views/generic_files/upload/_tos_checkbox.html.erb +3 -3
  97. data/app/views/homepage/_home_content.html.erb +0 -9
  98. data/app/views/homepage/_home_header.html.erb +1 -1
  99. data/app/views/homepage/_recent_document.html.erb +2 -2
  100. data/app/views/layouts/_head_tag_content.html.erb +7 -1
  101. data/app/views/layouts/sufia-dashboard.html.erb +4 -2
  102. data/app/views/layouts/sufia-one-column.html.erb +1 -1
  103. data/app/views/my/_action_menu.html.erb +1 -1
  104. data/app/views/my/_collection_action_menu.html.erb +3 -3
  105. data/app/views/my/_constraints.html.erb +11 -0
  106. data/app/views/my/_document_list.html.erb +1 -1
  107. data/app/views/my/_facet_limit.html.erb +4 -12
  108. data/app/views/my/_facets.html.erb +1 -3
  109. data/app/views/my/_index_partials/_default_group.html.erb +2 -3
  110. data/app/views/my/_index_partials/_list_collections.html.erb +17 -11
  111. data/app/views/my/_index_partials/_list_files.html.erb +20 -24
  112. data/app/views/my/_search_header.html.erb +5 -0
  113. data/app/views/my/_sort_and_per_page.html.erb +11 -7
  114. data/app/views/my/index.html.erb +9 -15
  115. data/app/views/records/_edit_field.html.erb +14 -10
  116. data/app/views/records/edit_fields/_default.html.erb +6 -0
  117. data/app/views/records/edit_fields/_description.html.erb +3 -7
  118. data/app/views/records/edit_fields/_resource_type.html.erb +4 -6
  119. data/app/views/records/edit_fields/_rights.html.erb +4 -5
  120. data/app/views/records/edit_fields/_suffix.html.erb +6 -3
  121. data/app/views/records/edit_fields/_type.html.erb +7 -12
  122. data/app/views/{generic_files → records}/show_fields/_based_near.html.erb +1 -1
  123. data/app/views/{generic_files → records}/show_fields/_contributor.html.erb +2 -2
  124. data/app/views/records/show_fields/_creator.html.erb +6 -0
  125. data/app/views/{generic_files → records}/show_fields/_date_created.html.erb +1 -1
  126. data/app/views/records/show_fields/_default.html.erb +6 -0
  127. data/app/views/records/show_fields/_description.html.erb +6 -0
  128. data/app/views/records/show_fields/_identifier.html.erb +4 -0
  129. data/app/views/{generic_files → records}/show_fields/_language.html.erb +1 -1
  130. data/app/views/{generic_files → records}/show_fields/_publisher.html.erb +1 -1
  131. data/app/views/records/show_fields/_related_url.html.erb +6 -0
  132. data/app/views/{generic_files → records}/show_fields/_resource_type.html.erb +1 -1
  133. data/app/views/{generic_files → records}/show_fields/_rights.html.erb +1 -1
  134. data/app/views/{generic_files → records}/show_fields/_subject.html.erb +1 -1
  135. data/app/views/{generic_files → records}/show_fields/_tag.html.erb +1 -1
  136. data/app/views/records/show_fields/_title.html.erb +6 -0
  137. data/app/views/shared/_attributes.html.erb +27 -0
  138. data/app/views/static/agreement.html.erb +1 -1
  139. data/app/views/users/_activity_log.html.erb +0 -2
  140. data/app/views/users/_follower_modal.html.erb +27 -23
  141. data/app/views/users/_following_modal.html.erb +27 -23
  142. data/app/views/users/_social_media_info.html.erb +4 -4
  143. data/app/views/users/_trophy_edit.html.erb +5 -7
  144. data/app/views/users/_user_info.html.erb +3 -3
  145. data/app/views/users/_user_util_links_extra.html.erb +4 -0
  146. data/app/views/users/edit.html.erb +28 -33
  147. data/app/views/users/index.html.erb +1 -1
  148. data/app/views/users/show.html.erb +0 -4
  149. data/config/jetty.yml +1 -1
  150. data/config/locales/sufia.en.yml +53 -12
  151. data/lib/generators/sufia/install_generator.rb +89 -0
  152. data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
  153. data/lib/generators/sufia/upgrade400_generator.rb +4 -0
  154. data/lib/sufia.rb +1 -10
  155. data/lib/sufia/version.rb +1 -1
  156. data/solr_conf/conf/solrconfig.xml +31 -17
  157. data/spec/actors/generic_file/actor_spec.rb +17 -0
  158. data/spec/controllers/batch_controller_spec.rb +2 -2
  159. data/spec/controllers/batch_edits_controller_spec.rb +24 -19
  160. data/spec/controllers/catalog_controller_spec.rb +23 -12
  161. data/spec/controllers/collections_controller_spec.rb +19 -17
  162. data/spec/controllers/dashboard_controller_spec.rb +5 -19
  163. data/spec/controllers/generic_files_controller_spec.rb +35 -20
  164. data/spec/controllers/homepage_controller_spec.rb +25 -2
  165. data/spec/controllers/users_controller_spec.rb +99 -102
  166. data/spec/factories/generic_files.rb +2 -2
  167. data/spec/factories/users.rb +32 -2
  168. data/spec/features/browse_dashboard_files_spec.rb +14 -2
  169. data/spec/features/browse_files_spec.rb +5 -1
  170. data/spec/features/catalog_search_spec.rb +7 -6
  171. data/spec/features/collection_spec.rb +43 -33
  172. data/spec/features/display_dashboard_spec.rb +25 -22
  173. data/spec/features/notifications_spec.rb +9 -4
  174. data/spec/features/users_spec.rb +34 -25
  175. data/spec/fixtures/1.5mb-avatar.jpg +0 -0
  176. data/spec/helpers/batch_edits_helper_spec.rb +38 -0
  177. data/spec/helpers/dashboard_helper_spec.rb +16 -5
  178. data/spec/helpers/generic_file_helper_spec.rb +41 -0
  179. data/spec/helpers/records_helper_spec.rb +12 -0
  180. data/spec/jobs/active_fedora_pid_based_job_spec.rb +1 -1
  181. data/spec/jobs/audit_job_spec.rb +2 -3
  182. data/spec/jobs/batch_update_job_spec.rb +39 -24
  183. data/spec/jobs/event_jobs_spec.rb +1 -1
  184. data/spec/lib/sufia/id_service_spec.rb +25 -7
  185. data/spec/lib/sufia/messages_spec.rb +60 -0
  186. data/spec/lib/sufia/readable_permissions_spec.rb +56 -0
  187. data/spec/lib/sufia/writable_permissions_spec.rb +20 -0
  188. data/spec/models/batch_spec.rb +1 -1
  189. data/spec/models/collection_spec.rb +24 -2
  190. data/spec/models/featured_work_spec.rb +2 -2
  191. data/spec/models/file_content_datastream_spec.rb +5 -5
  192. data/spec/models/generic_file_spec.rb +149 -133
  193. data/spec/models/local_authority_spec.rb +1 -1
  194. data/spec/models/user_spec.rb +33 -6
  195. data/spec/spec_helper.rb +7 -10
  196. data/spec/{support → test_app_templates}/lib/generators/test_app_generator.rb +11 -6
  197. data/spec/views/batch/edit.html.erb_spec.rb +8 -2
  198. data/spec/views/catalog/index.html.erb_spec.rb +34 -0
  199. data/spec/views/catalog/{sort_and_per_pange.html.erb_spec.rb → sort_and_per_page.html.erb_spec.rb} +0 -0
  200. data/spec/views/collections/_form.html.erb_spec.rb +32 -0
  201. data/spec/views/collections/_show_descriptions.html.erb_spec.rb +25 -0
  202. data/spec/views/dashboard/index_spec.rb +33 -4
  203. data/spec/views/generic_file/_breadcrumbs.html.erb_spec.rb +32 -0
  204. data/spec/views/generic_file/show.html.erb_spec.rb +273 -8
  205. data/spec/views/users/_user_util_links.html.erb_spec.rb +25 -0
  206. data/sufia-models/app/actors/sufia/generic_file/actor.rb +14 -5
  207. data/sufia-models/{lib/sufia/models → app}/jobs/active_fedora_pid_based_job.rb +0 -0
  208. data/sufia-models/{lib/sufia/models → app}/jobs/audit_job.rb +4 -10
  209. data/sufia-models/{lib/sufia/models → app}/jobs/batch_update_job.rb +22 -18
  210. data/sufia-models/{lib/sufia/models → app}/jobs/characterize_job.rb +0 -0
  211. data/sufia-models/{lib/sufia/models → app}/jobs/create_derivatives_job.rb +0 -0
  212. data/sufia-models/{lib/sufia/models → app}/jobs/import_url_job.rb +0 -0
  213. data/sufia-models/{lib/sufia/models → app}/jobs/resolrize_job.rb +0 -0
  214. data/sufia-models/app/models/collection.rb +1 -39
  215. data/sufia-models/{lib → app/models/concerns}/sufia/ability.rb +0 -0
  216. data/sufia-models/app/models/concerns/sufia/collection.rb +55 -0
  217. data/sufia-models/app/models/concerns/sufia/generic_file.rb +5 -11
  218. data/sufia-models/app/models/concerns/sufia/generic_file/audit.rb +1 -2
  219. data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +4 -2
  220. data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +27 -0
  221. data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +1 -0
  222. data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +2 -49
  223. data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/model_methods.rb +0 -0
  224. data/sufia-models/app/models/concerns/sufia/user.rb +8 -1
  225. data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
  226. data/sufia-models/app/services/sufia/noid.rb +9 -0
  227. data/sufia-models/config/locales/sufia.en.yml +1 -0
  228. data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +27 -0
  229. data/sufia-models/lib/generators/sufia/models/install_generator.rb +7 -0
  230. data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +5 -5
  231. data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +177 -0
  232. data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -1
  233. data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +7 -0
  234. data/sufia-models/lib/sufia/messages.rb +67 -0
  235. data/sufia-models/lib/sufia/models.rb +2 -0
  236. data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -6
  237. data/sufia-models/lib/sufia/models/engine.rb +1 -3
  238. data/sufia-models/lib/sufia/models/resque.rb +1 -1
  239. data/sufia-models/lib/sufia/models/version.rb +1 -1
  240. data/sufia-models/lib/sufia/permissions.rb +9 -0
  241. data/sufia-models/lib/sufia/permissions/readable.rb +20 -0
  242. data/sufia-models/lib/sufia/permissions/writable.rb +56 -0
  243. data/sufia-models/lib/tasks/sufia-models_tasks.rake +58 -2
  244. data/sufia-models/sufia-models.gemspec +11 -11
  245. data/sufia.gemspec +19 -9
  246. data/tasks/jetty.rake +6 -5
  247. data/tasks/sufia-dev.rake +4 -77
  248. metadata +235 -72
  249. data/app/assets/images/folder.png +0 -0
  250. data/app/views/collections/show_fields/_creator.html.erb +0 -11
  251. data/app/views/collections/show_fields/_description.html.erb +0 -8
  252. data/app/views/collections/show_fields/_title.html.erb +0 -8
  253. data/app/views/generic_files/edit_fields/_default.html.erb +0 -6
  254. data/app/views/generic_files/edit_fields/_description.html.erb +0 -5
  255. data/app/views/generic_files/edit_fields/_resource_type.html.erb +0 -6
  256. data/app/views/generic_files/edit_fields/_rights.html.erb +0 -6
  257. data/app/views/generic_files/edit_fields/_suffix.html.erb +0 -9
  258. data/app/views/generic_files/show_fields/_creator.html.erb +0 -7
  259. data/app/views/generic_files/show_fields/_default.html.erb +0 -6
  260. data/app/views/generic_files/show_fields/_description.html.erb +0 -7
  261. data/app/views/generic_files/show_fields/_identifier.html.erb +0 -4
  262. data/app/views/generic_files/show_fields/_related_url.html.erb +0 -6
  263. data/app/views/generic_files/show_fields/_title.html.erb +0 -7
  264. data/lib/generators/sufia/sufia_generator.rb +0 -89
  265. data/spec/active_fedora/unsaved_digital_object_spec.rb +0 -35
@@ -7,4 +7,21 @@ describe Sufia::GenericFile::Actor do
7
7
  expect { Sufia::GenericFile::Actor.virus_check(File.new(fixture_path + '/world.png')) }.to raise_error(Sufia::VirusFoundError)
8
8
  end
9
9
  end
10
+
11
+ describe "#featured_work" do
12
+ let(:user) { FactoryGirl.create(:user) }
13
+ let(:gf) { FactoryGirl.create(:generic_file, visibility: 'open') }
14
+ let(:actor) { Sufia::GenericFile::Actor.new(gf, user)}
15
+
16
+ before { FeaturedWork.create(generic_file_id: gf.noid) }
17
+
18
+ after { gf.destroy }
19
+
20
+ it "should be removed if document is not public" do
21
+ # Switch document from public to restricted
22
+ attributes = {'permissions'=>{'group' =>{'public' => '1', 'registered'=>'2'}}}
23
+ expect { actor.update_metadata(attributes, 'restricted') }.to change { FeaturedWork.count }.by(-1)
24
+ end
25
+ end
26
+
10
27
  end
@@ -29,8 +29,8 @@ describe BatchController do
29
29
  end
30
30
  it "should not be editable" do
31
31
  ability = Ability.new(@user)
32
- ability.can?(:edit, @file).should be_true
33
- ability.can?(:edit, @file2).should be_false
32
+ expect(ability.can?(:edit, @file)).to be true
33
+ expect(ability.can?(:edit, @file2)).to be false
34
34
  end
35
35
  it "should enqueue a batch update job" do
36
36
  params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
@@ -14,50 +14,55 @@ describe BatchEditsController do
14
14
 
15
15
  describe "edit" do
16
16
  before do
17
- @one = GenericFile.new(creator: "Fred", language: 'en')#, resource_type: 'foo')
17
+ @one = GenericFile.new(creator: ["Fred"], language: ['en'])
18
18
  @one.apply_depositor_metadata('mjg36')
19
- @two = GenericFile.new(creator: "Wilma", publisher: 'Rand McNally', language: 'en', resource_type: 'bar')
19
+ @two = GenericFile.new(creator: ["Wilma"], publisher: ['Rand McNally'], language: ['en'], resource_type: ['bar'])
20
20
  @two.apply_depositor_metadata('mjg36')
21
21
  @one.save!
22
22
  @two.save!
23
23
  controller.batch = [@one.pid, @two.pid]
24
- controller.should_receive(:can?).with(:edit, @one.pid).and_return(true)
25
- controller.should_receive(:can?).with(:edit, @two.pid).and_return(true)
24
+ expect(controller).to receive(:can?).with(:edit, @one.pid).and_return(true)
25
+ expect(controller).to receive(:can?).with(:edit, @two.pid).and_return(true)
26
26
  end
27
27
  it "should be successful" do
28
28
  get :edit
29
29
  response.should be_successful
30
30
  assigns[:terms].should == [:creator, :contributor, :description, :tag, :rights, :publisher,
31
31
  :date_created, :subject, :language, :identifier, :based_near, :related_url]
32
- assigns[:show_file].creator.should == ["Fred", "Wilma"]
33
- assigns[:show_file].publisher.should == ["Rand McNally"]
34
- assigns[:show_file].language.should == ["en"]
32
+ expect(assigns[:show_file].creator).to eq ["Fred", "Wilma"]
33
+ expect(assigns[:show_file].publisher).to eq ["Rand McNally"]
34
+ expect(assigns[:show_file].language).to eq ["en"]
35
35
  end
36
36
  end
37
37
 
38
38
  describe "update" do
39
39
  before do
40
- @one = GenericFile.new(creator: "Fred", language: 'en')
40
+ @one = GenericFile.new(creator: ["Fred"], language: ['en'])
41
41
  @one.apply_depositor_metadata('mjg36')
42
- @two = GenericFile.new(creator: "Wilma", publisher: 'Rand McNally', language: 'en')
42
+ @two = GenericFile.new(creator: ["Wilma"], publisher: ['Rand McNally'], language: ['en'])
43
43
  @two.apply_depositor_metadata('mjg36')
44
44
  @one.save!
45
45
  @two.save!
46
46
  controller.batch = [@one.pid, @two.pid]
47
- controller.should_receive(:can?).with(:edit, @one.pid).and_return(true)
48
- controller.should_receive(:can?).with(:edit, @two.pid).and_return(true)
47
+ expect(controller).to receive(:can?).with(:edit, @one.pid).and_return(true)
48
+ expect(controller).to receive(:can?).with(:edit, @two.pid).and_return(true)
49
49
  end
50
+ let(:mycontroller) { "my/files" }
50
51
  it "should be successful" do
51
- put :update , update_type:"delete_all"
52
- response.should be_redirect
53
- expect {GenericFile.find(@one.id)}.to raise_error(ActiveFedora::ObjectNotFoundError)
54
- expect {GenericFile.find(@two.id)}.to raise_error(ActiveFedora::ObjectNotFoundError)
52
+ put :update , update_type: "delete_all"
53
+ expect(response).to redirect_to(Sufia::Engine.routes.url_for(controller: "dashboard", only_path: true))
54
+ expect { GenericFile.find(@one.id) }.to raise_error(ActiveFedora::ObjectNotFoundError)
55
+ expect { GenericFile.find(@two.id) }.to raise_error(ActiveFedora::ObjectNotFoundError)
56
+ end
57
+ it "should redirect to the return controller" do
58
+ put :update , update_type: "delete_all", return_controller: mycontroller
59
+ expect(response).to redirect_to(Sufia::Engine.routes.url_for(controller: mycontroller, only_path: true))
55
60
  end
56
61
  it "should update the records" do
57
- put :update , update_type:"update", "generic_file"=>{"subject"=>["zzz"]}
58
- response.should be_redirect
59
- GenericFile.find(@one.id).subject.should == ["zzz"]
60
- GenericFile.find(@two.id).subject.should == ["zzz"]
62
+ put :update , update_type: "update", "generic_file"=>{"subject"=>["zzz"]}
63
+ expect(response).to be_redirect
64
+ expect(GenericFile.find(@one.id).subject).to eq ["zzz"]
65
+ expect(GenericFile.find(@two.id).subject).to eq ["zzz"]
61
66
  end
62
67
  end
63
68
 
@@ -12,24 +12,35 @@ describe CatalogController do
12
12
  describe "#index" do
13
13
  before (:all) do
14
14
  @user = FactoryGirl.find_or_create(:jill)
15
- GenericFile.delete_all
16
- @gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', tag:'rocks', read_groups:['public'])
17
- @gf1.apply_depositor_metadata('mjg36')
18
- @gf1.save
15
+ @gf1 = GenericFile.new(title: 'Test Document PDF', filename: 'test.pdf', tag: 'rocks', read_groups: ['public']).tap do |f|
16
+ f.apply_depositor_metadata('mjg36')
17
+ f.save
18
+ end
19
19
 
20
- @gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', tag:'clouds', contributor:'Contrib1', read_groups:['public'])
21
- @gf2.apply_depositor_metadata('mjg36')
22
- @gf2.save
20
+ @gf2 = GenericFile.new(title: 'Test 2 Document', filename: 'test2.doc', tag: 'clouds', contributor: 'Contrib1', read_groups: ['public']).tap do |f|
21
+ f.apply_depositor_metadata('mjg36')
22
+ f.full_text.content = 'full_textfull_text'
23
+ f.save
24
+ end
23
25
 
24
- @editable_file = GenericFile.new.tap do |gf|
25
- gf.apply_depositor_metadata(@user.user_key)
26
- gf.save!
26
+ @editable_file = GenericFile.new.tap do |f|
27
+ f.apply_depositor_metadata(@user.user_key)
28
+ f.save!
27
29
  end
28
30
  end
29
31
 
30
32
  after (:all) do
31
- @gf1.delete
32
- @gf2.delete
33
+ GenericFile.destroy_all
34
+ end
35
+
36
+ describe 'full-text search' do
37
+ it 'finds records' do
38
+ get :index, q: 'full_textfull_text'
39
+ expect(response).to be_success
40
+ expect(response).to render_template('catalog/index')
41
+ assigns(:document_list).count.should eql(1)
42
+ assigns(:document_list).map(&:id).should == [@gf2.id]
43
+ end
33
44
  end
34
45
 
35
46
  describe "term search" do
@@ -38,33 +38,35 @@ describe CollectionsController do
38
38
  Collection.count.should == old_count+1
39
39
  end
40
40
  it "should create a Collection with files I can access" do
41
- @asset1 = GenericFile.new(title: "First of the Assets")
41
+ @asset1 = GenericFile.new(title: ["First of the Assets"])
42
42
  @asset1.apply_depositor_metadata(user.user_key)
43
43
  @asset1.save
44
- @asset2 = GenericFile.new(title: "Second of the Assets", depositor: user.user_key)
44
+ @asset2 = GenericFile.new(title: ["Second of the Assets"], depositor: user.user_key)
45
45
  @asset2.apply_depositor_metadata(user.user_key)
46
46
  @asset2.save
47
- @asset3 = GenericFile.new(title: "Third of the Assets", depositor:'abc')
47
+ @asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:'abc')
48
48
  @asset3.apply_depositor_metadata('abc')
49
49
  @asset3.save
50
50
  controller.should_receive(:has_access?).and_return(true)
51
51
  old_count = Collection.count
52
- post :create, collection: {title: "My own Collection ", description: "The Description\r\n\r\nand more"}, batch_document_ids:[@asset1.id, @asset2.id, @asset3.id]
52
+ post :create, collection: { title: "My own Collection", description: "The Description\r\n\r\nand more" },
53
+ batch_document_ids: [@asset1.id, @asset2.id, @asset3.id]
53
54
  Collection.count.should == old_count+1
54
55
  collection = assigns(:collection)
55
56
  collection.members.should include (@asset1)
56
57
  collection.members.should include (@asset2)
57
- collection.members.should_not include (@asset3)
58
+ collection.members.to_a.should_not include (@asset3) # .to_a to avoid a call to any? which doesn't exist in AF::HABTM
58
59
  @asset1.destroy
59
60
  @asset2.destroy
60
61
  @asset3.destroy
61
62
  end
62
63
 
63
64
  it "should add docs to collection if batch ids provided and add the collection id to the documents int he colledction" do
64
- @asset1 = GenericFile.new(title: "First of the Assets")
65
+ @asset1 = GenericFile.new(title: ["First of the Assets"])
65
66
  @asset1.apply_depositor_metadata(user.user_key)
66
67
  @asset1.save
67
- post :create, batch_document_ids: [@asset1.id], collection: {title: "My Secong Collection ", description: "The Description\r\n\r\nand more"}
68
+ post :create, batch_document_ids: [@asset1.id],
69
+ collection: { title: "My Secong Collection ", description: "The Description\r\n\r\nand more" }
68
70
  assigns[:collection].members.should == [@asset1]
69
71
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
70
72
  asset_results["response"]["numFound"].should == 1
@@ -78,16 +80,16 @@ describe CollectionsController do
78
80
 
79
81
  describe "#update" do
80
82
  before do
81
- @collection = Collection.new(title: "Collection Title")
83
+ @collection = Collection.new(title: ["Collection Title"])
82
84
  @collection.apply_depositor_metadata(user.user_key)
83
85
  @collection.save
84
- @asset1 = GenericFile.new(title: "First of the Assets")
86
+ @asset1 = GenericFile.new(title: ["First of the Assets"])
85
87
  @asset1.apply_depositor_metadata(user.user_key)
86
88
  @asset1.save
87
- @asset2 = GenericFile.new(title: "Second of the Assets", depositor: user.user_key)
89
+ @asset2 = GenericFile.new(title: ["Second of the Assets"], depositor: user.user_key)
88
90
  @asset2.apply_depositor_metadata(user.user_key)
89
91
  @asset2.save
90
- @asset3 = GenericFile.new(title: "Third of the Assets", depositor:'abc')
92
+ @asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:'abc')
91
93
  @asset3.apply_depositor_metadata(user.user_key)
92
94
  @asset3.save
93
95
  sign_in user
@@ -100,7 +102,7 @@ describe CollectionsController do
100
102
  end
101
103
 
102
104
  it "should set collection on members" do
103
- put :update, id: @collection.id, collection: {members:"add"}, batch_document_ids:[@asset3.pid,@asset1.pid, @asset2.pid]
105
+ put :update, id: @collection.id, collection: {members:"add"}, batch_document_ids: [@asset3.pid, @asset1.pid, @asset2.pid]
104
106
  response.should redirect_to Hydra::Collections::Engine.routes.url_helpers.collection_path(@collection.noid)
105
107
  assigns[:collection].members.map{|m| m.pid}.sort.should == [@asset2, @asset3, @asset1].map {|m| m.pid}.sort
106
108
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.pid}\""],fl:['id',Solrizer.solr_name(:collection)]}
@@ -109,7 +111,7 @@ describe CollectionsController do
109
111
  doc["id"].should == @asset2.id
110
112
  afterupdate = GenericFile.find(@asset2.pid)
111
113
  doc[Solrizer.solr_name(:collection)].should == afterupdate.to_solr[Solrizer.solr_name(:collection)]
112
- put :update, id: @collection.id, collection: {members:"remove"}, batch_document_ids:[@asset2]
114
+ put :update, id: @collection.id, collection: {members:"remove"}, batch_document_ids: [@asset2]
113
115
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.pid}\""],fl:['id',Solrizer.solr_name(:collection)]}
114
116
  asset_results["response"]["numFound"].should == 1
115
117
  doc = asset_results["response"]["docs"].first
@@ -121,16 +123,16 @@ describe CollectionsController do
121
123
 
122
124
  describe "#show" do
123
125
  before do
124
- @asset1 = GenericFile.new(title: "First of the Assets")
126
+ @asset1 = GenericFile.new(title: ["First of the Assets"])
125
127
  @asset1.apply_depositor_metadata(user.user_key)
126
128
  @asset1.save!
127
- @asset2 = GenericFile.new(title: "Second of the Assets", depositor:user.user_key)
129
+ @asset2 = GenericFile.new(title: ["Second of the Assets"], depositor:user.user_key)
128
130
  @asset2.apply_depositor_metadata(user.user_key)
129
131
  @asset2.save!
130
- @asset3 = GenericFile.new(title: "Third of the Assets", depositor:user.user_key)
132
+ @asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:user.user_key)
131
133
  @asset3.apply_depositor_metadata(user.user_key)
132
134
  @asset3.save!
133
- @asset4 = GenericFile.new(title: "Third of the Assets", depositor:user.user_key)
135
+ @asset4 = GenericFile.new(title: ["Third of the Assets"], depositor:user.user_key)
134
136
  @asset4.apply_depositor_metadata(user.user_key)
135
137
  @asset4.save!
136
138
  @collection = Collection.new
@@ -32,34 +32,20 @@ describe DashboardController do
32
32
 
33
33
  it "gathers the user's notifications" do
34
34
  get :index
35
- expect(assigns(:notifications)).to be_true
35
+ expect(assigns(:notifications)).to be_truthy
36
36
  end
37
37
 
38
38
  context "with activities" do
39
39
 
40
- before :all do
41
- @now = DateTime.now.to_i
42
- end
43
-
40
+ let(:activity) { double }
44
41
  before do
45
- allow_any_instance_of(User).to receive(:events).and_return(activities)
46
- end
47
-
48
- def activities
49
- [
50
- { action: 'so and so edited their profile', timestamp: @now },
51
- { action: 'so and so uploaded a file', timestamp: (@now - 360 ) }
52
- ]
42
+ allow(activity).to receive(:map).and_return(activity)
43
+ expect_any_instance_of(User).to receive(:get_all_user_activity).and_return(activity)
53
44
  end
54
45
 
55
46
  it "gathers the user's recent activity within the default amount of time" do
56
47
  get :index
57
- expect(assigns(:activity)).to eq(activities.reverse)
58
- end
59
-
60
- it "gathers the user's recent activity within a given timestamp" do
61
- get :index, { since: (@now - 60 ) }
62
- expect(assigns(:activity)).to eq([activities.first])
48
+ expect(assigns(:activity)).to eq activity
63
49
  end
64
50
 
65
51
  it "returns results in JSON" do
@@ -17,7 +17,10 @@ describe GenericFilesController do
17
17
  end
18
18
 
19
19
  after do
20
- GenericFile.unstub(:new)
20
+ begin
21
+ GenericFile.unstub(:new)
22
+ rescue RSpec::Mocks::MockExpectationError => e
23
+ end
21
24
  Batch.find("sample:batch_id").delete rescue
22
25
  @mock.delete unless @mock.inner_object.class == ActiveFedora::UnsavedDigitalObject
23
26
  end
@@ -63,7 +66,7 @@ describe GenericFilesController do
63
66
  # This is confirming that the correct file was attached
64
67
  saved_file.label.should == 'world.png'
65
68
  saved_file.content.checksum.should == 'f794b23c0c6fe1083d0ca8b58261a078cd968967'
66
- saved_file.content.dsChecksumValid.should be_true
69
+ expect(saved_file.content.dsChecksumValid).to be true
67
70
 
68
71
  # Confirming that date_uploaded and date_modified were set
69
72
  saved_file.date_uploaded.should == date_today
@@ -71,10 +74,8 @@ describe GenericFilesController do
71
74
  end
72
75
 
73
76
  it "should record what user created the first version of content" do
74
- #GenericFile.any_instance.stub(:to_solr).and_return({})
75
77
  file = fixture_file_upload('/world.png','image/png')
76
- xhr :post, :create, files: [file], Filename: "The world", terms_of_service: "1"
77
-
78
+ xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
78
79
  saved_file = GenericFile.find('test:123')
79
80
  version = saved_file.content.latest_version
80
81
  version.versionID.should == "content.0"
@@ -86,9 +87,10 @@ describe GenericFilesController do
86
87
  file = fixture_file_upload('/world.png','image/png')
87
88
  controller.stub(:add_posted_blob_to_asset)
88
89
  xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
90
+ GenericFile.unstub(:new)
89
91
  lambda {Batch.find("sample:batch_id")}.should raise_error(ActiveFedora::ObjectNotFoundError) # The controller shouldn't actually save the Batch, but it should write the batch id to the files.
90
- b = Batch.create(pid: "sample:batch_id")
91
- b.generic_files.first.pid.should == "test:123"
92
+ batch = Batch.create(pid: "sample:batch_id")
93
+ batch.generic_files.first.pid.should == "test:123"
92
94
  end
93
95
  it "should set the depositor id" do
94
96
  file = fixture_file_upload('/world.png','image/png')
@@ -123,15 +125,18 @@ describe GenericFilesController do
123
125
  describe "#create with browse-everything" do
124
126
  before do
125
127
  GenericFile.delete_all
126
- @json_from_browse_everything = {"0"=>{"url"=>"https://dl.dropbox.com/fake/filepicker-demo.txt.txt", "expires"=>"2014-03-31T20:37:36.214Z", "file_name"=>"filepicker-demo.txt.txt"}, "1"=>{"url"=>"https://dl.dropbox.com/fake/Getting%20Started.pdf", "expires"=>"2014-03-31T20:37:36.731Z", "file_name"=>"Getting+Started.pdf"}}
128
+ @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"}}
127
129
  end
128
130
  it "should ingest files from provide URLs" do
129
131
  ImportUrlJob.should_receive(:new).twice {"ImportJob"}
130
132
  Sufia.queue.should_receive(:push).with("ImportJob").twice
131
- lambda { post :create, selected_files: @json_from_browse_everything, batch_id: "sample:batch_id"}.should change(GenericFile, :count).by(2)
133
+ expect { post :create, selected_files: @json_from_browse_everything, batch_id: "sample:batch_id" }.to change(GenericFile, :count).by(2)
132
134
  created_files = GenericFile.all
133
- ["https://dl.dropbox.com/fake/Getting%20Started.pdf", "https://dl.dropbox.com/fake/filepicker-demo.txt.txt"].each do |url|
134
- created_files.map {|f| f.import_url}.should include(url)
135
+ ["https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt"].each do |url|
136
+ expect(created_files.map {|f| f.import_url}).to include(url)
137
+ end
138
+ ["filepicker-demo.txt.txt","Getting+Started.pdf"].each do |filename|
139
+ expect(created_files.map {|f| f.label}).to include(filename)
135
140
  end
136
141
  end
137
142
  end
@@ -167,8 +172,8 @@ describe GenericFilesController do
167
172
  lambda { post :create, local_file: ["world.png", "image.jpg"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(2)
168
173
  response.should redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path('xw42n7934')
169
174
  # These files should have been moved out of the upload directory
170
- File.exist?("#{@mock_upload_directory}/image.jpg").should be_false
171
- File.exist?("#{@mock_upload_directory}/world.png").should be_false
175
+ expect(File).not_to exist("#{@mock_upload_directory}/image.jpg")
176
+ expect(File).not_to exist("#{@mock_upload_directory}/world.png")
172
177
  # And into the storage directory
173
178
  files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
174
179
  files.first.label.should == 'world.png'
@@ -179,7 +184,7 @@ describe GenericFilesController do
179
184
  lambda { post :create, local_file: ["world.png"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(1)
180
185
  response.should redirect_to mock_url
181
186
  # These files should have been moved out of the upload directory
182
- File.exist?("#{@mock_upload_directory}/world.png").should be_false
187
+ expect(File).not_to exist("#{@mock_upload_directory}/world.png")
183
188
  # And into the storage directory
184
189
  files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
185
190
  files.first.label.should == 'world.png'
@@ -188,9 +193,9 @@ describe GenericFilesController do
188
193
  lambda { post :create, local_file: ["world.png", "import"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(4)
189
194
  response.should redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path('xw42n7934')
190
195
  # These files should have been moved out of the upload directory
191
- File.exist?("#{@mock_upload_directory}/import/files/icons.zip").should be_false
192
- File.exist?("#{@mock_upload_directory}/import/metadata/dublin_core_rdf_descMetadata.nt").should be_false
193
- File.exist?("#{@mock_upload_directory}/world.png").should be_false
196
+ expect(File).not_to exist("#{@mock_upload_directory}/import/files/icons.zip")
197
+ expect(File).not_to exist("#{@mock_upload_directory}/import/metadata/dublin_core_rdf_descMetadata.nt")
198
+ expect(File).not_to exist("#{@mock_upload_directory}/world.png")
194
199
  # And into the storage directory
195
200
  files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
196
201
  files.first.label.should == 'world.png'
@@ -224,7 +229,7 @@ describe GenericFilesController do
224
229
  response.should be_success
225
230
  lambda { JSON.parse(response.body) }.should_not raise_error
226
231
  audit_results = JSON.parse(response.body).collect { |result| result["pass"] }
227
- audit_results.reduce(true) { |sum, value| sum && value }.should be_true
232
+ expect(audit_results.reduce(true) { |sum, value| sum && value }).to be_truthy
228
233
  end
229
234
  end
230
235
 
@@ -250,6 +255,17 @@ describe GenericFilesController do
250
255
  Sufia.queue.should_receive(:push).with(s1).once
251
256
  delete :destroy, id: @generic_file.pid
252
257
  end
258
+
259
+ context "when the file is featured" do
260
+ before do
261
+ FeaturedWork.create(generic_file_id: @generic_file.pid)
262
+ end
263
+ it "should make the file not featured" do
264
+ expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to include(@generic_file.pid)
265
+ delete :destroy, id: @generic_file.pid
266
+ expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to_not include(@generic_file.pid)
267
+ end
268
+ end
253
269
  end
254
270
 
255
271
  describe 'stats' do
@@ -538,8 +554,7 @@ describe GenericFilesController do
538
554
  end
539
555
  it "should display failing audits" do
540
556
  sign_in @archivist
541
- @ds = @file.datastreams.first
542
- AuditJob.new(@file.pid, @ds[0], @ds[1].versionID).run
557
+ AuditJob.new(@file.pid, "RELS-EXT", @file.rels_ext.versionID).run
543
558
  get :show, id: "test5"
544
559
  assigns[:notify_number].should == 1
545
560
  @archivist.mailbox.inbox[0].messages[0].subject.should == "Failing Audit Run"
@@ -6,10 +6,10 @@ describe HomepageController do
6
6
  describe "#index" do
7
7
  before :all do
8
8
  GenericFile.delete_all
9
- @gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', tag:'rocks', read_groups:['public'])
9
+ @gf1 = GenericFile.new(title:['Test Document PDF'], filename:['test.pdf'], tag:['rocks'], read_groups:['public'])
10
10
  @gf1.apply_depositor_metadata('mjg36')
11
11
  @gf1.save
12
- @gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', tag:'clouds', contributor:'Contrib1', read_groups:['public'])
12
+ @gf2 = GenericFile.new(title:['Test 2 Document'], filename:['test2.doc'], tag:['clouds'], contributor:['Contrib1'], read_groups:['public'])
13
13
  @gf2.apply_depositor_metadata('mjg36')
14
14
  @gf2.save
15
15
  end
@@ -42,6 +42,29 @@ describe HomepageController do
42
42
  end
43
43
  end
44
44
 
45
+ context "with a document not created this second" do
46
+ before do
47
+ gf3 = GenericFile.new(title:['Test 3 Document'], read_groups:['public'])
48
+ gf3.apply_depositor_metadata('mjg36')
49
+ # stubbing to_solr so we know we have something that didn't create in the current second
50
+ old_to_solr = gf3.method(:to_solr)
51
+ allow(gf3).to receive(:to_solr) do
52
+ old_to_solr.call.merge(
53
+ Solrizer.solr_name('system_create', :stored_sortable, type: :date) => 1.day.ago.iso8601
54
+ )
55
+ end
56
+ gf3.save
57
+ end
58
+
59
+ it "should set recent documents in the right order" do
60
+ get :index
61
+ expect(response).to be_success
62
+ expect(assigns(:recent_documents).length).to be <= 4
63
+ create_times = assigns(:recent_documents).map{|d| d['system_create_dtsi']}
64
+ expect(create_times).to eq create_times.sort.reverse
65
+ end
66
+ end
67
+
45
68
  context "with featured works" do
46
69
  before do
47
70
  FeaturedWork.create!(generic_file_id: @gf1.id)