Last active
December 10, 2015 07:28
-
-
Save pinzolo/8a2ac20964721c17f5ee to your computer and use it in GitHub Desktop.
確認メールの有効期限を設定した場合のテスト
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 Users::ConfirmationsControllerTest < ActionController::TestCase | |
setup do | |
@request.env['devise.mapping'] = Devise.mappings[:user] | |
@user = create(:user) | |
end | |
test '登録して30日以内なら確認可' do | |
assert_not @user.confirmed? | |
Time.stub(:now, @user.confirmation_sent_at + 30.days) do | |
get :show, confirmation_token: @user.confirmation_token | |
end | |
assert user.reload.confirmed? | |
end | |
test '登録して30日以降なら確認不可' do | |
assert_not @user.confirmed? | |
Time.stub(:now, @user.confirmation_sent_at + 30.days + 1.second) do | |
get :show, confirmation_token: @user.confirmation_token | |
end | |
assert_not @user.reload.confirmed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment