sufia 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +247 -215
  3. data/README.md +7 -3
  4. data/SUFIA_VERSION +1 -1
  5. data/app/assets/javascripts/sufia.js +5 -2
  6. data/app/assets/javascripts/sufia/proxy_rights.js +68 -0
  7. data/app/assets/javascripts/sufia/transfers.js +3 -0
  8. data/app/assets/javascripts/sufia/user_search.js +31 -0
  9. data/app/assets/stylesheets/jquery-ui.css +17 -17
  10. data/app/assets/stylesheets/sufia.css.scss +3 -2
  11. data/app/assets/stylesheets/sufia/_proxy-rights.scss +10 -0
  12. data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +22 -23
  13. data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +41 -0
  14. data/app/controllers/concerns/sufia/files_controller_behavior.rb +1 -0
  15. data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +76 -0
  16. data/app/controllers/concerns/sufia/users_controller_behavior.rb +9 -11
  17. data/app/controllers/depositors_controller.rb +3 -0
  18. data/app/controllers/transfers_controller.rb +3 -0
  19. data/app/helpers/sufia/dashboard_helper_behavior.rb +15 -0
  20. data/app/helpers/sufia/sufia_helper_behavior.rb +24 -2
  21. data/app/jobs/content_depositor_change_event_job.rb +50 -0
  22. data/app/views/dashboard/_index_partials/_contents.html.erb +18 -0
  23. data/app/views/dashboard/_index_partials/_proxy_rights.html.erb +23 -0
  24. data/app/views/dashboard/_index_partials/_transfers.html.erb +14 -0
  25. data/app/views/generic_files/proxy.html.erb +5 -0
  26. data/app/views/generic_files/upload/_form.html.erb +7 -2
  27. data/app/views/my/_action_menu.html.erb +3 -1
  28. data/app/views/records/edit_fields/_default.html.erb +1 -1
  29. data/app/views/transfers/_received.html.erb +58 -0
  30. data/app/views/transfers/_sent.html.erb +38 -0
  31. data/app/views/transfers/index.html.erb +7 -0
  32. data/app/views/transfers/new.html.erb +23 -0
  33. data/app/views/users/_proxies.html.erb +8 -0
  34. data/app/views/users/_user_util_links_extra.html.erb +1 -0
  35. data/app/views/users/edit.html.erb +6 -1
  36. data/config/locales/sufia.en.yml +9 -4
  37. data/config/routes.rb +14 -3
  38. data/lib/sufia.rb +7 -5
  39. data/lib/sufia/version.rb +1 -1
  40. data/spec/controllers/authorities_controller_spec.rb +6 -6
  41. data/spec/controllers/batch_controller_spec.rb +29 -29
  42. data/spec/controllers/batch_edits_controller_spec.rb +7 -7
  43. data/spec/controllers/catalog_controller_spec.rb +9 -9
  44. data/spec/controllers/collections_controller_spec.rb +28 -28
  45. data/spec/controllers/content_blocks_controller_spec.rb +3 -3
  46. data/spec/controllers/dashboard_controller_spec.rb +1 -1
  47. data/spec/controllers/depositors_controller_spec.rb +50 -0
  48. data/spec/controllers/downloads_controller_spec.rb +22 -22
  49. data/spec/controllers/featured_work_lists_controller_spec.rb +1 -1
  50. data/spec/controllers/featured_works_controller_spec.rb +1 -1
  51. data/spec/controllers/generic_files_controller_spec.rb +98 -90
  52. data/spec/controllers/homepage_controller_spec.rb +1 -1
  53. data/spec/controllers/mailbox_controller_spec.rb +10 -10
  54. data/spec/controllers/my/collections_controller_spec.rb +1 -1
  55. data/spec/controllers/my/files_controller_spec.rb +1 -1
  56. data/spec/controllers/my/highlights_controller_spec.rb +1 -1
  57. data/spec/controllers/my/shares_controller_spec.rb +1 -1
  58. data/spec/controllers/my_controller_spec.rb +1 -1
  59. data/spec/controllers/pages_controller_spec.rb +1 -1
  60. data/spec/controllers/single_use_links_controller_spec.rb +46 -50
  61. data/spec/controllers/single_use_links_viewer_controller_spec.rb +16 -16
  62. data/spec/controllers/static_controller_spec.rb +9 -9
  63. data/spec/controllers/tinymce_assets_controller_spec.rb +1 -1
  64. data/spec/controllers/transfers_controller_spec.rb +212 -0
  65. data/spec/controllers/users_controller_spec.rb +1 -1
  66. data/spec/factories/generic_files.rb +4 -4
  67. data/spec/factories/proxy_deposit_requests.rb +6 -0
  68. data/spec/features/browse_dashboard_files_spec.rb +25 -36
  69. data/spec/features/browse_files_spec.rb +18 -13
  70. data/spec/features/catalog_search_spec.rb +3 -6
  71. data/spec/features/cloud_upload_spec.rb +5 -7
  72. data/spec/features/collection_spec.rb +28 -35
  73. data/spec/features/contact_form_spec.rb +24 -24
  74. data/spec/features/display_dashboard_spec.rb +11 -11
  75. data/spec/features/ingest_upload_files_spec.rb +10 -10
  76. data/spec/features/notifications_spec.rb +11 -11
  77. data/spec/features/ownership_transfer_spec.rb +111 -0
  78. data/spec/features/proxy_spec.rb +52 -0
  79. data/spec/features/search_spec.rb +1 -1
  80. data/spec/features/single_use_links_spec.rb +28 -18
  81. data/spec/features/users_spec.rb +3 -3
  82. data/spec/helpers/batch_edits_helper_spec.rb +1 -1
  83. data/spec/helpers/content_block_helper_spec.rb +1 -1
  84. data/spec/helpers/dashboard_helper_spec.rb +1 -1
  85. data/spec/helpers/generic_file_helper_spec.rb +1 -1
  86. data/spec/helpers/records_helper_spec.rb +1 -1
  87. data/spec/helpers/sufia_helper_spec.rb +8 -8
  88. data/spec/helpers/trophy_helper_spec.rb +1 -1
  89. data/spec/jobs/audit_job_spec.rb +5 -5
  90. data/spec/jobs/batch_update_job_spec.rb +14 -14
  91. data/spec/jobs/content_depositor_change_event_job_spec.rb +22 -0
  92. data/spec/jobs/event_jobs_spec.rb +104 -104
  93. data/spec/jobs/import_url_job_spec.rb +2 -2
  94. data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
  95. data/spec/lib/sufia/breadcrumbs_spec.rb +3 -3
  96. data/spec/lib/sufia/id_service_spec.rb +1 -1
  97. data/spec/lib/sufia/upload_complete_behavior_spec.rb +4 -4
  98. data/spec/models/ability_spec.rb +59 -15
  99. data/spec/models/batch_spec.rb +16 -16
  100. data/spec/models/characterization_spec.rb +1 -1
  101. data/spec/models/checksum_audit_log_spec.rb +34 -26
  102. data/spec/models/collection_spec.rb +1 -1
  103. data/spec/models/download_spec.rb +1 -1
  104. data/spec/models/featured_work_list_spec.rb +1 -1
  105. data/spec/models/featured_work_spec.rb +15 -4
  106. data/spec/models/file_content_datastream_spec.rb +14 -14
  107. data/spec/models/file_usage_spec.rb +1 -1
  108. data/spec/models/fits_datastream_spec.rb +1 -1
  109. data/spec/models/generic_file/reload_on_save_spec.rb +4 -4
  110. data/spec/models/generic_file/visibility_spec.rb +1 -1
  111. data/spec/models/generic_file/web_form_spec.rb +6 -5
  112. data/spec/models/generic_file_rdf_datastream_spec.rb +1 -1
  113. data/spec/models/generic_file_spec.rb +254 -220
  114. data/spec/models/geo_names_resource_spec.rb +2 -2
  115. data/spec/models/local_authority_spec.rb +60 -59
  116. data/spec/models/pageview_spec.rb +1 -1
  117. data/spec/models/properties_datastream_spec.rb +29 -10
  118. data/spec/models/proxy_deposit_request_spec.rb +107 -0
  119. data/spec/models/single_use_link_spec.rb +13 -13
  120. data/spec/models/solr_document_spec.rb +1 -1
  121. data/spec/models/trophy_spec.rb +6 -6
  122. data/spec/models/user_spec.rb +38 -22
  123. data/spec/routing/featured_works_route_spec.rb +1 -1
  124. data/spec/routing/ownership_transfers_route_spec.rb +45 -0
  125. data/spec/routing/route_spec.rb +42 -42
  126. data/spec/services/noid_spec.rb +2 -2
  127. data/spec/spec_helper.rb +10 -5
  128. data/spec/support/cleaner.rb +12 -0
  129. data/spec/support/features.rb +5 -0
  130. data/spec/support/features/session_helpers.rb +3 -17
  131. data/spec/support/locations.rb +36 -0
  132. data/spec/support/poltergeist.rb +11 -0
  133. data/spec/support/proxies.rb +14 -0
  134. data/spec/support/selectors.rb +122 -0
  135. data/spec/views/batch/edit.html.erb_spec.rb +1 -1
  136. data/spec/views/batch_edits/check_all_spec.rb +4 -4
  137. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  138. data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +1 -1
  139. data/spec/views/collections/_form.html.erb_spec.rb +3 -1
  140. data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
  141. data/spec/views/dashboard/index_spec.rb +3 -6
  142. data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
  143. data/spec/views/generic_file/show.html.erb_spec.rb +1 -1
  144. data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
  145. data/spec/views/my/facet.html.erb_spec.rb +2 -2
  146. data/spec/views/users/_follower_modal.html.erb_spec.rb +1 -1
  147. data/spec/views/users/_following_modal.html.erb_spec.rb +1 -1
  148. data/spec/views/users/_notify_number.html.erb_spec.rb +1 -1
  149. data/spec/views/users/_user_util_links.html.erb_spec.rb +1 -1
  150. data/spec/views/users/index.html.erb_spec.rb +2 -2
  151. data/spec/views/users/show.html.erb_spec.rb +2 -2
  152. data/sufia-models/app/models/concerns/sufia/ability.rb +22 -0
  153. data/sufia-models/app/models/concerns/sufia/generic_file.rb +1 -0
  154. data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +22 -0
  155. data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +3 -0
  156. data/sufia-models/app/models/concerns/sufia/user.rb +9 -0
  157. data/sufia-models/app/models/proxy_deposit_request.rb +85 -0
  158. data/sufia-models/app/models/proxy_deposit_rights.rb +4 -0
  159. data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
  160. data/sufia-models/lib/generators/sufia/models/install_generator.rb +9 -1
  161. data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +53 -0
  162. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +16 -0
  163. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +11 -0
  164. data/sufia-models/lib/sufia/models/engine.rb +1 -1
  165. data/sufia-models/lib/sufia/models/version.rb +1 -1
  166. data/sufia.gemspec +2 -1
  167. data/tasks/sufia-dev.rake +5 -0
  168. metadata +82 -6
  169. data/tasks/sufia-db.rake +0 -21
