From b3c7faba031ff6ee511574bd233c4c6b75b0da86 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 21 Jun 2022 21:33:07 +0200 Subject: [PATCH] run Rubocop --- .../role_constrained_routes_spec.rb | 34 +++++++++---------- spec/support/factory_bot.rb | 1 - 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/spec/integration/role_constrained_routes_spec.rb b/spec/integration/role_constrained_routes_spec.rb index 4b093876..0bbab0fe 100644 --- a/spec/integration/role_constrained_routes_spec.rb +++ b/spec/integration/role_constrained_routes_spec.rb @@ -1,51 +1,51 @@ # frozen_string_literal: true -require 'rails_helper' +require "rails_helper" -describe 'role-constrained routes', type: :request do - shared_examples_for 'fails to access route' do - it 'fails to access route' do +describe "role-constrained routes", type: :request do + shared_examples_for "fails to access route" do + it "fails to access route" do # 404 = no user found -- we have a fallback route if something could not be matched expect(subject).to eq 404 end end - shared_examples_for 'routes for' do |roles, subject_block, skip_reason: nil| + shared_examples_for "routes for" do |roles, subject_block, skip_reason: nil| before { skip(skip_reason) } if skip_reason subject(&subject_block) - context 'not signed in' do - include_examples 'fails to access route' + context "not signed in" do + include_examples "fails to access route" end roles.each do |role| context "signed in user without #{role} role" do - let(:user) { FactoryBot.create(:user, password: 'test1234') } + let(:user) { FactoryBot.create(:user, password: "test1234") } before(:each) do - post '/sign_in', params: { user: { login: user.email, password: user.password } } + post "/sign_in", params: { user: { login: user.email, password: user.password } } end - include_examples 'fails to access route' + include_examples "fails to access route" end context "signed in user with #{role} role" do - let(:user) { FactoryBot.create(:user, password: 'test1234', roles: [role]) } + let(:user) { FactoryBot.create(:user, password: "test1234", roles: [role]) } before(:each) do - post '/sign_in', params: { user: { login: user.email, password: user.password } } + post "/sign_in", params: { user: { login: user.email, password: user.password } } end - it 'can access route' do + it "can access route" do expect(subject).to be_in 200..299 end end end end - it_behaves_like('routes for', [:administrator], -> { get('/justask_admin') }) - it_behaves_like('routes for', [:administrator], -> { get('/sidekiq') }) - it_behaves_like('routes for', [:administrator], -> { get('/pghero') }, skip_reason: 'PG::InFailedSqlTransaction due to 5.1 upgrade, works fine outside specs though') - it_behaves_like('routes for', %i[administrator moderator], -> { get('/moderation') }) + it_behaves_like("routes for", [:administrator], -> { get("/justask_admin") }) + it_behaves_like("routes for", [:administrator], -> { get("/sidekiq") }) + it_behaves_like("routes for", [:administrator], -> { get("/pghero") }), skip_reason: "PG::InFailedSqlTransaction due to 5.1 upgrade, works fine outside specs though") + it_behaves_like("routes for", %i[administrator moderator], -> { get("/moderation") }) end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb index d49046ca..31663a9d 100644 --- a/spec/support/factory_bot.rb +++ b/spec/support/factory_bot.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "factory_bot_rails"