Skip to content

Commit

Permalink
Extrude fill_in_auth_details method to ProfileStories spec suppor…
Browse files Browse the repository at this point in the history
…t module (mastodon#31163)
  • Loading branch information
mjankowski authored Jul 29, 2024
1 parent 6ad477d commit 95eadab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 7 additions & 3 deletions spec/support/stories/profile_stories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
module ProfileStories
attr_reader :bob, :alice, :alice_bio

def fill_in_auth_details(email, password)
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on I18n.t('auth.login')
end

def as_a_registered_user
@bob = Fabricate(
:user,
Expand All @@ -16,9 +22,7 @@ def as_a_registered_user
def as_a_logged_in_user
as_a_registered_user
visit new_user_session_path
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on I18n.t('auth.login')
fill_in_auth_details(email, password)
end

def as_a_logged_in_admin
Expand Down
12 changes: 3 additions & 9 deletions spec/system/log_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@
end

it 'A valid email and password user is able to log in' do
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on I18n.t('auth.login')
fill_in_auth_details(email, password)

expect(subject).to have_css('div.app-holder')
end

it 'A invalid email and password user is not able to log in' do
fill_in 'user_email', with: 'invalid_email'
fill_in 'user_password', with: 'invalid_password'
click_on I18n.t('auth.login')
fill_in_auth_details('invalid_email', 'invalid_password')

expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
end
Expand All @@ -36,9 +32,7 @@
let(:confirmed_at) { nil }

it 'A unconfirmed user is able to log in' do
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on I18n.t('auth.login')
fill_in_auth_details(email, password)

expect(subject).to have_css('div.admin-wrapper')
end
Expand Down
8 changes: 2 additions & 6 deletions spec/system/oauth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'rails_helper'

describe 'Using OAuth from an external app' do
include ProfileStories

subject { visit "/oauth/authorize?#{params.to_query}" }

let(:client_app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: about_url(host: Rails.application.config.x.local_domain), scopes: 'read') }
Expand Down Expand Up @@ -246,12 +248,6 @@

private

def fill_in_auth_details(email, password)
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on I18n.t('auth.login')
end

def fill_in_otp_details(value)
fill_in 'user_otp_attempt', with: value
click_on I18n.t('auth.login')
Expand Down

0 comments on commit 95eadab

Please sign in to comment.