@@ -72,6 +72,11 @@ en:
72
72
  user_notiticiations: "User Notifications"
73
73
  no_notifications: "User has no notifications"
74
74
  additional_notifications: "See all notifications"
75
+ proxy_activity: "Proxy Activity"
76
+ transfer_of_ownership: "Transfer of Ownership"
77
+ transfer_files_link: "Select files to transfer"
78
+ no_transfer_requests: "You haven't received any file transfer requests"
79
+ no_transfers: "You haven't transferred any files"
75
80
  stats:
76
81
  heading: "Your Statistics"
77
82
  files: "Files you've deposited"
@@ -103,14 +108,14 @@ en:
103
108
  multiple:
104
109
  link: "These files"
105
110
  tag: "have been saved."
106
- title: "Files uploaded successfully"
111
+ title: "Files uploaded successfully"
107
112
  subject: "Batch upload complete"
108
113
  failure:
109
114
  single: "could not be updated. You do not have sufficient privileges to edit it."
110
115
  multiple:
111
- link: "These files"
116
+ link: "These files"
112
117
  tag: "could not be updated. You do not have sufficient privileges to edit them."
113
- title: "Files failed"
118
+ title: "Files failed"
114
119
  subject: "Batch upload permission denied"
115
120
  metadata_help:
116
121
  resource_type: "Pre-defined categories to describe the type of file content being uploaded, such as \"article\" or \"dataset.\" More than one type may be selected."
@@ -127,7 +132,7 @@ en:
127
132
  language: "The language of the file content."
128
133
  publisher: "The person or group making the file available. Generally this is the institution."
129
134
  rights: "Licensing and distribution information governing access to the file. Select from the provided drop-down list. <em>This is a required field</em>."
130
- aria_label:
135
+ aria_label:
131
136
  default: "Usage information for %{title}"
132
137
  based_near: "Usage information for location"
133
138
  description: "Usage information for abstract or summary"
@@ -20,12 +20,17 @@ Sufia::Engine.routes.draw do
20
20
  resources :generic_files, path: :files, except: :index do
21
21
  member do
22
22
  resource :featured_work, only: [:create, :destroy]
23
+ resources :transfers, as: :generic_file_transfers, only: [:new, :create]
23
24
  get 'citation'
24
25
  get 'stats'
25
26
  post 'audit'
26
27
  end
27
28
  end
28
29
 
30
+ # Depositors routes for proxy deposit
31
+ post 'users/:user_id/depositors' => 'depositors#create', as: 'user_depositors'
32
+ delete 'users/:user_id/depositors/:id' => 'depositors#destroy', as: 'user_depositor'
33
+
29
34
  resources :featured_work_lists, path: 'featured_works', only: :create
30
35
 
31
36
  # Downloads controller route
@@ -51,6 +56,12 @@ Sufia::Engine.routes.draw do
51
56
  resources :dashboard, only: :index do
52
57
  collection do
53
58
  get 'activity', action: :activity, as: :dashboard_activity
59
+ resources :transfers, only: [:index, :destroy] do
60
+ member do
61
+ put 'accept'
62
+ put 'reject'
63
+ end
64
+ end
54
65
  end
55
66
  end
56
67
 
@@ -61,15 +72,15 @@ Sufia::Engine.routes.draw do
61
72
  get '/files', controller: 'my/files', action: :index, as: 'dashboard_files'
62
73
  get '/files/page/:page', controller: 'my/files', action: :index
63
74
  get '/files/facet/:id', controller: 'my/files', action: :facet, as: 'dashboard_files_facet'
64
-
75
+
65
76
  get '/collections', controller: 'my/collections', action: :index, as: 'dashboard_collections'
66
77
  get '/collections/page/:page', controller: 'my/collections', action: :index
67
78
  get '/collections/facet/:id', controller: 'my/collections', action: :facet, as: 'dashboard_collections_facet'
68
-
79
+
69
80
  get '/highlights', controller: 'my/highlights', action: :index, as: 'dashboard_highlights'
70
81
  get '/highlights/page/:page', controller: 'my/highlights', action: :index
71
82
  get '/highlights/facet/:id', controller: 'my/highlights', action: :facet, as: 'dashboard_highlights_facet'
72
-
83
+
73
84
  get '/shares', controller: 'my/shares', action: :index, as: 'dashboard_shares'
74
85
  get '/shares/page/:page', controller: 'my/shares', action: :index
75
86
  get '/shares/facet/:id', controller: 'my/shares', action: :facet, as: 'dashboard_shares_facet'
@@ -1,11 +1,12 @@
1
- require "sufia/version"
2
- require 'blacklight'
3
- require 'blacklight_advanced_search'
4
- require 'blacklight/gallery'
5
1
  require 'hydra/head'
6
- require 'hydra-batch-edit'
7
2
  require 'hydra-editor'
3
+ require 'blacklight/gallery'
4
+ require 'select2-rails'
5
+ require 'hydra-batch-edit'
8
6
  require 'browse-everything'
7
+ require "sufia/version"
8
+ require 'blacklight'
9
+ require 'blacklight_advanced_search'
9
10
  require 'sufia/models'
10
11
 
11
12
  require 'rails_autolink'
@@ -18,6 +19,7 @@ module Sufia
18
19
 
19
20
  class Engine < ::Rails::Engine
20
21
  engine_name 'sufia'
22
+
21
23
  # Breadcrumbs on rails must be required outside of an initializer or it doesn't get loaded.
22
24
  require 'breadcrumbs_on_rails'
23
25
 
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "4.0.1"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe AuthoritiesController do
3
+ describe AuthoritiesController, :type => :controller do
4
4
  describe "#query" do
5
5
  it "should return an array of hashes" do
6
6
  mock_hits = [{label: "English", uri: "http://example.org/eng"},
@@ -9,12 +9,12 @@ describe AuthoritiesController do
9
9
  {label: "Edgar", uri: "http://example.org/edga"},
10
10
  {label: "Eddie", uri: "http://example.org/edd"},
11
11
  {label: "Economics", uri: "http://example.org/eco"}]
12
- LocalAuthority.should_receive(:entries_by_term).and_return(mock_hits)
12
+ expect(LocalAuthority).to receive(:entries_by_term).and_return(mock_hits)
13
13
  xhr :get, :query, model: "generic_files", term: "subject", q: "E"
14
- response.should be_success
15
- JSON.parse(response.body).count.should == 6
16
- JSON.parse(response.body)[0]["label"].should == "English"
17
- JSON.parse(response.body)[0]["uri"].should == "http://example.org/eng"
14
+ expect(response).to be_success
15
+ expect(JSON.parse(response.body).count).to eq(6)
16
+ expect(JSON.parse(response.body)[0]["label"]).to eq("English")
17
+ expect(JSON.parse(response.body)[0]["uri"]).to eq("http://example.org/eng")
18
18
  end
19
19
  end
20
20
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BatchController do
3
+ describe BatchController, :type => :controller do
4
4
  before do
5
- controller.stub(:has_access?).and_return(true)
5
+ allow(controller).to receive(:has_access?).and_return(true)
6
6
  @user = FactoryGirl.find_or_create(:jill)
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
  after do
12
12
  @user.delete
@@ -35,82 +35,82 @@ describe BatchController do
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'}
37
37
  s1 = double('one')
38
- BatchUpdateJob.should_receive(:new).with(@user.user_key, params).and_return(s1)
39
- Sufia.queue.should_receive(:push).with(s1).once
38
+ expect(BatchUpdateJob).to receive(:new).with(@user.user_key, params).and_return(s1)
39
+ expect(Sufia.queue).to receive(:push).with(s1).once
40
40
  post :update, id: @batch.pid, "generic_file" => {"read_groups_string" => "", "read_users_string" => "archivist1, archivist2", "tag" => [""]}
41
41
  end
42
42
  it "should show flash messages" do
43
43
  post :update, id: @batch.pid, "generic_file" => {"read_groups_string" => "","read_users_string" => "archivist1, archivist2", "tag" => [""]}
44
- response.should redirect_to @routes.url_helpers.dashboard_files_path
45
- flash[:notice].should_not be_nil
46
- flash[:notice].should_not be_empty
47
- flash[:notice].should include("Your files are being processed")
44
+ expect(response).to redirect_to @routes.url_helpers.dashboard_files_path
45
+ expect(flash[:notice]).not_to be_nil
46
+ expect(flash[:notice]).not_to be_empty
47
+ expect(flash[:notice]).to include("Your files are being processed")
48
48
  end
49
49
 
50
50
  describe "when user has edit permissions on a file" do
51
51
  it "should set the groups" do
52
52
  post :update, id: @batch.pid, "generic_file"=>{"permissions"=>{"group"=>{"public"=>"1", "registered"=>"2"}}}
53
- @file.reload.read_groups.should == []
54
- @file.reload.edit_groups.should == []
55
- response.should redirect_to @routes.url_helpers.dashboard_files_path
53
+ expect(@file.reload.read_groups).to eq([])
54
+ expect(@file.reload.edit_groups).to eq([])
55
+ expect(response).to redirect_to @routes.url_helpers.dashboard_files_path
56
56
  end
57
57
 
58
58
  it "should set the users with read access" do
59
59
  post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
60
60
  file = GenericFile.find(@file.pid)
61
- file.read_users.should == ['archivist1', 'archivist2']
61
+ expect(file.read_users).to eq(['archivist1', 'archivist2'])
62
62
 
63
- response.should redirect_to @routes.url_helpers.dashboard_files_path
63
+ expect(response).to redirect_to @routes.url_helpers.dashboard_files_path
64
64
  end
65
65
  it "should set the groups with read access" do
66
66
  post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
67
67
  file = GenericFile.find(@file.pid)
68
- file.read_groups.should == ['group1', 'group2']
68
+ expect(file.read_groups).to eq(['group1', 'group2'])
69
69
  end
70
70
  it "should set public read access" do
71
71
  post :update, id: @batch.pid, "visibility"=>"open", "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"", "tag"=>[""]}
72
72
  file = GenericFile.find(@file.pid)
73
- file.read_groups.should == ['public']
73
+ expect(file.read_groups).to eq(['public'])
74
74
  end
75
75
  it "should set public read access and groups at the same time" do
76
76
  post :update, id: @batch.pid, "visibility"=>"open", "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
77
77
  file = GenericFile.find(@file.pid)
78
- file.read_groups.should == ['group1', 'group2', 'public']
78
+ expect(file.read_groups).to eq(['group1', 'group2', 'public'])
79
79
  end
80
80
  it "should set public discover access and groups at the same time" do
81
81
  post :update, id: @batch.pid, "permission"=>{"group"=>{"public"=>"none"}}, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
82
82
  file = GenericFile.find(@file.pid)
83
- file.read_groups.should == ['group1', 'group2']
84
- file.discover_groups.should == []
83
+ expect(file.read_groups).to eq(['group1', 'group2'])
84
+ expect(file.discover_groups).to eq([])
85
85
  end
86
86
  it "should set metadata like title" do
87
87
  post :update, id: @batch.pid, "generic_file"=>{"tag"=>["footag", "bartag"]}, "title"=>{@file.pid=>["New Title"]}
88
88
  file = GenericFile.find(@file.pid)
89
- file.title.should == ["New Title"]
90
- file.tag.should == ["footag", "bartag"]
89
+ expect(file.title).to eq(["New Title"])
90
+ expect(file.tag).to eq(["footag", "bartag"])
91
91
  end
92
92
  it "should not set any tags" do
93
93
  post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1", "tag"=>[""]}
94
94
  file = GenericFile.find(@file.pid)
95
- file.tag.should be_empty
95
+ expect(file.tag).to be_empty
96
96
  end
97
97
  end
98
98
  describe "when user does not have edit permissions on a file" do
99
99
  it "should not modify the object" do
100
100
  file = GenericFile.find(@file2.pid)
101
101
  file.title = ["Original Title"]
102
- file.read_groups.should == []
102
+ expect(file.read_groups).to eq([])
103
103
  file.save
104
104
  post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}, "title"=>{@file2.pid=>["Title Wont Change"]}
105
105
  file = GenericFile.find(@file2.pid)
106
- file.title.should == ["Original Title"]
107
- file.read_groups.should == []
106
+ expect(file.title).to eq(["Original Title"])
107
+ expect(file.read_groups).to eq([])
108
108
  end
109
109
  end
110
110
  end
111
111
  describe "#edit" do
112
112
  before do
113
- User.any_instance.stub(:display_name).and_return("Jill Z. User")
113
+ allow_any_instance_of(User).to receive(:display_name).and_return("Jill Z. User")
114
114
  @b1 = Batch.new
115
115
  @b1.save
116
116
  @file = GenericFile.new(batch: @b1, label: 'f1')
@@ -127,8 +127,8 @@ describe BatchController do
127
127
  end
128
128
  it "should default creator" do
129
129
  get :edit, id: @b1.id
130
- assigns[:generic_file].creator[0].should == @user.display_name
131
- assigns[:generic_file].title[0].should == 'f1'
130
+ expect(assigns[:generic_file].creator[0]).to eq(@user.display_name)
131
+ expect(assigns[:generic_file].title[0]).to eq('f1')
132
132
  end
133
133
  end
134
134
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BatchEditsController do
3
+ describe BatchEditsController, :type => :controller do
4
4
  before do
5
- controller.stub(:has_access?).and_return(true)
5
+ allow(controller).to receive(:has_access?).and_return(true)
6
6
  @user = FactoryGirl.find_or_create(:jill)
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
  request.env["HTTP_REFERER"] = 'test.host/original_page'
11
11
  end
12
12
 
@@ -26,9 +26,9 @@ describe BatchEditsController do
26
26
  end
27
27
  it "should be successful" do
28
28
  get :edit
29
- response.should be_successful
30
- assigns[:terms].should == [:creator, :contributor, :description, :tag, :rights, :publisher,
31
- :date_created, :subject, :language, :identifier, :based_near, :related_url]
29
+ expect(response).to be_successful
30
+ expect(assigns[:terms]).to eq([:creator, :contributor, :description, :tag, :rights, :publisher,
31
+ :date_created, :subject, :language, :identifier, :based_near, :related_url])
32
32
  expect(assigns[:show_file].creator).to eq ["Fred", "Wilma"]
33
33
  expect(assigns[:show_file].publisher).to eq ["Rand McNally"]
34
34
  expect(assigns[:show_file].language).to eq ["en"]
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe CatalogController do
3
+ describe CatalogController, :type => :controller do
4
4
  routes { Rails.application.class.routes }
5
5
 
6
6
  let(:user) { @user }
@@ -38,8 +38,8 @@ describe CatalogController do
38
38
  get :index, q: 'full_textfull_text'
39
39
  expect(response).to be_success
40
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]
41
+ expect(assigns(:document_list).count).to eql(1)
42
+ expect(assigns(:document_list).map(&:id)).to eq([@gf2.id])
43
43
  end
44
44
  end
45
45
 
@@ -47,10 +47,10 @@ describe CatalogController do
47
47
  it "should find records" do
48
48
  get :index, q: "pdf", owner: 'all'
49
49
  expect(response).to be_success
