diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9850ff15..9b396683 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base if current_user.present? && current_user.banned? name = current_user.screen_name # obligatory '2001: A Space Odyssey' reference - flash[:notice] = t(".banned", name: name) + flash[:notice] = t(".banned", name:) current_ban = current_user.bans.current.first unless current_ban&.reason.nil? flash[:notice] += "\n#{t('.reason', reason: current_ban.reason)}" diff --git a/spec/controllers/user/sessions_controller_spec.rb b/spec/controllers/user/sessions_controller_spec.rb index 3c77627d..66d6bdf0 100644 --- a/spec/controllers/user/sessions_controller_spec.rb +++ b/spec/controllers/user/sessions_controller_spec.rb @@ -9,7 +9,7 @@ describe User::SessionsController do end describe "#create" do - let(:user) { FactoryBot.create(:user, password: '/bin/animals64') } + let(:user) { FactoryBot.create(:user, password: "/bin/animals64") } subject { post :create, params: { user: { login: user.email, password: user.password } } } @@ -21,13 +21,13 @@ describe User::SessionsController do user.otp_module = :enabled user.save - expect(subject).to have_rendered('auth/two_factor_authentication') + expect(subject).to have_rendered("auth/two_factor_authentication") end context "2fa sign in attempt" do subject do post :create, - params: { user: { otp_attempt: code_input } }, + params: { user: { otp_attempt: code_input } }, session: { user_sign_in_uid: user.id } end @@ -53,10 +53,10 @@ describe User::SessionsController do end context "correct recovery code" do - let(:code_input) { 'raccoons' } + let(:code_input) { "raccoons" } before do - user.totp_recovery_codes << TotpRecoveryCode.create(code: 'raccoons') + user.totp_recovery_codes << TotpRecoveryCode.create(code: "raccoons") end it "consumes the recovery code" do @@ -66,7 +66,7 @@ describe User::SessionsController do end context "incorrect recovery code" do - let(:code_input) { 'abcdefgh' } + let(:code_input) { "abcdefgh" } it "redirects to the sign in page" do expect(subject).to redirect_to :new_user_session @@ -82,7 +82,7 @@ describe User::SessionsController do it "redirects to the sign in page" do expect(subject).to redirect_to :new_user_session - expect(flash[:notice]).to eq "#{I18n.t("user.sessions.create.banned", name: user.screen_name)}\n#{I18n.t("user.sessions.create.reason", reason: 'Do not feed the animals')}" + expect(flash[:notice]).to eq "#{I18n.t('user.sessions.create.banned', name: user.screen_name)}\n#{I18n.t('user.sessions.create.reason', reason: 'Do not feed the animals')}" end end @@ -96,9 +96,9 @@ describe User::SessionsController do it "redirects to the sign in page" do expect(subject).to redirect_to :new_user_session expect(flash[:notice]).to eq I18n.t("user.sessions.create.banned", name: user.screen_name) + - "\n#{I18n.t("user.sessions.create.reason", reason: 'Do not feed the animals')}" \ - "\n#{I18n.t("user.sessions.create.until", time: expiry)}" + "\n#{I18n.t('user.sessions.create.reason', reason: 'Do not feed the animals')}" \ + "\n#{I18n.t('user.sessions.create.until', time: expiry)}" end end end -end \ No newline at end of file +end