From e73cf356d2f7dc38ef30e5465635c4c0813f4ade Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 5 Apr 2024 18:52:05 +0200 Subject: [PATCH] Move OAuth flow tests from feature tests to system tests (#29837) --- spec/{features => system}/oauth_spec.rb | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) rename spec/{features => system}/oauth_spec.rb (94%) diff --git a/spec/features/oauth_spec.rb b/spec/system/oauth_spec.rb similarity index 94% rename from spec/features/oauth_spec.rb rename to spec/system/oauth_spec.rb index 720c26289..060978217 100644 --- a/spec/features/oauth_spec.rb +++ b/spec/system/oauth_spec.rb @@ -3,13 +3,14 @@ require 'rails_helper' describe 'Using OAuth from an external app' do - let(:client_app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/', scopes: 'read') } + let(:client_app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/health', scopes: 'read') } context 'when the user is already logged in' do let!(:user) { Fabricate(:user) } before do - sign_in user, scope: :user + visit new_user_session_path + fill_in_auth_details(user.email, user.password) end it 'when accepting the authorization request' do @@ -164,20 +165,19 @@ describe 'Using OAuth from an external app' do expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be false end end - - 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') - end - # TODO: external auth end + + 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') + end end