sufia 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +111 -0
  3. data/Gemfile +4 -4
  4. data/History.md +126 -0
  5. data/README.md +23 -5
  6. data/SUFIA_VERSION +1 -1
  7. data/app/assets/javascripts/sufia/multiForm.js +10 -2
  8. data/app/assets/stylesheets/{application-bootstrap.css → application-bootstrap.css.erb} +7 -7
  9. data/app/assets/stylesheets/{bootstrap.min.css → bootstrap.min.css.erb} +1 -1
  10. data/app/controllers/concerns/sufia/users_controller_behavior.rb +9 -3
  11. data/app/controllers/single_use_link_controller.rb +1 -1
  12. data/app/helpers/sufia_helper.rb +7 -1
  13. data/app/models/contact_form.rb +0 -14
  14. data/app/views/_user_util_links.html.erb +0 -15
  15. data/app/views/batch_edits/_check_all.html.erb +2 -2
  16. data/app/views/batch_edits/_delete_selected.html.erb +1 -1
  17. data/app/views/layouts/{_head-tag-content.html.erb → _head_tag_content.html.erb} +0 -0
  18. data/app/views/layouts/homepage.html.erb +2 -2
  19. data/app/views/layouts/sufia-one-column.html.erb +1 -1
  20. data/app/views/layouts/sufia-two-column.html.erb +1 -1
  21. data/app/views/users/edit.html.erb +1 -1
  22. data/app/views/users/show.html.erb +1 -17
  23. data/config/routes.rb +31 -33
  24. data/lib/generators/sufia/sufia_generator.rb +5 -3
  25. data/lib/generators/sufia/templates/catalog_controller.rb +5 -1
  26. data/lib/generators/sufia/templates/config/redis_config.rb +1 -14
  27. data/lib/sufia/batch_edits_controller_behavior.rb +1 -1
  28. data/lib/sufia/controller.rb +1 -1
  29. data/lib/sufia/dashboard_controller_behavior.rb +8 -2
  30. data/lib/sufia/files_controller_behavior.rb +1 -2
  31. data/lib/sufia/version.rb +1 -1
  32. data/spec/active_fedora/unsaved_digital_object_spec.rb +1 -15
  33. data/spec/controllers/authorities_controller_spec.rb +1 -15
  34. data/spec/controllers/batch_controller_spec.rb +10 -16
  35. data/spec/controllers/batch_edits_controller_spec.rb +1 -1
  36. data/spec/controllers/catalog_controller_spec.rb +1 -15
  37. data/spec/controllers/dashboard_controller_spec.rb +23 -17
  38. data/spec/controllers/downloads_controller_spec.rb +1 -15
  39. data/spec/controllers/generic_files_controller_spec.rb +18 -32
  40. data/spec/controllers/mailbox_controller_spec.rb +1 -15
  41. data/spec/controllers/single_use_link_controller_spec.rb +6 -13
  42. data/spec/controllers/users_controller_spec.rb +27 -41
  43. data/spec/factories/users.rb +5 -14
  44. data/spec/features/browse_dashboard_files.rb +21 -0
  45. data/spec/features/browse_files.rb +31 -0
  46. data/spec/features/contact_form.rb +99 -0
  47. data/spec/features/display_dashboard.rb +46 -0
  48. data/spec/features/ingest_upload_files.rb +24 -0
  49. data/spec/features/users_spec.rb +25 -0
  50. data/spec/helpers/generic_file_helper_spec.rb +10 -3
  51. data/spec/helpers/sufia_helper_spec.rb +1 -1
  52. data/spec/lib/sufia/id_service_spec.rb +1 -15
  53. data/spec/models/audit_job_spec.rb +1 -15
  54. data/spec/models/batch_spec.rb +1 -15
  55. data/spec/models/batch_update_job_spec.rb +3 -16
  56. data/spec/models/characterize_job_spec.rb +4 -4
  57. data/spec/models/checksum_audit_log_spec.rb +1 -15
  58. data/spec/models/event_jobs_spec.rb +1 -15
  59. data/spec/models/file_content_datastream_spec.rb +5 -19
  60. data/spec/models/fits_datastream_spec.rb +1 -15
  61. data/spec/models/generic_file/web_form_spec.rb +34 -0
  62. data/spec/models/generic_file_spec.rb +11 -39
  63. data/spec/models/local_authority_spec.rb +3 -15
  64. data/spec/models/properties_datastream_spec.rb +1 -1
  65. data/spec/models/single_use_link_spec.rb +1 -1
  66. data/spec/models/solr_document_spec.rb +1 -1
  67. data/spec/models/transcode_audio_job_spec.rb +1 -1
  68. data/spec/models/transcode_video_job_spec.rb +1 -1
  69. data/spec/models/trophy_spec.rb +1 -1
  70. data/spec/models/unzip_job_spec.rb +1 -15
  71. data/spec/models/user_spec.rb +1 -15
  72. data/spec/rake/sufia_fixtures_spec.rb +3 -17
  73. data/spec/routing/route_spec.rb +7 -21
  74. data/spec/spec_helper.rb +8 -20
  75. data/spec/support/features.rb +6 -0
  76. data/spec/support/features/session_helpers.rb +21 -0
  77. data/spec/support/lib/generators/test_app_generator.rb +4 -0
  78. data/spec/views/batch_edits/check_all_spec.rb +6 -4
  79. data/sufia-models/app/models/checksum_audit_log.rb +1 -15
  80. data/sufia-models/app/models/domain_term.rb +3 -15
  81. data/sufia-models/app/models/geo_names_resource.rb +1 -13
  82. data/sufia-models/app/models/local_authority.rb +12 -17
  83. data/sufia-models/app/models/local_authority_entry.rb +1 -15
  84. data/sufia-models/app/models/single_use_link.rb +2 -3
  85. data/sufia-models/app/models/trophy.rb +1 -1
  86. data/sufia-models/app/models/version_committer.rb +1 -15
  87. data/sufia-models/lib/sufia/models.rb +6 -2
  88. data/sufia-models/lib/sufia/models/engine.rb +1 -1
  89. data/sufia-models/lib/sufia/models/generic_file.rb +3 -0
  90. data/sufia-models/lib/sufia/models/generic_file/accessible_attributes.rb +87 -0
  91. data/sufia-models/lib/sufia/models/generic_file/permissions.rb +2 -1
  92. data/sufia-models/lib/sufia/models/generic_file/web_form.rb +4 -1
  93. data/sufia-models/lib/sufia/models/user.rb +9 -2
  94. data/sufia-models/lib/sufia/models/version.rb +1 -1
  95. data/{lib → sufia-models/lib}/tasks/resque.rake +0 -0
  96. data/sufia-models/sufia-models.gemspec +13 -11
  97. data/sufia.gemspec +1 -3
  98. data/tasks/sufia-dev.rake +21 -10
  99. metadata +30 -84
  100. data/config/cucumber.yml +0 -8
  101. data/features/browse_dashboard_files.feature +0 -16
  102. data/features/browse_files.feature +0 -16
  103. data/features/contact_form.feature +0 -86
  104. data/features/display_dashboard.feature +0 -42
  105. data/features/ingest_upload_files.feature +0 -21
  106. data/features/step_definitions/edit_metadata_steps.rb +0 -89
  107. data/features/step_definitions/fixture_steps.rb +0 -35
  108. data/features/step_definitions/show_document_steps.rb +0 -103
  109. data/features/step_definitions/sufia.rb +0 -69
  110. data/features/step_definitions/user_steps.rb +0 -58
  111. data/features/step_definitions/web_steps.rb +0 -235
  112. data/features/support/cleanup.rb +0 -19
  113. data/features/support/env.rb +0 -90
  114. data/features/support/headless.rb +0 -26
  115. data/features/support/paths.rb +0 -101
  116. data/features/users.feature +0 -18
  117. data/spec/lib/sufia/role_mapper_spec.rb +0 -28
  118. data/spec/support/Gemfile +0 -24
  119. data/spec/views/single_user_link/download.html.erb_spec.rb +0 -5
  120. data/spec/views/single_user_link/generate_download.html.erb_spec.rb +0 -5
  121. data/spec/views/single_user_link/generate_show.html.erb_spec.rb +0 -5
  122. data/spec/views/single_user_link/show.html.erb_spec.rb +0 -5
  123. data/tasks/cucumber.rake +0 -72
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe BatchEditsController do
4
4
  before do
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe CatalogController do
18
4
  before do
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe DashboardController do
18
4
  before do
