Last active
February 3, 2016 01:42
-
-
Save pinzolo/11321cf742668f79aef3 to your computer and use it in GitHub Desktop.
Devise の confirmations_controller にて期間丁度に確認した場合、Mac, Linux での挙動が異なることの検証
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class ConfirmationsControllerTest < ActionController::TestCase | |
setup do | |
@request.env['devise.mapping'] = Devise.mappings[:user] | |
end | |
test '登録して10日以内なら確認可' do | |
user = create(:user) | |
Time.stub(:now, user.confirmation_sent_at + 10.days) do | |
get :show, confirmation_token: user.confirmation_token | |
end | |
assert user.reload.confirmed? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/devise.rb | |
Devise.setup do |config| | |
# some settings | |
config.confirm_within = 10.days | |
# some settings | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :user do | |
email '[email protected]' | |
password 'newSecurePassw0rd' | |
confirmation_token 'xxxxxxxxxxxxxxxx' | |
confirmation_sent_at Time.zone.now.yesterday | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment