From 887a053e71d78e5bb95dd58c67a52a60f31099ab Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 2 Jul 2022 23:47:12 +0200 Subject: [PATCH] Appease the dog overlords --- .../otp_authentication_controller_spec.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb index 07257e29..809446e1 100644 --- a/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb @@ -3,9 +3,11 @@ require "rails_helper" describe Settings::TwoFactorAuthentication::OtpAuthenticationController, type: :controller do - let(:user) { FactoryBot.create :user, - otp_module: :disabled, - otp_secret_key: "EJFNIJPYXXTCQSRTQY6AG7XQLAT2IDG5H7NGLJE3" } + let(:user) do + FactoryBot.create :user, + otp_module: :disabled, + otp_secret_key: "EJFNIJPYXXTCQSRTQY6AG7XQLAT2IDG5H7NGLJE3" + end describe "#index" do subject { get :index } @@ -40,12 +42,12 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController, type: : context "user enters the incorrect code" do let(:update_params) do { - user: { otp_validation: 123456 } + user: { otp_validation: 123456 } } end it "shows an error if the user enters the incorrect code" do - Timecop.freeze(Time.at(1603290888)) do + Timecop.freeze(Time.at(1603290888).utc) do subject expect(response).to redirect_to :settings_two_factor_authentication_otp_authentication expect(flash[:error]).to eq("The code you entered was invalid.") @@ -56,12 +58,12 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController, type: : context "user enters the correct code" do let(:update_params) do { - user: { otp_validation: 187894 } + user: { otp_validation: 187894 } } end it "enables 2FA for the logged in user and generates recovery keys" do - Timecop.freeze(Time.at(1603290888)) do + Timecop.freeze(Time.at(1603290888).utc) do subject expect(response).to have_rendered(:recovery_keys) @@ -70,7 +72,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController, type: : end it "shows an error if the user attempts to use the code once it has expired" do - Timecop.freeze(Time.at(1603290950)) do + Timecop.freeze(Time.at(1603290950).utc) do subject expect(response).to redirect_to :settings_two_factor_authentication_otp_authentication expect(flash[:error]).to eq(I18n.t("errors.invalid_otp"))