Skip to content

Instantly share code, notes, and snippets.

@pinzolo
Last active February 3, 2016 01:42
Show Gist options
  • Save pinzolo/11321cf742668f79aef3 to your computer and use it in GitHub Desktop.
Save pinzolo/11321cf742668f79aef3 to your computer and use it in GitHub Desktop.
Devise の confirmations_controller にて期間丁度に確認した場合、Mac, Linux での挙動が異なることの検証
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
# config/initializers/devise.rb
Devise.setup do |config|
# some settings
config.confirm_within = 10.days
# some settings
end
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