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
@@ -5,21 +5,21 @@ describe UsersController do
5
5
  @user = FactoryGirl.find_or_create(:jill)
6
6
  @another_user = FactoryGirl.find_or_create(:archivist)
7
7
  sign_in @user
8
- User.any_instance.stub(:groups).and_return([])
9
- controller.stub(:clear_session_user) ## Don't clear out the authenticated session
8
+ allow_any_instance_of(User).to receive(:groups).and_return([])
9
+ allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
10
10
  end
11
11
 
12
12
  describe "#show" do
13
13
  it "show the user profile if user exists" do
14
14
  get :show, id: @user.user_key
15
- response.should be_success
16
- response.should_not redirect_to(root_path)
17
- flash[:alert].should be_nil
15
+ expect(response).to be_success
16
+ expect(response).to_not redirect_to(root_path)
17
+ expect(flash[:alert]).to be_nil
18
18
  end
19
19
  it "redirects to root if user does not exist" do
20
20
  get :show, id: 'johndoe666'
21
- response.should redirect_to(root_path)
22
- flash[:alert].should include ("User 'johndoe666' does not exist")
21
+ expect(response).to redirect_to(root_path)
22
+ expect(flash[:alert]).to include ("User 'johndoe666' does not exist")
23
23
  end
24
24
 
25
25
  describe "when the user has trophies" do
@@ -33,8 +33,8 @@ describe UsersController do
33
33
 
34
34
  it "show the user profile if user exists" do
35
35
  get :show, id: user.user_key
36
- response.should be_success
37
- assigns[:trophies].should match_array([file1, file2, file3])
36
+ expect(response).to be_success
37
+ expect(assigns[:trophies]).to match_array([file1, file2, file3])
38
38
  end
39
39
 
40
40
  end
@@ -47,36 +47,36 @@ describe UsersController do
47
47
  describe "requesting html" do
48
48
  it "should test users" do
49
49
  get :index
50
- assigns[:users].should include(@u1, @u2)
51
- response.should be_successful
50
+ expect(assigns[:users]).to include(@u1, @u2)
51
+ expect(response).to be_successful
52
52
  end
53
53
  end
54
54
  describe "requesting json" do
55
55
  it "should display users" do
56
56
  get :index, format: :json
57
- response.should be_successful
57
+ expect(response).to be_successful
58
58
  json = JSON.parse(response.body)
59
- json.map{|u| u['id']}.should include(@u1.email, @u2.email)
60
- json.map{|u| u['text']}.should include(@u1.email, @u2.email)
59
+ expect(json.map{|u| u['id']}).to include(@u1.email, @u2.email)
60
+ expect(json.map{|u| u['text']}).to include(@u1.email, @u2.email)
61
61
  end
62
62
  end
63
63
  describe "query users" do
64
64
  it "finds the expected user via email" do
65
65
  get :index, uq: @u1.email
66
- assigns[:users].should include(@u1)
67
- assigns[:users].should_not include(@u2)
68
- response.should be_successful
66
+ expect(assigns[:users]).to include(@u1)
67
+ expect(assigns[:users]).to_not include(@u2)
68
+ expect(response).to be_successful
69
69
  end
70
70
  it "finds the expected user via display name" do
71
71
  @u1.display_name = "Dr. Curator"
72
72
  @u1.save
73
73
  @u2.display_name = "Jr. Architect"
74
74
  @u2.save
75
- User.any_instance.stub(:display_name).and_return("Dr. Curator", "Jr.Archivist")
75
+ allow_any_instance_of(User).to receive(:display_name).and_return("Dr. Curator", "Jr.Archivist")
76
76
  get :index, uq: @u1.display_name
77
- assigns[:users].should include(@u1)
78
- assigns[:users].should_not include(@u2)
79
- response.should be_successful
77
+ expect(assigns[:users]).to include(@u1)
78
+ expect(assigns[:users]).to_not include(@u2)
79
+ expect(response).to be_successful
80
80
  @u1.display_name = nil
81
81
  @u1.save
82
82
  @u2.display_name = nil
@@ -84,10 +84,10 @@ describe UsersController do
84
84
  end
85
85
  it "uses the base query" do
86
86
  u3 = FactoryGirl.find_or_create(:jill)
87
- controller.stub(:base_query).and_return(['email == "jilluser@example.com"'])
87
+ allow(controller).to receive(:base_query).and_return(['email == "jilluser@example.com"'])
88
88
  get :index
89
- assigns[:users].should include(u3)
90
- assigns[:users].should_not include(@u1, @u2)
89
+ expect(assigns[:users]).to include(u3)
90
+ expect(assigns[:users]).to_not include(@u1, @u2)
91
91
  u3.destroy
92
92
  end
93
93
  end
@@ -95,14 +95,14 @@ describe UsersController do
95
95
  describe "#edit" do
96
96
  it "show edit form when user edits own profile" do
97
97
  get :edit, id: @user.user_key
98
- response.should be_success
99
- response.should render_template('users/edit')
100
- flash[:alert].should be_nil
98
+ expect(response).to be_success
99
+ expect(response).to render_template('users/edit')
100
+ expect(flash[:alert]).to be_nil
101
101
  end
102
102
  it "redirects to show profile when user attempts to edit another profile" do
103
103
  get :edit, id: @another_user.user_key
104
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
105
- flash[:alert].should include("Permission denied: cannot access this page.")
104
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
105
+ expect(flash[:alert]).to include("Permission denied: cannot access this page.")
106
106
  end
107
107
  describe "when the user has trophies" do
108
108
  let(:user) { @user }
@@ -115,8 +115,8 @@ describe UsersController do
115
115
 
116
116
  it "show the user profile if user exists" do
117
117
  get :edit, id: @user.user_key
118
- response.should be_success
119
- assigns[:trophies].should match_array([file1, file2, file3])
118
+ expect(response).to be_success
119
+ expect(assigns[:trophies]).to match_array([file1, file2, file3])
120
120
  end
121
121
 
122
122
  end
@@ -124,33 +124,33 @@ describe UsersController do
124
124
  describe "#update" do
125
125
  it "should not allow other users to update" do
126
126
  post :update, id: @another_user.user_key, user: { avatar: nil }
127
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
128
- flash[:alert].should include("Permission denied: cannot access this page.")
127
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
128
+ expect(flash[:alert]).to include("Permission denied: cannot access this page.")
129
129
  end
130
130
  it "should set an avatar and redirect to profile" do
131
- @user.avatar?.should be_false
131
+ expect(@user.avatar?).to be false
132
132
  s1 = double('one')
133
- UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
134
- Sufia.queue.should_receive(:push).with(s1).once
135
- f = fixture_file_upload('/world.png', 'image/png')
133
+ expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
134
+ expect(Sufia.queue).to receive(:push).with(s1).once
135
+ f = fixture_file_upload('/1.5mb-avatar.jpg', 'image/jpg')
136
136
  post :update, id: @user.user_key, user: { avatar: f }
137
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
138
- flash[:notice].should include("Your profile has been updated")
139
- User.find_by_user_key(@user.user_key).avatar?.should be_true
137
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
138
+ expect(flash[:notice]).to include("Your profile has been updated")
139
+ expect(User.find_by_user_key(@user.user_key).avatar?).to be true
140
140
  end
141
141
  it "should validate the content type of an avatar" do
142
- Sufia.queue.should_receive(:push).never
142
+ expect(Sufia.queue).to receive(:push).never
143
143
  f = fixture_file_upload('/image.jp2', 'image/jp2')
144
144
  post :update, id: @user.user_key, user: { avatar: f }
145
- response.should redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
146
- flash[:alert].should include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
145
+ expect(response).to redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
146
+ expect(flash[:alert]).to include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
147
147
  end
148
148
  it "should validate the size of an avatar" do
149
149
  f = fixture_file_upload('/4-20.png', 'image/png')
150
- Sufia.queue.should_receive(:push).never
150
+ expect(Sufia.queue).to receive(:push).never
151
151
  post :update, id: @user.user_key, user: { avatar: f }
152
- response.should redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
153
- flash[:alert].should include("Avatar file size must be less than 2MB")
152
+ expect(response).to redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
153
+ expect(flash[:alert]).to include("Avatar file size must be less than 2MB")
154
154
  end
155
155
  context "user with existing avatar" do
156
156
  before do
@@ -160,36 +160,36 @@ describe UsersController do
160
160
  end
161
161
  it "should delete an avatar" do
162
162
  s1 = double('one')
163
- UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
164
- Sufia.queue.should_receive(:push).with(s1).once
165
- post :update, id: @user.user_key, delete_avatar: true
166
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
167
- flash[:notice].should include("Your profile has been updated")
168
- User.find_by_user_key(@user.user_key).avatar?.should be_false
163
+ expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
164
+ expect(Sufia.queue).to receive(:push).with(s1).once
165
+ post :update, id: @user.user_key, user: { remove_avatar: true }
166
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
167
+ expect(flash[:notice]).to include("Your profile has been updated")
168
+ expect(User.find_by_user_key(@user.user_key).avatar?).to be false
169
169
  end
170
170
  end
171
171
  it "should refresh directory attributes" do
172
172
  s1 = double('one')
173
- UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
174
- Sufia.queue.should_receive(:push).with(s1).once
175
- User.any_instance.should_receive(:populate_attributes).once
176
- post :update, id: @user.user_key, update_directory: true
177
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
178
- flash[:notice].should include("Your profile has been updated")
173
+ expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
174
+ expect(Sufia.queue).to receive(:push).with(s1).once
175
+ expect_any_instance_of(User).to receive(:populate_attributes).once
176
+ post :update, id: @user.user_key, user: { update_directory: true }
177
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
178
+ expect(flash[:notice]).to include("Your profile has been updated")
179
179
  end
180
180
  it "should set an social handles" do
181
- @user.twitter_handle.blank?.should be_true
182
- @user.facebook_handle.blank?.should be_true
183
- @user.googleplus_handle.blank?.should be_true
184
- @user.linkedin_handle.blank?.should be_true
181
+ expect(@user.twitter_handle).to be_blank
182
+ expect(@user.facebook_handle).to be_blank
183
+ expect(@user.googleplus_handle).to be_blank
184
+ expect(@user.linkedin_handle).to be_blank
185
185
  post :update, id: @user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle:"link" }
186
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
187
- flash[:notice].should include("Your profile has been updated")
186
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
187
+ expect(flash[:notice]).to include("Your profile has been updated")
188
188
  u = User.find_by_user_key(@user.user_key)
189
- u.twitter_handle.should == 'twit'
190
- u.facebook_handle.should == 'face'
191
- u.googleplus_handle.should == 'goo'
192
- u.linkedin_handle.should == 'link'
189
+ expect(u.twitter_handle).to eq 'twit'
190
+ expect(u.facebook_handle).to eq 'face'
191
+ expect(u.googleplus_handle).to eq 'goo'
192
+ expect(u.linkedin_handle).to eq 'link'
193
193
  end
194
194
 
195
195
  context "when removing a trophy" do
@@ -202,8 +202,8 @@ describe UsersController do
202
202
  expect {
203
203
  post :update, id: user.user_key, 'remove_trophy_'+file.noid => 'yes'
204
204
  }.to change { user.trophies.count }.by(-1)
205
- response.should redirect_to(@routes.url_helpers.profile_path(user.to_param))
206
- flash[:notice].should include("Your profile has been updated")
205
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
206
+ expect(flash[:notice]).to include("Your profile has been updated")
207
207
  end
208
208
  end
209
209
  end
@@ -213,54 +213,50 @@ describe UsersController do
213
213
  @user.unfollow(@another_user) rescue nil
214
214
  end
215
215
  it "should follow another user if not already following, and log an event" do
216
- @user.following?(@another_user).should be_false
216
+ expect(@user.following?(@another_user)).to be false
217
217
  s1 = double('one')
218
- UserFollowEventJob.should_receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
219
- Sufia.queue.should_receive(:push).with(s1).once
218
+ expect(UserFollowEventJob).to receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
219
+ expect(Sufia.queue).to receive(:push).with(s1).once
220
220
  post :follow, id: @another_user.user_key
221
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
222
- flash[:notice].should include("You are following #{@another_user.user_key}")
221
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
222
+ expect(flash[:notice]).to include("You are following #{@another_user.user_key}")
223
223
  end
224
224
  it "should redirect to profile if already following and not log an event" do