50
- response.should render_template('catalog/index')
51
- assigns(:document_list).map(&:id).should == [@gf1.id]
52
- assigns(:document_list).count.should eql(1)
53
- assigns(:document_list).first['desc_metadata__title_tesim'].should == ['Test Document PDF']
50
+ expect(response).to render_template('catalog/index')
51
+ expect(assigns(:document_list).map(&:id)).to eq([@gf1.id])
52
+ expect(assigns(:document_list).count).to eql(1)
53
+ expect(assigns(:document_list).first['desc_metadata__title_tesim']).to eq(['Test Document PDF'])
54
54
  end
55
55
  end
56
56
 
@@ -61,8 +61,8 @@ describe CatalogController do
61
61
  end
62
62
  it "should find facet files" do
63
63
  expect(response).to be_success
64
- response.should render_template('catalog/index')
65
- assigns(:document_list).count.should eql(1)
64
+ expect(response).to render_template('catalog/index')
65
+ expect(assigns(:document_list).count).to eql(1)
66
66
  end
67
67
  end
68
68
 
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe CollectionsController do
3
+ describe CollectionsController, :type => :controller do
4
4
  before(:each) { @routes = Hydra::Collections::Engine.routes }
5
5
  before do
6
- controller.stub(:has_access?).and_return(true)
7
- User.any_instance.stub(:groups).and_return([])
6
+ allow(controller).to receive(:has_access?).and_return(true)
7
+ allow_any_instance_of(User).to receive(:groups).and_return([])
8
8
  end
9
9
 
10
10
  let(:user) { FactoryGirl.create(:user) }
@@ -22,7 +22,7 @@ describe CollectionsController do
22
22
 
23
23
  it 'should assign @collection' do
24
24
  get :new
25
- assigns(:collection).should be_kind_of(Collection)
25
+ expect(assigns(:collection)).to be_kind_of(Collection)
26
26
  end
27
27
  end
28
28
 
@@ -32,10 +32,10 @@ describe CollectionsController do
32
32
  end
33
33
 
34
34
  it "should create a Collection" do
35
- controller.should_receive(:has_access?).and_return(true)
35
+ expect(controller).to receive(:has_access?).and_return(true)
36
36
  old_count = Collection.count
37
37
  post :create, collection: {title: "My First Collection ", description: "The Description\r\n\r\nand more"}
38
- Collection.count.should == old_count+1
38
+ expect(Collection.count).to eq(old_count+1)
39
39
  end
40
40
  it "should create a Collection with files I can access" do
41
41
  @asset1 = GenericFile.new(title: ["First of the Assets"])
@@ -47,15 +47,15 @@ describe CollectionsController do
47
47
  @asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:'abc')
48
48
  @asset3.apply_depositor_metadata('abc')
49
49
  @asset3.save
50
- controller.should_receive(:has_access?).and_return(true)
50
+ expect(controller).to receive(:has_access?).and_return(true)
51
51
  old_count = Collection.count
52
52
  post :create, collection: { title: "My own Collection", description: "The Description\r\n\r\nand more" },
53
53
  batch_document_ids: [@asset1.id, @asset2.id, @asset3.id]
54
- Collection.count.should == old_count+1
54
+ expect(Collection.count).to eq(old_count+1)
55
55
  collection = assigns(:collection)
56
- collection.members.should include (@asset1)
57
- collection.members.should include (@asset2)
58
- collection.members.to_a.should_not include (@asset3) # .to_a to avoid a call to any? which doesn't exist in AF::HABTM
56
+ expect(collection.members).to include (@asset1)
57
+ expect(collection.members).to include (@asset2)
58
+ expect(collection.members.to_a).not_to include (@asset3) # .to_a to avoid a call to any? which doesn't exist in AF::HABTM
59
59
  @asset1.destroy
60
60
  @asset2.destroy
61
61
  @asset3.destroy
@@ -67,13 +67,13 @@ describe CollectionsController do
67
67
  @asset1.save
68
68
  post :create, batch_document_ids: [@asset1.id],
69
69
  collection: { title: "My Secong Collection ", description: "The Description\r\n\r\nand more" }
70
- assigns[:collection].members.should == [@asset1]
70
+ expect(assigns[:collection].members).to eq([@asset1])
71
71
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
72
- asset_results["response"]["numFound"].should == 1
72
+ expect(asset_results["response"]["numFound"]).to eq(1)
73
73
  doc = asset_results["response"]["docs"].first
74
- doc["id"].should == @asset1.id
74
+ expect(doc["id"]).to eq(@asset1.id)
75
75
  afterupdate = GenericFile.find(@asset1.pid)