@@ -63,14 +49,34 @@ describe DashboardController do
63
49
  describe "#index" do
64
50
  before (:each) do
65
51
  xhr :get, :index
52
+ # Make sure there are at least 3 files owned by @user. Otherwise, the tests aren't meaningful.
53
+ if assigns(:document_list).count < 3
54
+ files_count = assigns(:document_list).count
55
+ until files_count == 3
56
+ gf = GenericFile.new()
57
+ gf.apply_depositor_metadata(@user.user_key)
58
+ gf.save
59
+ files_count += 1
60
+ end
61
+ xhr :get, :index
62
+ end
66
63
  end
67
64
  it "should be a success" do
68
65
  response.should be_success
69
66
  response.should render_template('dashboard/index')
70
67
  end
71
68
  it "should return an array of documents I can edit" do
72
- user_results = Blacklight.solr.get "select", :params=>{:fq=>["edit_access_group_ssim:public OR edit_access_person_ssim:#{@user.user_key}"]}
73
- assigns(:document_list).count.should eql(user_results["response"]["numFound"])
69
+ editable_docs_response = Blacklight.solr.get "select", :params=>{:fq=>["edit_access_group_ssim:public OR edit_access_person_ssim:#{@user.user_key}"]}
70
+ assigns(:result_set_size).should eql(editable_docs_response["response"]["numFound"])
71
+ assigns(:document_list).each {|doc| doc.should be_kind_of SolrDocument}
72
+ end
73
+ context "with render views" do
74
+ render_views
75
+ it "should paginate" do
76
+ xhr :get, :index, per_page: 2
77
+ response.should be_success
78
+ response.should render_template('dashboard/index')
79
+ end
74
80
  end