225
- User.any_instance.stub(:following?).with(@another_user).and_return(true)
226
- #Resque.should_receive(:enqueue).with(UserFollowEventJob, @user.user_key, @another_user.user_key).never
227
- Sufia.queue.should_receive(:push).never
225
+ allow_any_instance_of(User).to receive(:following?).with(@another_user).and_return(true)
226
+ expect(Sufia.queue).to receive(:push).never
228
227
  post :follow, id: @another_user.user_key
229
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
230
- flash[:notice].should include("You are following #{@another_user.user_key}")
228
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
229
+ expect(flash[:notice]).to include("You are following #{@another_user.user_key}")
231
230
  end
232
231
  it "should redirect to profile if user attempts to self-follow and not log an event" do
233
- #Resque.should_receive(:enqueue).with(UserFollowEventJob, @user.user_key, @user.user_key).never
234
- Sufia.queue.should_receive(:push).never
232
+ expect(Sufia.queue).to receive(:push).never
235
233
  post :follow, id: @user.user_key
236
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
237
- flash[:alert].should include("You cannot follow or unfollow yourself")
234
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
235
+ expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
238
236
  end
239
237
  end
240
238
  describe "#unfollow" do
241
239
  it "should unfollow another user if already following, and log an event" do
242
- User.any_instance.stub(:following?).with(@another_user).and_return(true)
240
+ allow_any_instance_of(User).to receive(:following?).with(@another_user).and_return(true)
243
241
  s1 = double('one')
244
- UserUnfollowEventJob.should_receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
245
- Sufia.queue.should_receive(:push).with(s1).once
242
+ expect(UserUnfollowEventJob).to receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
243
+ expect(Sufia.queue).to receive(:push).with(s1).once
246
244
  post :unfollow, id: @another_user.user_key
247
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
248
- flash[:notice].should include("You are no longer following #{@another_user.user_key}")
245
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
246
+ expect(flash[:notice]).to include("You are no longer following #{@another_user.user_key}")
249
247
  end
250
248
  it "should redirect to profile if not following and not log an event" do
251
- @user.stub(:following?).with(@another_user).and_return(false)
252
- #Resque.should_receive(:enqueue).with(UserUnfollowEventJob, @user.user_key, @another_user.user_key).never
253
- Sufia.queue.should_receive(:push).never
249
+ allow(@user).to receive(:following?).with(@another_user).and_return(false)
250
+ expect(Sufia.queue).to receive(:push).never
254
251
  post :unfollow, id: @another_user.user_key
255
- response.should redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
256
- flash[:notice].should include("You are no longer following #{@another_user.user_key}")
252
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
253
+ expect(flash[:notice]).to include("You are no longer following #{@another_user.user_key}")
257
254
  end
258
255
  it "should redirect to profile if user attempts to self-follow and not log an event" do
259
- #Resque.should_receive(:enqueue).with(UserUnfollowEventJob, @user.user_key, @user.user_key).never
260
- Sufia.queue.should_receive(:push).never
256
+ expect(Sufia.queue).to receive(:push).never
261
257
  post :unfollow, id: @user.user_key
262
- response.should redirect_to(@routes.url_helpers.profile_path(@user.to_param))
263
- flash[:alert].should include("You cannot follow or unfollow yourself")
258
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
259
+ expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
264
260
  end
265
261
  end
266
262
  describe "#toggle_trophy" do
@@ -275,18 +271,19 @@ describe UsersController do
275
271
  end
276
272
  it "should trophy a file" do
277
273
  post :toggle_trophy, {id: @user.user_key, file_id: @file_id}
278
- JSON.parse(response.body)['user_id'].should == @user.id
279
- JSON.parse(response.body)['generic_file_id'].should == @file_id
274
+ json = JSON.parse(response.body)
275
+ expect(json['user_id']).to eq @user.id
276
+ expect(json['generic_file_id']).to eq @file_id
280
277
  end
281
278
  it "should not trophy a file for a different user" do
282
279
  post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
283
- response.should_not be_success
280
+ expect(response).to_not be_success
284
281
  end
285
282
  it "should not trophy a file with no edit privs" do
286
283
  sign_out @user
287
284
  sign_in @another_user
288
285
  post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
289
- response.should_not be_success
286
+ expect(response).to_not be_success
290
287
  end
291
288
  end
292
289
  end
@@ -18,11 +18,11 @@ FactoryGirl.define do
18
18
  end
