user_impersonate2 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,5 +15,51 @@ class UserImpersonate::ImpersonateControllerTest < ActionController::TestCase
15
15
  delete :destroy, :use_route => 'user_impersonate'
16
16
  assert_redirected_to 'http://test.host/'
17
17
  end
18
+
19
+ test 'configuration uses default model User' do
20
+ user = mock('User')
21
+
22
+ @controller.expects(:config_or_default).
23
+ with(:authenticate_user_method, 'authenticate_user!').
24
+ returns('authenticate_user!')
25
+ @controller.expects(:config_or_default).
26
+ with(:current_staff, 'current_user').
27
+ returns('current_user')
28
+ @controller.expects(:config_or_default).
29
+ with(:user_is_staff_method, 'staff?').
30
+ returns('staff?')
31
+
32
+ @controller.expects(:authenticate_user!).once.returns(true)
33
+ @controller.expects(:current_user).once.returns(user)
34
+ @controller.expects(:authenticate_admin_user!).never
35
+ @controller.expects(:current_admin_user).never
36
+
37
+ get :index, :use_route => 'user_impersonate'
38
+ assert_redirected_to 'http://test.host/'
39
+ assert_equal user, assigns(:current_staff)
40
+ end
41
+
42
+ test 'configuration to use a different model than User' do
43
+ admin_user = mock('AdminUser')
44
+
45
+ @controller.expects(:config_or_default).
46
+ with(:authenticate_user_method, 'authenticate_user!').
47
+ returns('authenticate_admin_user!')
48
+ @controller.expects(:config_or_default).
49
+ with(:current_staff, 'current_user').
50
+ returns('current_admin_user')
51
+ @controller.expects(:config_or_default).
52
+ with(:user_is_staff_method, 'staff?').
53
+ returns('staff?')
54
+
55
+ @controller.expects(:authenticate_user!).never
56
+ @controller.expects(:current_user).never
57
+ @controller.expects(:authenticate_admin_user!).once.returns(true)
58
+ @controller.expects(:current_admin_user).once.returns(admin_user)
59
+
60
+ get :index, :use_route => 'user_impersonate'
61
+ assert_redirected_to 'http://test.host/'
62
+ assert_equal admin_user, assigns(:current_staff)
63
+ end
18
64
  end
19
65
 
data/test/test_helper.rb CHANGED
@@ -8,6 +8,7 @@ ENV['RAILS_ENV'] = 'test'
8
8
 
9
9
  require File.expand_path("../#{TestUtils.dummy_app_dir}/config/environment.rb", __FILE__)
10
10
  require 'rails/test_help'
11
+ require 'mocha/setup'
11
12
 
12
13
  puts "Rails #{Rails.version} is loaded"
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_impersonate2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Cook
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-18 00:00:00.000000000 Z
13
+ date: 2014-04-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -155,7 +155,6 @@ files:
155
155
  - test/dummy-rails3/config/initializers/secret_token.rb
156
156
  - test/dummy-rails3/config/initializers/backtrace_silencers.rb
157
157
  - test/dummy-rails3/config/initializers/devise.rb
158
- - test/dummy-rails3/config/initializers/inflections.rb
159
158
  - test/dummy-rails3/config/application.rb
160
159
  - test/dummy-rails3/config/environment.rb
161
160
  - test/dummy-rails3/config/environments/production.rb
@@ -207,7 +206,6 @@ files:
207
206
  - test/dummy-rails4/config/initializers/secret_token.rb
208
207
  - test/dummy-rails4/config/initializers/backtrace_silencers.rb
209
208
  - test/dummy-rails4/config/initializers/devise.rb
210
- - test/dummy-rails4/config/initializers/inflections.rb
211
209
  - test/dummy-rails4/config/application.rb
212
210
  - test/dummy-rails4/config/environment.rb
213
211
  - test/dummy-rails4/config/environments/production.rb