75
81
  end
76
82
  end
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe DownloadsController do
18
4
 
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe GenericFilesController do
18
4
  before do
@@ -46,11 +32,11 @@ describe GenericFilesController do
46
32
 
47
33
  it "should spawn a content deposit event job" do
48
34
  file = fixture_file_upload('/world.png','image/png')
49
- s1 = stub('one')
35
+ s1 = double('one')
50
36
  ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
51
37
  Sufia.queue.should_receive(:push).with(s1).once
52
38
 
53
- s2 = stub('one')
39
+ s2 = double('one')
54
40
  CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
55
41
  Sufia.queue.should_receive(:push).with(s2).once
56
42
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
@@ -58,15 +44,15 @@ describe GenericFilesController do
58
44
 
59
45
  it "should expand zip files" do
60
46
  file = fixture_file_upload('/icons.zip','application/zip')
61
- s1 = stub('one')
47
+ s1 = double('one')
62
48
  ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
63
49
  Sufia.queue.should_receive(:push).with(s1).once
64
50
 
65
- s2 = stub('one')
51
+ s2 = double('one')
66
52
  CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
67
53
  Sufia.queue.should_receive(:push).with(s2).once
68
54
 
69
- s3 = stub('one')
55
+ s3 = double('one')
70
56
  UnzipJob.should_receive(:new).with('test:123').and_return(s3)
71
57
  Sufia.queue.should_receive(:push).with(s3).once
72
58
 
@@ -173,11 +159,11 @@ describe GenericFilesController do
173
159
  controller.should_receive(:virus_check).and_return(0)
174
160
  file = fixture_file_upload('/world.png','image/png')
175
161
 
176
- s1 = stub('one')
162
+ s1 = double('one')
177
163
  ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
178
164
  Sufia.queue.should_receive(:push).with(s1).once
179
165
 
180
- s2 = stub('one')
166
+ s2 = double('one')
181
167
  CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
182
168
  Sufia.queue.should_receive(:push).with(s2).once
183
169
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
@@ -253,7 +239,7 @@ describe GenericFilesController do
253
239
  lambda { GenericFile.find(@generic_file.pid) }.should raise_error(ActiveFedora::ObjectNotFoundError)
254
240
  end
255
241
  it "should spawn a content delete event job" do
256
- s1 = stub('one')
242
+ s1 = double('one')
257
243
  ContentDeleteEventJob.should_receive(:new).with(@generic_file.noid, @user.user_key).and_return(s1)
258
244
  Sufia.queue.should_receive(:push).with(s1).once
259
245
  delete :destroy, :id=>@generic_file.pid
@@ -272,7 +258,7 @@ describe GenericFilesController do
272
258
  end
273
259
 
274
260
  it "should spawn a content update event job" do
275
- s1 = stub('one')
261
+ s1 = double('one')
276
262
  ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
277
263
  Sufia.queue.should_receive(:push).with(s1).once
278
264
  @user = FactoryGirl.find_or_create(:user)
@@ -282,10 +268,10 @@ describe GenericFilesController do
282
268
  end
283
269
 
284
270
  it "should spawn a content new version event job" do
285
- s1 = stub('one')
271
+ s1 = double('one')
286
272
  ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
287
273
  Sufia.queue.should_receive(:push).with(s1).once
288
- s2 = stub('one')
274
+ s2 = double('one')
289
275
  CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
290
276
  Sufia.queue.should_receive(:push).with(s2).once
291
277
  @user = FactoryGirl.find_or_create(:user)
@@ -346,11 +332,11 @@ describe GenericFilesController do
346
332
 
347
333
  ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').never
348
334
 
349
- s1 = stub('one')
335
+ s1 = double('one')
350
336
  ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, archivist.user_key).and_return(s1)
351
337
  Sufia.queue.should_receive(:push).with(s1).once
352
338
 
353
- s2 = stub('one')
339
+ s2 = double('one')
354
340
  CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
355
341
  Sufia.queue.should_receive(:push).with(s2).once
356
342
  file = fixture_file_upload('/image.jp2','image/jp2')
@@ -365,11 +351,11 @@ describe GenericFilesController do
365
351
  controller.stub(:current_user).and_return(@user)
366
352
  sign_in @user
367
353
  ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').never
368
- s1 = stub('one')
354
+ s1 = double('one')
369
355
  ContentRestoredVersionEventJob.should_receive(:new).with(@generic_file.pid, @user.user_key, 'content.0').and_return(s1)
370
356
  Sufia.queue.should_receive(:push).with(s1).once
371
357
 
372
- s2 = stub('one')
358
+ s2 = double('one')
373
359
  CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
374
360
  Sufia.queue.should_receive(:push).with(s2).once
375
361
  post :update, :id=>@generic_file.pid, :revision=>'content.0'
@@ -398,11 +384,11 @@ describe GenericFilesController do
398
384
  it "should spawn a virus check" do
399
385
  # The expectation is in the begin block
400
386
  controller.should_receive(:virus_check).and_return(0)
401
- s1 = stub('one')
387
+ s1 = double('one')
402
388
  ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
403
389
  Sufia.queue.should_receive(:push).with(s1).once
404
390
 
405
- s2 = stub('one')
391
+ s2 = double('one')
406
392
  CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
407
393
  Sufia.queue.should_receive(:push).with(s2).once
