devise_token_auth 0.1.29.beta6 → 0.1.29.beta7

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,5 +36,25 @@ class UserTest < ActiveSupport::TestCase
36
36
  refute @user.errors.messages[:email]
37
37
  end
38
38
  end
39
+
40
+ describe 'expired tokens are destroyed on save' do
41
+ before do
42
+ @user = users(:confirmed_email_user)
43
+ @user.skip_confirmation!
44
+ @user.save!
45
+
46
+ @old_auth_headers = @user.create_new_auth_token
47
+ @new_auth_headers = @user.create_new_auth_token
48
+ expire_token(@user, @old_auth_headers['client'])
49
+ end
50
+
51
+ test 'expired token was removed' do
52
+ refute @user.tokens[@old_auth_headers['client']]
53
+ end
54
+
55
+ test 'current token was not removed' do
56
+ assert @user.tokens[@new_auth_headers['client']]
57
+ end
58
+ end
39
59
  end
40
60
  end
data/test/test_helper.rb CHANGED
@@ -41,12 +41,12 @@ class ActiveSupport::TestCase
41
41
 
42
42
  def age_token(user, client_id)
43
43
  user.tokens[client_id]['updated_at'] = Time.now - (DeviseTokenAuth.batch_request_buffer_throttle + 10.seconds)
44
- user.save
44
+ user.save!
45
45
  end
46
46
 
47
47
  def expire_token(user, client_id)
48
48
  user.tokens[client_id]['expiry'] = (Time.now - (DeviseTokenAuth.token_lifespan.to_f + 10.seconds)).to_i
49
- user.save
49
+ user.save!
50
50
  end
51
51
  end
52
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_token_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29.beta6
4
+ version: 0.1.29.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley
@@ -200,8 +200,7 @@ files:
200
200
  - test/dummy/public/favicon.ico
201
201
  - test/dummy/tmp/generators/app/models/user.rb
202
202
  - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
203
- - test/dummy/tmp/generators/config/routes.rb
204
- - test/dummy/tmp/generators/db/migrate/20141002192139_devise_token_auth_create_users.rb
203
+ - test/dummy/tmp/generators/db/migrate/20141002213327_devise_token_auth_create_users.rb
205
204
  - test/dummy/tmp/restart.txt
206
205
  - test/fixtures/evil_users.yml
207
206
  - test/fixtures/mangs.yml
@@ -315,8 +314,7 @@ test_files:
315
314
  - test/dummy/README.rdoc
316
315
  - test/dummy/tmp/generators/app/models/user.rb
317
316
  - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
318
- - test/dummy/tmp/generators/config/routes.rb
319
- - test/dummy/tmp/generators/db/migrate/20141002192139_devise_token_auth_create_users.rb
317
+ - test/dummy/tmp/generators/db/migrate/20141002213327_devise_token_auth_create_users.rb
320
318
  - test/dummy/tmp/restart.txt
321
319
  - test/fixtures/evil_users.yml
322
320
  - test/fixtures/mangs.yml
@@ -1,4 +0,0 @@
1
- Rails.application.routes.draw do
2
- mount_devise_token_auth_for 'User', at: '/auth'
3
- patch '/chong', to: 'bong#index'
4
- end