mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Update spec/requests/authentication_spec.rb
This commit is contained in:
parent
c0e756d085
commit
5347232376
1 changed files with 7 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue