From caf0c21036d1b850c6d5c1517982e69227be21dd Mon Sep 17 00:00:00 2001 From: Janell Huyck Date: Fri, 19 Apr 2024 16:05:14 -0400 Subject: [PATCH] Rubocop: --- .../specs/user_scenarios/admin_user_spec.rb | 9 +++---- .../user_scenarios/read_only_user_spec.rb | 9 +++---- .../user_scenarios/standard_user_spec.rb | 9 +++---- .../support/helpers/authentication_helpers.rb | 25 +++++++++++++------ .../shared_contexts/admin_user_context.rb | 4 +-- .../shared_contexts/read_only_user_context.rb | 4 +-- .../shared_contexts/standard_user_context.rb | 4 +-- 7 files changed, 36 insertions(+), 28 deletions(-) diff --git a/spec/features/specs/user_scenarios/admin_user_spec.rb b/spec/features/specs/user_scenarios/admin_user_spec.rb index a63568c6..5858f2e9 100644 --- a/spec/features/specs/user_scenarios/admin_user_spec.rb +++ b/spec/features/specs/user_scenarios/admin_user_spec.rb @@ -2,11 +2,10 @@ require 'rails_helper' -RSpec.describe "Admin User Functionalities", type: :feature do - include_context "admin user context" +RSpec.describe 'Admin User Functionalities', type: :feature do + include_context 'admin user context' - it "passes a test" do + it 'passes a test' do expect(1).to eq(1) end - -end \ No newline at end of file +end diff --git a/spec/features/specs/user_scenarios/read_only_user_spec.rb b/spec/features/specs/user_scenarios/read_only_user_spec.rb index e4d49a8c..5ccb9102 100644 --- a/spec/features/specs/user_scenarios/read_only_user_spec.rb +++ b/spec/features/specs/user_scenarios/read_only_user_spec.rb @@ -2,11 +2,10 @@ require 'rails_helper' -RSpec.describe "Read-Only User Functionalities", type: :feature do - include_context "read-only user context" +RSpec.describe 'Read-Only User Functionalities', type: :feature do + include_context 'read-only user context' - it "passes a test" do + it 'passes a test' do expect(1).to eq(1) end - -end \ No newline at end of file +end diff --git a/spec/features/specs/user_scenarios/standard_user_spec.rb b/spec/features/specs/user_scenarios/standard_user_spec.rb index 8d7f5d55..6f118094 100644 --- a/spec/features/specs/user_scenarios/standard_user_spec.rb +++ b/spec/features/specs/user_scenarios/standard_user_spec.rb @@ -2,11 +2,10 @@ require 'rails_helper' -RSpec.describe "Standard User Functionalities", type: :feature do - include_context "standard user context" +RSpec.describe 'Standard User Functionalities', type: :feature do + include_context 'standard user context' - it "passes a test" do + it 'passes a test' do expect(1).to eq(1) end - -end \ No newline at end of file +end diff --git a/spec/features/support/helpers/authentication_helpers.rb b/spec/features/support/helpers/authentication_helpers.rb index 18f8fe2a..db818aef 100644 --- a/spec/features/support/helpers/authentication_helpers.rb +++ b/spec/features/support/helpers/authentication_helpers.rb @@ -8,13 +8,24 @@ def log_in_as_user(user) fill_in 'Email', with: user.email fill_in 'Password', with: 'notapassword' # from the factory click_button 'Log in' + validate_login_success + end + + private + + def validate_login_success + check_successful_sign_in + check_no_error_messages + end + + def check_successful_sign_in + expect(page).to have_content('Signed in successfully') + expect(page).to have_content('Conservation Records') + end - aggregate_failures "checking login and dashboard access" do - expect(page).to have_content('Signed in successfully') - expect(page).to have_content('Conservation Records') - expect(page).to_not have_content('Invalid Email or password.') - expect(page).to_not have_content('Log in') - expect(page).to_not have_content('You are already signed in.') - end + def check_no_error_messages + expect(page).to_not have_content('Invalid Email or password.') + expect(page).to_not have_content('Log in') + expect(page).to_not have_content('You are already signed in.') end end diff --git a/spec/features/support/shared_contexts/admin_user_context.rb b/spec/features/support/shared_contexts/admin_user_context.rb index 435dde84..d494e3be 100644 --- a/spec/features/support/shared_contexts/admin_user_context.rb +++ b/spec/features/support/shared_contexts/admin_user_context.rb @@ -2,11 +2,11 @@ # Sets up and logs in an admin user for tests, using aggregate_failures to # report all login-related issues at once. -RSpec.shared_context "admin user context", shared_context: :metadata do +RSpec.shared_context 'admin user context', shared_context: :metadata do let(:user) { create(:user, role: 'admin') } before(:each) do user log_in_as_user(user) end -end \ No newline at end of file +end diff --git a/spec/features/support/shared_contexts/read_only_user_context.rb b/spec/features/support/shared_contexts/read_only_user_context.rb index b578cbb5..d4c158be 100644 --- a/spec/features/support/shared_contexts/read_only_user_context.rb +++ b/spec/features/support/shared_contexts/read_only_user_context.rb @@ -2,11 +2,11 @@ # Sets up and logs in an admin user for tests, using aggregate_failures to # report all login-related issues at once. -RSpec.shared_context "read-only user context", shared_context: :metadata do +RSpec.shared_context 'read-only user context', shared_context: :metadata do let(:user) { create(:user, role: 'read_only') } before(:each) do user log_in_as_user(user) end -end \ No newline at end of file +end diff --git a/spec/features/support/shared_contexts/standard_user_context.rb b/spec/features/support/shared_contexts/standard_user_context.rb index 3cfc2f9b..a21e01e3 100644 --- a/spec/features/support/shared_contexts/standard_user_context.rb +++ b/spec/features/support/shared_contexts/standard_user_context.rb @@ -2,11 +2,11 @@ # Sets up and logs in an admin user for tests, using aggregate_failures to # report all login-related issues at once. -RSpec.shared_context "standard user context", shared_context: :metadata do +RSpec.shared_context 'standard user context', shared_context: :metadata do let(:user) { create(:user, role: 'standard') } before(:each) do user log_in_as_user(user) end -end \ No newline at end of file +end