@@ -221,6 +219,7 @@ files:
221
219
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/40fc2f3d2a468a00e463f1d313cb1683
222
220
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/681d1010f98d5ed273e67645c7cb454d
223
221
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/35f33ae400a6b0b5bf527436a68133b5
222
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/a51c3d05425a76a50181d8144764ac8f
224
223
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
225
224
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/edbef6e0d0a4742346cf479f2c522eb0
226
225
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/d0cde4ef34755468270bb49c4a3689f1
@@ -232,11 +231,14 @@ files:
232
231
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/bdaaf186999b6b59a3063d23b589d307
233
232
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
234
233
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/f1aac9109f5dae028b3c56eb07311208
234
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/79203f7770f5d8956dee4606e93f3d65
235
235
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
236
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/291faed72d20664326ce265eb8e1ed2f
236
237
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/b6f020b01a84691088a0c459a18f9c7e
237
238
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/5f1c168e97e274509aa4673eab0d86f6
238
239
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/b878faf942403e313a5b103e5d80488e
239
240
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/7f14251885cab31b58c878119cbdc199
241
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/8473d4c341d1accbf02a0c2d8270c68e
240
242
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/8ff157af159f38d424ce1367e29760a2
241
243
  - test/dummy-rails4/public/500.html
242
244
  - test/dummy-rails4/public/422.html
@@ -308,7 +310,6 @@ test_files:
308
310
  - test/dummy-rails3/config/initializers/secret_token.rb
309
311
  - test/dummy-rails3/config/initializers/backtrace_silencers.rb
310
312
  - test/dummy-rails3/config/initializers/devise.rb
311
- - test/dummy-rails3/config/initializers/inflections.rb
312
313
  - test/dummy-rails3/config/application.rb
313
314
  - test/dummy-rails3/config/environment.rb
314
315
  - test/dummy-rails3/config/environments/production.rb
@@ -360,7 +361,6 @@ test_files:
360
361
  - test/dummy-rails4/config/initializers/secret_token.rb
361
362
  - test/dummy-rails4/config/initializers/backtrace_silencers.rb
362
363
  - test/dummy-rails4/config/initializers/devise.rb
363
- - test/dummy-rails4/config/initializers/inflections.rb
364
364
  - test/dummy-rails4/config/application.rb
365
365
  - test/dummy-rails4/config/environment.rb
366
366
  - test/dummy-rails4/config/environments/production.rb
@@ -374,6 +374,7 @@ test_files:
374
374
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/40fc2f3d2a468a00e463f1d313cb1683
375
375
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/681d1010f98d5ed273e67645c7cb454d
376
376
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/35f33ae400a6b0b5bf527436a68133b5
377
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/a51c3d05425a76a50181d8144764ac8f
377
378
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
378
379
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/edbef6e0d0a4742346cf479f2c522eb0
379
380
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/d0cde4ef34755468270bb49c4a3689f1
@@ -385,11 +386,14 @@ test_files:
385
386
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/bdaaf186999b6b59a3063d23b589d307
386
387
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
387
388
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/f1aac9109f5dae028b3c56eb07311208
389
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/79203f7770f5d8956dee4606e93f3d65
388
390
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
391
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/291faed72d20664326ce265eb8e1ed2f
389
392
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/b6f020b01a84691088a0c459a18f9c7e
390
393
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/5f1c168e97e274509aa4673eab0d86f6
391
394
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/b878faf942403e313a5b103e5d80488e
392
395
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/7f14251885cab31b58c878119cbdc199
396
+ - test/dummy-rails4/tmp/cache/assets/test/sprockets/8473d4c341d1accbf02a0c2d8270c68e
393
397
  - test/dummy-rails4/tmp/cache/assets/test/sprockets/8ff157af159f38d424ce1367e29760a2
394
398
  - test/dummy-rails4/public/500.html
395
399
  - test/dummy-rails4/public/422.html
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
11
- #
12
- # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
- # inflect.acronym 'RESTful'
15
- # end
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
11
- #
12
- # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
- # inflect.acronym 'RESTful'
15
- # end