devise 0.6.1 → 0.6.2
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.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +2 -1
- data/TODO +0 -3
- data/generators/devise_install/templates/devise.rb +1 -1
- data/lib/devise.rb +4 -3
- data/lib/devise/hooks/timeoutable.rb +7 -10
- data/lib/devise/hooks/trackable.rb +18 -0
- data/lib/devise/models.rb +22 -0
- data/lib/devise/models/authenticatable.rb +30 -31
- data/lib/devise/models/confirmable.rb +4 -9
- data/lib/devise/models/recoverable.rb +5 -7
- data/lib/devise/models/rememberable.rb +1 -1
- data/lib/devise/models/timeoutable.rb +2 -2
- data/lib/devise/models/trackable.rb +16 -0
- data/lib/devise/models/validatable.rb +15 -0
- data/lib/devise/orm/data_mapper.rb +9 -5
- data/lib/devise/schema.rb +10 -0
- data/lib/devise/version.rb +1 -1
- data/test/integration/confirmable_test.rb +2 -1
- data/test/integration/timeoutable_test.rb +12 -17
- data/test/integration/trackable_test.rb +64 -0
- data/test/models/authenticatable_test.rb +21 -36
- data/test/models/confirmable_test.rb +25 -40
- data/test/models/recoverable_test.rb +17 -20
- data/test/models/rememberable_test.rb +27 -28
- data/test/models/timeoutable_test.rb +5 -4
- data/test/models/trackable_test.rb +5 -0
- data/test/models/validatable_test.rb +6 -0
- data/test/models_test.rb +14 -15
- data/test/rails_app/app/controllers/users_controller.rb +3 -8
- data/test/rails_app/app/models/admin.rb +1 -1
- data/test/rails_app/app/models/user.rb +1 -0
- data/test/rails_app/config/routes.rb +1 -1
- data/test/test_helper.rb +2 -0
- metadata +42 -39
| @@ -3,11 +3,11 @@ require 'test/test_helper' | |
| 3 3 | 
             
            class TimeoutableTest < ActiveSupport::TestCase
         | 
| 4 4 |  | 
| 5 5 | 
             
              test 'should be expired' do
         | 
| 6 | 
            -
                assert new_user.timeout?( | 
| 6 | 
            +
                assert new_user.timeout?(31.minutes.ago)
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              test 'should not be expired' do
         | 
| 10 | 
            -
                assert_not new_user.timeout?( | 
| 10 | 
            +
                assert_not new_user.timeout?(29.minutes.ago)
         | 
| 11 11 | 
             
              end
         | 
| 12 12 |  | 
| 13 13 | 
             
              test 'should not be expired when params is nil' do
         | 
| @@ -15,11 +15,12 @@ class TimeoutableTest < ActiveSupport::TestCase | |
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 17 | 
             
              test 'fallback to Devise config option' do
         | 
| 18 | 
            -
                swap Devise, : | 
| 18 | 
            +
                swap Devise, :timeout_in => 1.minute do
         | 
| 19 19 | 
             
                  user = new_user
         | 
| 20 20 | 
             
                  assert user.timeout?(2.minutes.ago)
         | 
| 21 21 | 
             
                  assert_not user.timeout?(30.seconds.ago)
         | 
| 22 | 
            -
             | 
| 22 | 
            +
             | 
| 23 | 
            +
                  Devise.timeout_in = 5.minutes
         | 
| 23 24 | 
             
                  assert_not user.timeout?(2.minutes.ago)
         | 
| 24 25 | 
             
                  assert user.timeout?(6.minutes.ago)
         | 
| 25 26 | 
             
                end
         | 
| @@ -96,4 +96,10 @@ class ValidatableTest < ActiveSupport::TestCase | |
| 96 96 | 
             
                assert user.errors[:password]
         | 
| 97 97 | 
             
                assert_not user.errors[:password].to_a.include?('is too short (minimum is 6 characters)')
         | 
| 98 98 | 
             
              end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
              test 'shuold not be included in objects with invalid API' do
         | 
| 101 | 
            +
                assert_raise RuntimeError do
         | 
| 102 | 
            +
                  Class.new.send :include, Devise::Models::Validatable
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
              end
         | 
| 99 105 | 
             
            end
         | 
    
        data/test/models_test.rb
    CHANGED
    
    | @@ -16,6 +16,10 @@ class Rememberable < User | |
| 16 16 | 
             
              devise :authenticatable, :rememberable
         | 
| 17 17 | 
             
            end
         | 
| 18 18 |  | 
| 19 | 
            +
            class Trackable < User
         | 
| 20 | 
            +
              devise :authenticatable, :trackable
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 19 23 | 
             
            class Timeoutable < User
         | 
| 20 24 | 
             
              devise :authenticatable, :timeoutable
         | 
| 21 25 | 
             
            end
         | 
| @@ -37,7 +41,7 @@ class Configurable < User | |
| 37 41 | 
             
                           :pepper => 'abcdef',
         | 
| 38 42 | 
             
                           :confirm_within => 5.days,
         | 
| 39 43 | 
             
                           :remember_for => 7.days,
         | 
| 40 | 
            -
                           : | 
| 44 | 
            +
                           :timeout_in => 15.minutes
         | 
| 41 45 | 
             
            end
         | 
| 42 46 |  | 
| 43 47 | 
             
            class ActiveRecordTest < ActiveSupport::TestCase
         | 
| @@ -50,52 +54,47 @@ class ActiveRecordTest < ActiveSupport::TestCase | |
| 50 54 | 
             
                modules.each do |mod|
         | 
| 51 55 | 
             
                  assert include_module?(klass, mod)
         | 
| 52 56 | 
             
                end
         | 
| 53 | 
            -
              end
         | 
| 54 57 |  | 
| 55 | 
            -
             | 
| 56 | 
            -
                modules.each do |mod|
         | 
| 58 | 
            +
                (Devise::ALL - modules).each do |mod|
         | 
| 57 59 | 
             
                  assert_not include_module?(klass, mod)
         | 
| 58 60 | 
             
                end
         | 
| 59 61 | 
             
              end
         | 
| 60 62 |  | 
| 61 63 | 
             
              test 'include by default authenticatable only' do
         | 
| 62 64 | 
             
                assert_include_modules Authenticatable, :authenticatable
         | 
| 63 | 
            -
                assert_not_include_modules Authenticatable, :confirmable, :recoverable, :rememberable, :timeoutable, :validatable
         | 
| 64 65 | 
             
              end
         | 
| 65 66 |  | 
| 66 67 | 
             
              test 'add confirmable module only' do
         | 
| 67 68 | 
             
                assert_include_modules Confirmable, :authenticatable, :confirmable
         | 
| 68 | 
            -
                assert_not_include_modules Confirmable, :recoverable, :rememberable, :timeoutable, :validatable
         | 
| 69 69 | 
             
              end
         | 
| 70 70 |  | 
| 71 71 | 
             
              test 'add recoverable module only' do
         | 
| 72 72 | 
             
                assert_include_modules Recoverable, :authenticatable, :recoverable
         | 
| 73 | 
            -
                assert_not_include_modules Recoverable, :confirmable, :rememberable, :timeoutable, :validatable
         | 
| 74 73 | 
             
              end
         | 
| 75 74 |  | 
| 76 75 | 
             
              test 'add rememberable module only' do
         | 
| 77 76 | 
             
                assert_include_modules Rememberable, :authenticatable, :rememberable
         | 
| 78 | 
            -
             | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              test 'add trackable module only' do
         | 
| 80 | 
            +
                assert_include_modules Trackable, :authenticatable, :trackable
         | 
| 79 81 | 
             
              end
         | 
| 80 82 |  | 
| 81 83 | 
             
              test 'add timeoutable module only' do
         | 
| 82 84 | 
             
                assert_include_modules Timeoutable, :authenticatable, :timeoutable
         | 
| 83 | 
            -
                assert_not_include_modules Timeoutable, :confirmable, :recoverable, :rememberable, :validatable
         | 
| 84 85 | 
             
              end
         | 
| 85 86 |  | 
| 86 87 | 
             
              test 'add validatable module only' do
         | 
| 87 88 | 
             
                assert_include_modules Validatable, :authenticatable, :validatable
         | 
| 88 | 
            -
                assert_not_include_modules Validatable, :confirmable, :recoverable, :timeoutable, :rememberable
         | 
| 89 89 | 
             
              end
         | 
| 90 90 |  | 
| 91 91 | 
             
              test 'add all modules' do
         | 
| 92 92 | 
             
                assert_include_modules Devisable,
         | 
| 93 | 
            -
                  :authenticatable, :confirmable, :recoverable, :rememberable, :timeoutable, :validatable
         | 
| 93 | 
            +
                  :authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :timeoutable, :validatable
         | 
| 94 94 | 
             
              end
         | 
| 95 95 |  | 
| 96 96 | 
             
              test 'configure modules with except option' do
         | 
| 97 | 
            -
                assert_include_modules Exceptable, :authenticatable, :confirmable
         | 
| 98 | 
            -
                assert_not_include_modules Exceptable, :recoverable, :rememberable, :validatable
         | 
| 97 | 
            +
                assert_include_modules Exceptable, :authenticatable, :confirmable, :trackable, :timeoutable
         | 
| 99 98 | 
             
              end
         | 
| 100 99 |  | 
| 101 100 | 
             
              test 'set a default value for stretches' do
         | 
| @@ -114,8 +113,8 @@ class ActiveRecordTest < ActiveSupport::TestCase | |
| 114 113 | 
             
                assert_equal 7.days, Configurable.remember_for
         | 
| 115 114 | 
             
              end
         | 
| 116 115 |  | 
| 117 | 
            -
              test 'set a default value for  | 
| 118 | 
            -
                assert_equal 15.minutes, Configurable. | 
| 116 | 
            +
              test 'set a default value for timeout_in' do
         | 
| 117 | 
            +
                assert_equal 15.minutes, Configurable.timeout_in
         | 
| 119 118 | 
             
              end
         | 
| 120 119 |  | 
| 121 120 | 
             
              test 'set null fields on migrations' do
         | 
| @@ -5,13 +5,8 @@ class UsersController < ApplicationController | |
| 5 5 | 
             
                user_session[:cart] = "Cart"
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 | 
            -
              def  | 
| 9 | 
            -
                user_session['last_request_at'] =  | 
| 10 | 
            -
                render :text => ' | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def edit
         | 
| 14 | 
            -
                user_session['last_request_at'] = 9.minutes.ago.utc
         | 
| 15 | 
            -
                render :text => 'Edit user!'
         | 
| 8 | 
            +
              def expire
         | 
| 9 | 
            +
                user_session['last_request_at'] = 31.minutes.ago.utc
         | 
| 10 | 
            +
                render :text => 'User will be expired on next request'
         | 
| 16 11 | 
             
              end
         | 
| 17 12 | 
             
            end
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            class Admin < ActiveRecord::Base
         | 
| 2 | 
            -
              devise :all, :except => [:recoverable, :confirmable, :rememberable, :validatable]
         | 
| 2 | 
            +
              devise :all, :except => [:recoverable, :confirmable, :rememberable, :validatable, :trackable]
         | 
| 3 3 |  | 
| 4 4 | 
             
              def self.find_for_authentication(conditions)
         | 
| 5 5 | 
             
                last(:conditions => conditions)
         | 
| @@ -8,7 +8,7 @@ ActionController::Routing::Routes.draw do |map| | |
| 8 8 | 
             
                                          :path_prefix => '/:locale',
         | 
| 9 9 | 
             
                                          :requirements => { :extra => 'value' }
         | 
| 10 10 |  | 
| 11 | 
            -
              map.resources :users, :only => [:index, : | 
| 11 | 
            +
              map.resources :users, :only => [:index], :member => { :expire => :get }
         | 
| 12 12 | 
             
              map.resources :admins, :only => :index
         | 
| 13 13 | 
             
              map.root :controller => :home
         | 
| 14 14 |  | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -3,6 +3,7 @@ require File.join(File.dirname(__FILE__), 'rails_app', 'config', 'environment') | |
| 3 3 |  | 
| 4 4 | 
             
            require 'test_help'
         | 
| 5 5 | 
             
            require 'webrat'
         | 
| 6 | 
            +
            require 'mocha'
         | 
| 6 7 |  | 
| 7 8 | 
             
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 8 9 |  | 
| @@ -24,6 +25,7 @@ ActiveRecord::Schema.define(:version => 1) do | |
| 24 25 | 
             
                    t.confirmable
         | 
| 25 26 | 
             
                    t.recoverable
         | 
| 26 27 | 
             
                    t.rememberable
         | 
| 28 | 
            +
                    t.trackable
         | 
| 27 29 | 
             
                  end
         | 
| 28 30 |  | 
| 29 31 | 
             
                  t.timestamps
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: devise
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - "Jos\xC3\xA9 Valim"
         | 
| @@ -10,7 +10,7 @@ autorequire: | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2009-11- | 
| 13 | 
            +
            date: 2009-11-25 00:00:00 -02:00
         | 
| 14 14 | 
             
            default_executable: 
         | 
| 15 15 | 
             
            dependencies: 
         | 
| 16 16 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -31,7 +31,6 @@ extensions: [] | |
| 31 31 |  | 
| 32 32 | 
             
            extra_rdoc_files: 
         | 
| 33 33 | 
             
            - README.rdoc
         | 
| 34 | 
            -
            - TODO
         | 
| 35 34 | 
             
            files: 
         | 
| 36 35 | 
             
            - CHANGELOG.rdoc
         | 
| 37 36 | 
             
            - MIT-LICENSE
         | 
| @@ -72,6 +71,7 @@ files: | |
| 72 71 | 
             
            - lib/devise/failure_app.rb
         | 
| 73 72 | 
             
            - lib/devise/hooks/confirmable.rb
         | 
| 74 73 | 
             
            - lib/devise/hooks/timeoutable.rb
         | 
| 74 | 
            +
            - lib/devise/hooks/trackable.rb
         | 
| 75 75 | 
             
            - lib/devise/locales/en.yml
         | 
| 76 76 | 
             
            - lib/devise/mapping.rb
         | 
| 77 77 | 
             
            - lib/devise/models.rb
         | 
| @@ -80,6 +80,7 @@ files: | |
| 80 80 | 
             
            - lib/devise/models/recoverable.rb
         | 
| 81 81 | 
             
            - lib/devise/models/rememberable.rb
         | 
| 82 82 | 
             
            - lib/devise/models/timeoutable.rb
         | 
| 83 | 
            +
            - lib/devise/models/trackable.rb
         | 
| 83 84 | 
             
            - lib/devise/models/validatable.rb
         | 
| 84 85 | 
             
            - lib/devise/orm/active_record.rb
         | 
| 85 86 | 
             
            - lib/devise/orm/data_mapper.rb
         | 
| @@ -124,47 +125,49 @@ signing_key: | |
| 124 125 | 
             
            specification_version: 3
         | 
| 125 126 | 
             
            summary: Flexible authentication solution for Rails with Warden
         | 
| 126 127 | 
             
            test_files: 
         | 
| 127 | 
            -
            - test/ | 
| 128 | 
            -
            - test/ | 
| 128 | 
            +
            - test/rails_app/config/boot.rb
         | 
| 129 | 
            +
            - test/rails_app/config/routes.rb
         | 
| 130 | 
            +
            - test/rails_app/config/environments/development.rb
         | 
| 131 | 
            +
            - test/rails_app/config/environments/production.rb
         | 
| 132 | 
            +
            - test/rails_app/config/environments/test.rb
         | 
| 133 | 
            +
            - test/rails_app/config/environment.rb
         | 
| 134 | 
            +
            - test/rails_app/config/initializers/session_store.rb
         | 
| 135 | 
            +
            - test/rails_app/config/initializers/new_rails_defaults.rb
         | 
| 136 | 
            +
            - test/rails_app/app/controllers/users_controller.rb
         | 
| 137 | 
            +
            - test/rails_app/app/controllers/application_controller.rb
         | 
| 138 | 
            +
            - test/rails_app/app/controllers/admins_controller.rb
         | 
| 139 | 
            +
            - test/rails_app/app/controllers/home_controller.rb
         | 
| 140 | 
            +
            - test/rails_app/app/helpers/application_helper.rb
         | 
| 141 | 
            +
            - test/rails_app/app/models/admin.rb
         | 
| 142 | 
            +
            - test/rails_app/app/models/organizer.rb
         | 
| 143 | 
            +
            - test/rails_app/app/models/account.rb
         | 
| 144 | 
            +
            - test/rails_app/app/models/user.rb
         | 
| 129 145 | 
             
            - test/controllers/url_helpers_test.rb
         | 
| 130 | 
            -
            - test/ | 
| 131 | 
            -
            - test/ | 
| 132 | 
            -
            - test/ | 
| 133 | 
            -
            - test/ | 
| 134 | 
            -
            - test/models/recoverable_test.rb
         | 
| 135 | 
            -
            - test/models/authenticatable_test.rb
         | 
| 146 | 
            +
            - test/controllers/helpers_test.rb
         | 
| 147 | 
            +
            - test/controllers/filters_test.rb
         | 
| 148 | 
            +
            - test/models_test.rb
         | 
| 149 | 
            +
            - test/integration/authenticatable_test.rb
         | 
| 136 150 | 
             
            - test/integration/rememberable_test.rb
         | 
| 151 | 
            +
            - test/integration/recoverable_test.rb
         | 
| 137 152 | 
             
            - test/integration/timeoutable_test.rb
         | 
| 153 | 
            +
            - test/integration/trackable_test.rb
         | 
| 138 154 | 
             
            - test/integration/confirmable_test.rb
         | 
| 139 | 
            -
            - test/integration/recoverable_test.rb
         | 
| 140 | 
            -
            - test/integration/authenticatable_test.rb
         | 
| 141 | 
            -
            - test/test_helper.rb
         | 
| 142 | 
            -
            - test/test_helpers_test.rb
         | 
| 143 | 
            -
            - test/encryptors_test.rb
         | 
| 144 | 
            -
            - test/mailers/reset_password_instructions_test.rb
         | 
| 145 155 | 
             
            - test/mailers/confirmation_instructions_test.rb
         | 
| 146 | 
            -
            - test/ | 
| 147 | 
            -
            - test/ | 
| 148 | 
            -
            - test/ | 
| 149 | 
            -
            - test/ | 
| 150 | 
            -
            - test/ | 
| 151 | 
            -
            - test/ | 
| 152 | 
            -
            - test/ | 
| 153 | 
            -
            - test/ | 
| 154 | 
            -
            - test/ | 
| 155 | 
            -
            - test/rails_app/app/models/admin.rb
         | 
| 156 | 
            -
            - test/rails_app/app/models/organizer.rb
         | 
| 157 | 
            -
            - test/rails_app/app/helpers/application_helper.rb
         | 
| 158 | 
            -
            - test/rails_app/config/boot.rb
         | 
| 159 | 
            -
            - test/rails_app/config/environments/production.rb
         | 
| 160 | 
            -
            - test/rails_app/config/environments/development.rb
         | 
| 161 | 
            -
            - test/rails_app/config/environments/test.rb
         | 
| 162 | 
            -
            - test/rails_app/config/initializers/new_rails_defaults.rb
         | 
| 163 | 
            -
            - test/rails_app/config/initializers/session_store.rb
         | 
| 164 | 
            -
            - test/rails_app/config/routes.rb
         | 
| 165 | 
            -
            - test/rails_app/config/environment.rb
         | 
| 166 | 
            -
            - test/mapping_test.rb
         | 
| 156 | 
            +
            - test/mailers/reset_password_instructions_test.rb
         | 
| 157 | 
            +
            - test/models/authenticatable_test.rb
         | 
| 158 | 
            +
            - test/models/rememberable_test.rb
         | 
| 159 | 
            +
            - test/models/recoverable_test.rb
         | 
| 160 | 
            +
            - test/models/timeoutable_test.rb
         | 
| 161 | 
            +
            - test/models/trackable_test.rb
         | 
| 162 | 
            +
            - test/models/validatable_test.rb
         | 
| 163 | 
            +
            - test/models/confirmable_test.rb
         | 
| 164 | 
            +
            - test/encryptors_test.rb
         | 
| 167 165 | 
             
            - test/support/model_tests_helper.rb
         | 
| 168 166 | 
             
            - test/support/assertions_helper.rb
         | 
| 169 167 | 
             
            - test/support/integration_tests_helper.rb
         | 
| 170 | 
            -
            - test/ | 
| 168 | 
            +
            - test/failure_app_test.rb
         | 
| 169 | 
            +
            - test/devise_test.rb
         | 
| 170 | 
            +
            - test/routes_test.rb
         | 
| 171 | 
            +
            - test/test_helper.rb
         | 
| 172 | 
            +
            - test/test_helpers_test.rb
         | 
| 173 | 
            +
            - test/mapping_test.rb
         |