76
- doc[Solrizer.solr_name(:collection)].should == afterupdate.to_solr[Solrizer.solr_name(:collection)]
76
+ expect(doc[Solrizer.solr_name(:collection)]).to eq(afterupdate.to_solr[Solrizer.solr_name(:collection)])
77
77
  end
78
78
 
79
79
  end
@@ -103,21 +103,21 @@ describe CollectionsController do
103
103
 
104
104
  it "should set collection on members" do
105
105
  put :update, id: @collection.id, collection: {members:"add"}, batch_document_ids: [@asset3.pid, @asset1.pid, @asset2.pid]
106
- response.should redirect_to Hydra::Collections::Engine.routes.url_helpers.collection_path(@collection.noid)
107
- assigns[:collection].members.map{|m| m.pid}.sort.should == [@asset2, @asset3, @asset1].map {|m| m.pid}.sort
106
+ expect(response).to redirect_to Hydra::Collections::Engine.routes.url_helpers.collection_path(@collection.noid)
107
+ expect(assigns[:collection].members.map{|m| m.pid}.sort).to eq([@asset2, @asset3, @asset1].map {|m| m.pid}.sort)
108
108
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.pid}\""],fl:['id',Solrizer.solr_name(:collection)]}
109
- asset_results["response"]["numFound"].should == 1
109
+ expect(asset_results["response"]["numFound"]).to eq(1)
110
110
  doc = asset_results["response"]["docs"].first
111
- doc["id"].should == @asset2.id
111
+ expect(doc["id"]).to eq(@asset2.id)
112
112
  afterupdate = GenericFile.find(@asset2.pid)
113
- doc[Solrizer.solr_name(:collection)].should == afterupdate.to_solr[Solrizer.solr_name(:collection)]
113
+ expect(doc[Solrizer.solr_name(:collection)]).to eq(afterupdate.to_solr[Solrizer.solr_name(:collection)])
114
114
  put :update, id: @collection.id, collection: {members:"remove"}, batch_document_ids: [@asset2]
115
115
  asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.pid}\""],fl:['id',Solrizer.solr_name(:collection)]}
116
- asset_results["response"]["numFound"].should == 1
116
+ expect(asset_results["response"]["numFound"]).to eq(1)
117
117
  doc = asset_results["response"]["docs"].first
118
- doc["id"].should == @asset2.pid
118
+ expect(doc["id"]).to eq(@asset2.pid)
119
119
  afterupdate = GenericFile.find(@asset2.pid)
120
- doc[Solrizer.solr_name(:collection)].should be_nil
120
+ expect(doc[Solrizer.solr_name(:collection)]).to be_nil
121
121
  end
122
122
  end
123
123
 
@@ -141,8 +141,8 @@ describe CollectionsController do
141
141
  @collection.apply_depositor_metadata(user.user_key)
142
142
  @collection.members = [@asset1,@asset2,@asset3]
143
143
  @collection.save!
144
- controller.stub(:authorize!).and_return(true)
145
- controller.stub(:apply_gated_search)
144
+ allow(controller).to receive(:authorize!).and_return(true)
145
+ allow(controller).to receive(:apply_gated_search)
146
146
  end
147
147
  context "when signed in" do
148
148
  before do
@@ -152,7 +152,7 @@ describe CollectionsController do
152
152
  it "should return the collection and its members" do
153
153
  get :show, id: @collection.id
154
154
  expect(response).to be_successful
155
- assigns[:collection].title.should == @collection.title
155
+ expect(assigns[:collection].title).to eq(@collection.title)
156
156
  ids = assigns[:member_docs].map(&:id)
157
157
  expect(ids).to include @asset1.pid, @asset2.pid, @asset3.pid
158
158
  expect(ids).to_not include @asset4.pid
@@ -165,7 +165,7 @@ describe CollectionsController do
165
165
  context "not signed in" do
166
166
  it "should not show me files in the collection" do
167
167
  get :show, id: @collection.id
168
- assigns[:member_docs].count.should == 0
168
+ expect(assigns[:member_docs].count).to eq(0)
169
169
  end
170
170
  end
171
171
  end
@@ -179,7 +179,7 @@ describe CollectionsController do
179
179
  end
180
180
  it "should not show flash" do
181
181
  get :edit, id: @collection.id
182
- flash[:notice].should be_nil
182
+ expect(flash[:notice]).to be_nil
183
183
  end
184
184
  end
185
185
  end