19
19
  initialize_with { new(pid: pid) }
20
20
  read_groups ["public"]
21
- resource_type "Dissertation"
21
+ resource_type ["Dissertation"]
22
22
  subject %w"lorem ipsum dolor sit amet"
23
23
  before(:create) do |gf|
24
24
  gf.apply_depositor_metadata "archivist1@example.com"
25
- gf.title = "Fake Document Title"
25
+ gf.title = ["Fake Document Title"]
26
26
  gf.label = "fake_document.pdf"
27
27
  end
28
28
  end
@@ -13,13 +13,43 @@ FactoryGirl.define do
13
13
 
14
14
  factory :user_with_mail do
15
15
  after(:create) do |user|
16
- message = '<span class="batchid ui-helper-hidden">fake_batch_noid</span>You\'ve got mail.'
17
- User.batchuser().send_message(user, message, "Sample notification.")
16
+ # TODO: what is this class for?
17
+ # <span class="batchid ui-helper-hidden">fake_batch_noid</span>
18
+ message = BatchMessage.new
19
+
20
+ # Create examples of single file successes and failures
21
+ (1..10).each do |number|
22
+ file = MockFile.new(number.to_s, "Single File #{number.to_s}")
23
+ User.batchuser().send_message(user, message.single_success("single-batch-success", file), message.success_subject, sanitize_text = false)
24
+ User.batchuser().send_message(user, message.single_failure("single-batch-failure", file), message.failure_subject, sanitize_text = false)
25
+ end
26
+
27
+ # Create examples of mulitple file successes and failures
28
+ files = []
29
+ (1..50).each do |number|
30
+ files << MockFile.new(number.to_s, "File #{number.to_s}")
31
+ end
32
+ User.batchuser().send_message(user, message.multiple_success("multiple-batch-success", files), message.success_subject, sanitize_text = false)
33
+ User.batchuser().send_message(user, message.multiple_failure("multiple-batch-failure", files), message.failure_subject, sanitize_text = false)
18
34
  end
19
35
  end
20
36
 
21
37
  factory :curator do
22
38
  email 'curator1@example.com'
23
39
  end
40
+
41
+ end
42
+ end
43
+
44
+ class MockFile
45
+ attr_accessor :noid, :to_s, :id
46
+ def initialize id, string
47
+ self.noid = id
48
+ self.id = id
49
+ self.to_s = string
24
50
  end
25
51
  end
52
+
53
+ class BatchMessage
54
+ include Sufia::Messages
55
+ end
@@ -20,15 +20,27 @@ describe "Browse Dashboard" do
20
20
  visit "dashboard/files"
21
21
  end
22
22
 
23
- it "should show me some files" do
23
+ it "should display all the necessary information" do
24
24
  expect(page).to have_content("Edit File")
25
25
  expect(page).to have_content("Download File")
26
+ expect(page).to_not have_content("Is part of:")
27
+ first(".label-success") do
28
+ expect(page).to have_content("Open Access")
29
+ end
30
+ expect(page).to have_link("Create Collection")
31
+ expect(page).to have_link("Upload")
26
32
  end
27
33
 
28
- it "should allow you to search your own files" do
34
+ it "should allow you to search your own files and remove constraints" do
29
35
  fill_in "q", with: "PDF"
30
36
  click_button "search-submit-header"
31
37
  expect(page).to have_content("Fake Document Title")
38
+ within(".constraints-container") do
39
+ expect(page).to have_content("You searched for:")
40
+ expect(page).to have_css("span.glyphicon-remove")
41
+ find(".dropdown-toggle").click
42
+ end
43
+ expect(page).to have_content("Fake Wav File")
32
44
  end
33
45
 
34
46
  it "should allow you to browse facets" do
@@ -2,9 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe "Browse files" do
4
4
 
5
+ before do
6
+ allow(User).to receive(:find_by_user_key).and_return(stub_model(User, twitter_handle: 'bob'))
7
+ end
8
+
5
9
  before(:all) do
6
10
  @fixtures = find_or_create_file_fixtures
7
- @fixtures[0].tag = "key"
11
+ @fixtures[0].tag = ["key"]
8
12
  (1..25).each do |i|
9
13
  @fixtures[0].tag << i
10
14
  end