408
394
  GenericFile.stub(:save).and_return({})
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe MailboxController do
18
4
  before(:each) do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe SingleUseLinkController do
4
4
  before(:all) do
@@ -14,7 +14,7 @@ describe SingleUseLinkController do
14
14
  @file2.save
15
15
  end
16
16
  after(:all) do
17
- SingleUseLink.find(:all).each{ |l| l.delete}
17
+ SingleUseLink.delete_all
18
18
  @user.delete
19
19
  @file.delete
20
20
  @file2.delete
@@ -70,13 +70,8 @@ describe SingleUseLinkController do
70
70
  end
71
71
  describe "retrieval links" do
72
72
  before (:each) do
73
- @user = FactoryGirl.find_or_create(:user)
74
- sign_in @user
75
- get 'generate_download', id:@file.pid
76
- @dhash = assigns[:su].downloadKey
77
- get 'generate_show', id:@file.pid
78
- @shash= assigns[:su].downloadKey
79
- sign_out @user
73
+ @dhash = SingleUseLink.create_download(@file.pid).downloadKey
74
+ @shash = SingleUseLink.create_show(@file.pid).downloadKey
80
75
  end
81
76
  before (:each) do
82
77
  @user.delete
@@ -116,10 +111,8 @@ describe SingleUseLinkController do
116
111
  get :show, id:@shash
117
112
  response.should render_template('error/single_use_error')
118
113
  end
119
- it "and_return 404 on attempt to get show with download" do
120
- get :show, id:@shash
121
- response.should be_success
122
- get :show, id:@shash
114
+ it "and_return 404 on attempt to get show path with download hash" do
115
+ get :show, id:@dhash
123
116
  response.should render_template('error/single_use_error')
124
117
  end
125
118
  end
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe UsersController do
18
4
  before(:each) do
@@ -30,13 +16,13 @@ describe UsersController do
30
16
  end
31
17
  describe "#show" do
32
18
  it "show the user profile if user exists" do
33
- get :show, uid: @user.user_key
19
+ get :show, id: @user.user_key
34
20
  response.should be_success
35
21
  response.should_not redirect_to(root_path)
36
22
  flash[:alert].should be_nil
37
23
  end
38
24
  it "redirects to root if user does not exist" do
39
- get :show, uid: 'johndoe666'
25
+ get :show, id: 'johndoe666'
40
26
  response.should redirect_to(root_path)
41
27
  flash[:alert].should include ("User 'johndoe666' does not exist")
42
28
  end
@@ -65,30 +51,30 @@ describe UsersController do
65
51
  end
66
52
  describe "#edit" do
67
53
  it "show edit form when user edits own profile" do
68
- get :edit, uid: @user.user_key
54
+ get :edit, id: @user.user_key
69
55
  response.should be_success
70
56
  response.should render_template('users/edit')
71
57
  flash[:alert].should be_nil
72
58
  end
73
59
  it "redirects to show profile when user attempts to edit another profile" do
74
- get :edit, uid: @another_user.user_key
60
+ get :edit, id: @another_user.user_key
75
61
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
76
62
  flash[:alert].should include("Permission denied: cannot access this page.")
77
63
  end
78
64
  end
79
65
  describe "#update" do
80
66
  it "should not allow other users to update" do
81
- post :update, uid: @another_user.user_key, user: { avatar: nil }
67
+ post :update, id: @another_user.user_key, user: { avatar: nil }
82
68
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
83
69
  flash[:alert].should include("Permission denied: cannot access this page.")
84
70
  end
85
71
  it "should set an avatar and redirect to profile" do
86
72
  @user.avatar.file?.should be_false
87
- s1 = stub('one')
73
+ s1 = double('one')
88
74
  UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
89
75
  Sufia.queue.should_receive(:push).with(s1).once
90
76
  f = fixture_file_upload('/world.png', 'image/png')
91
- post :update, uid: @user.user_key, user: { avatar: f }
77
+ post :update, id: @user.user_key, user: { avatar: f }
92
78
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
93
79
  flash[:notice].should include("Your profile has been updated")
