diff --git a/spec/controllers/two_factor_authentication_controller_spec.rb b/spec/controllers/two_factor_authentication_controller_spec.rb index 100876a..d578d0b 100644 --- a/spec/controllers/two_factor_authentication_controller_spec.rb +++ b/spec/controllers/two_factor_authentication_controller_spec.rb @@ -2,6 +2,14 @@ require 'spec_helper' describe Devise::TwoFactorAuthenticationController, type: :controller do describe 'is_fully_authenticated? helper' do + def post_code(code) + if Rails::VERSION::MAJOR >= 5 + post :update, params: { code: code } + else + post :update, code: code + end + end + before do sign_in end @@ -9,7 +17,7 @@ describe Devise::TwoFactorAuthenticationController, type: :controller do context 'after user enters valid OTP code' do it 'returns true' do controller.current_user.send_new_otp - post :update, code: controller.current_user.direct_otp + post_code controller.current_user.direct_otp expect(subject.is_fully_authenticated?).to eq true end end @@ -24,7 +32,7 @@ describe Devise::TwoFactorAuthenticationController, type: :controller do context 'when user enters an invalid OTP' do it 'returns false' do - post :update, code: '12345' + post_code '12345' expect(subject.is_fully_authenticated?).to eq false end diff --git a/spec/support/authenticated_model_helper.rb b/spec/support/authenticated_model_helper.rb index 42696e6..8138dc5 100644 --- a/spec/support/authenticated_model_helper.rb +++ b/spec/support/authenticated_model_helper.rb @@ -29,7 +29,7 @@ module AuthenticatedModelHelper end def create_table_for_nonencrypted_user - silence_stream(STDOUT) do + ActiveRecord::Migration.suppress_messages do ActiveRecord::Schema.define(version: 1) do create_table 'users', force: :cascade do |t| t.string 'email', default: '', null: false