From 53472323767d48022ec8f9e1d19071b6a2532209 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sun, 21 Sep 2025 13:22:07 +0200 Subject: [PATCH] Update spec/requests/authentication_spec.rb --- spec/requests/authentication_spec.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/requests/authentication_spec.rb b/spec/requests/authentication_spec.rb index f98efab8..99b46959 100644 --- a/spec/requests/authentication_spec.rb +++ b/spec/requests/authentication_spec.rb @@ -69,19 +69,15 @@ RSpec.describe 'Authentication', type: :request do describe 'Mobile iOS Authentication' do it 'redirects to iOS success path when signing in with iOS client header' do - # Sign in with iOS client header - sign_in user - - # Mock the after_sign_in_path_for redirect behavior - allow_any_instance_of(ApplicationController).to receive(:after_sign_in_path_for).and_return(ios_success_path) - - # Make a request with the iOS client header + # Make a login request with the iOS client header (user NOT pre-signed in) post user_session_path, params: { user: { email: user.email, password: 'password123' } }, headers: { 'X-Dawarich-Client' => 'ios' } # Should redirect to iOS success endpoint after successful login - expect(response).to redirect_to(ios_success_path) + # The redirect will include a token parameter generated by after_sign_in_path_for + expect(response).to redirect_to(%r{auth/ios/success\?token=}) + expect(response.location).to include('token=') end it 'returns JSON response with JWT token for iOS success endpoint' do @@ -127,15 +123,14 @@ RSpec.describe 'Authentication', type: :request do end it 'uses default path for non-iOS clients' do - sign_in user - - # Make a request without iOS client header + # Make a login request without iOS client header (user NOT pre-signed in) post user_session_path, params: { user: { email: user.email, password: 'password123' } } # Should redirect to default path (not iOS success) - expect(response).not_to redirect_to(ios_success_path) + expect(response).not_to redirect_to(%r{auth/ios/success}) + expect(response.location).not_to include('auth/ios/success') end end end