94
80
  User.find_by_user_key(@user.user_key).avatar.file?.should be_true
@@ -97,7 +83,7 @@ describe UsersController do
97
83
  #Resque.should_receive(:enqueue).with(UserEditProfileEventJob, @user.user_key).never
98
84
  Sufia.queue.should_receive(:push).never
99
85
  f = fixture_file_upload('/image.jp2', 'image/jp2')
100
- post :update, uid: @user.user_key, user: { avatar: f }
86
+ post :update, id: @user.user_key, user: { avatar: f }
101
87
  response.should redirect_to(@routes.url_helpers.edit_profile_path(URI.escape(@user.user_key,'@.')))
102
88
  flash[:alert].should include("Avatar content type is invalid")
103
89
  end
@@ -105,25 +91,25 @@ describe UsersController do
105
91
  f = fixture_file_upload('/4-20.png', 'image/png')
106
92
  #Resque.should_receive(:enqueue).with(UserEditProfileEventJob, @user.user_key).never
107
93
  Sufia.queue.should_receive(:push).never
108
- post :update, uid: @user.user_key, user: { avatar: f }
94
+ post :update, id: @user.user_key, user: { avatar: f }
109
95
  response.should redirect_to(@routes.url_helpers.edit_profile_path(URI.escape(@user.user_key,'@.')))
110
96
  flash[:alert].should include("Avatar file size must be less than 2097152 Bytes")
111
97
  end
112
98
  it "should delete an avatar" do
113
- s1 = stub('one')
99
+ s1 = double('one')
114
100
  UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
115
101
  Sufia.queue.should_receive(:push).with(s1).once
116
- post :update, uid: @user.user_key, delete_avatar: true
102
+ post :update, id: @user.user_key, delete_avatar: true
117
103
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
118
104
  flash[:notice].should include("Your profile has been updated")
119
105
  @user.avatar.file?.should be_false
120
106
  end
121
107
  it "should refresh directory attributes" do
122
- s1 = stub('one')
108
+ s1 = double('one')
123
109
  UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
124
110
  Sufia.queue.should_receive(:push).with(s1).once
125
111
  User.any_instance.should_receive(:populate_attributes).once
126
- post :update, uid: @user.user_key, update_directory: true
112
+ post :update, id: @user.user_key, update_directory: true
127
113
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
128
114
  flash[:notice].should include("Your profile has been updated")
129
115
  end
@@ -131,7 +117,7 @@ describe UsersController do
131
117
  @user.twitter_handle.blank?.should be_true
132
118
  @user.facebook_handle.blank?.should be_true
133
119
  @user.googleplus_handle.blank?.should be_true
134
- post :update, uid: @user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo' }
120
+ post :update, id: @user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo' }
135
121
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
136
122
  flash[:notice].should include("Your profile has been updated")
137
123
  u = User.find_by_user_key(@user.user_key)
@@ -146,7 +132,7 @@ describe UsersController do
146
132
  file_id = f.pid.split(":").last
147
133
  Trophy.create(:generic_file_id => file_id, :user_id => @user.id)
148
134
  @user.trophy_ids.length.should == 1
149
- post :update, uid: @user.user_key, 'remove_trophy_'+file_id=> 'yes'
135
+ post :update, id: @user.user_key, 'remove_trophy_'+file_id=> 'yes'
150
136
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
151
137
  flash[:notice].should include("Your profile has been updated")
152
138
  @user.trophy_ids.length.should == 0
@@ -159,10 +145,10 @@ describe UsersController do
159
145
  end
160
146
  it "should follow another user if not already following, and log an event" do
161
147
  @user.following?(@another_user).should be_false
162
- s1 = stub('one')
148
+ s1 = double('one')
163
149
  UserFollowEventJob.should_receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
164
150
  Sufia.queue.should_receive(:push).with(s1).once
165
- post :follow, uid: @another_user.user_key
151
+ post :follow, id: @another_user.user_key
166
152
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
167
153
  flash[:notice].should include("You are following #{@another_user.user_key}")
168
154
  end
@@ -170,14 +156,14 @@ describe UsersController do
170
156
  User.any_instance.stub(:following?).with(@another_user).and_return(true)
171
157
  #Resque.should_receive(:enqueue).with(UserFollowEventJob, @user.user_key, @another_user.user_key).never
172
158
  Sufia.queue.should_receive(:push).never
173
- post :follow, uid: @another_user.user_key
159
+ post :follow, id: @another_user.user_key
174
160
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
175
161
  flash[:notice].should include("You are following #{@another_user.user_key}")
176
162
  end
177
163
  it "should redirect to profile if user attempts to self-follow and not log an event" do
178
164
  #Resque.should_receive(:enqueue).with(UserFollowEventJob, @user.user_key, @user.user_key).never
179
165
  Sufia.queue.should_receive(:push).never
180
- post :follow, uid: @user.user_key
166
+ post :follow, id: @user.user_key
181
167
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
182
168
  flash[:alert].should include("You cannot follow or unfollow yourself")
183
169
  end
@@ -185,10 +171,10 @@ describe UsersController do
185
171
  describe "#unfollow" do
186
172
  it "should unfollow another user if already following, and log an event" do
187
173
  User.any_instance.stub(:following?).with(@another_user).and_return(true)
188
- s1 = stub('one')
174
+ s1 = double('one')
189
175
  UserUnfollowEventJob.should_receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
190
176
  Sufia.queue.should_receive(:push).with(s1).once
191
- post :unfollow, uid: @another_user.user_key
177
+ post :unfollow, id: @another_user.user_key
192
178
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
193
179
  flash[:notice].should include("You are no longer following #{@another_user.user_key}")
194
180
  end
@@ -196,14 +182,14 @@ describe UsersController do
196
182
  @user.stub(:following?).with(@another_user).and_return(false)
197
183
  #Resque.should_receive(:enqueue).with(UserUnfollowEventJob, @user.user_key, @another_user.user_key).never
198
184
  Sufia.queue.should_receive(:push).never
199
- post :unfollow, uid: @another_user.user_key
185
+ post :unfollow, id: @another_user.user_key
200
186
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
201
187
  flash[:notice].should include("You are no longer following #{@another_user.user_key}")
202
188
  end
203
189
  it "should redirect to profile if user attempts to self-follow and not log an event" do
204
190
  #Resque.should_receive(:enqueue).with(UserUnfollowEventJob, @user.user_key, @user.user_key).never
205
191
  Sufia.queue.should_receive(:push).never
206
- post :unfollow, uid: @user.user_key
192
+ post :unfollow, id: @user.user_key
207
193
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
208
194
  flash[:alert].should include("You cannot follow or unfollow yourself")
209
195
  end
@@ -219,18 +205,18 @@ describe UsersController do
219
205
  @file.delete
220
206
  end
221
207
  it "should trophy a file" do
222
- post :toggle_trophy, {uid: @user.user_key, file_id: @file_id}
208
+ post :toggle_trophy, {id: @user.user_key, file_id: @file_id}
223
209
  JSON.parse(response.body)['user_id'].should == @user.id
224
210
  JSON.parse(response.body)['generic_file_id'].should == @file_id
225
211
  end
226
212
  it "should not trophy a file for a different user" do
227
- post :toggle_trophy, {uid: @another_user.user_key, file_id: @file_id}
213
+ post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
228
214
  response.should_not be_success
229
215
  end
230
216
  it "should not trophy a file with no edit privs" do
231
217
  sign_out @user
232
218
  sign_in @another_user
233
- post :toggle_trophy, {uid: @another_user.user_key, file_id: @file_id}
219
+ post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
234
220
  response.should_not be_success
235
221
  end
236
222
  end