Skip to content

Commit

Permalink
Store the whole string of the request headers language
Browse files Browse the repository at this point in the history
Update the tests accordingly
  • Loading branch information
Patrycja-Nowak committed Jan 26, 2024
1 parent 65db1cb commit ebc3afb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/devise_recognisable/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def check_for_authentication_token
sign_in_at: Time.now,
user_agent: request.user_agent,
accept_header: request.headers["HTTP_ACCEPT"],
accept_language: request.headers["Accept-Language"].first
accept_language: request.headers["Accept-Language"]
)
redirect_to after_sign_in_path_for(resource)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/dummy-app/spec/features/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

let!(:user_agent) { 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' }
let!(:accept_header) { 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
let!(:accept_language) { 'en' }
let!(:accept_language) { "en-GB,en-US;q=0.9,en;q=0.8" }
let!(:recognisable_session_values) {{
recognisable_id: user.id,
recognisable_type: 'User',
Expand Down Expand Up @@ -327,7 +327,7 @@

context 'from a device with a different Accept-Language header value' do
let!(:recognisable_session) { FactoryBot.create :recognisable_session, recognisable_session_values }
let!(:new_accept_language) { 'fr' }
let!(:new_accept_language) { 'en,pl;q=0.9,pl-PL;q=0.8,en-GB-oxendict;q=0.7' }

before do
recognisable_session.update!(accept_header: new_accept_language)
Expand Down Expand Up @@ -355,7 +355,7 @@
context 'with multiple different RecognisableSessions' do
let!(:different_user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko)' }
let!(:different_accept_header) { 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' }
let!(:different_accept_language) { 'fr' }
let!(:different_accept_language) { 'en,pl;q=0.9,pl-PL;q=0.8,en-GB-oxendict;q=0.7' }
let!(:different_recognisable_session_values) {{
recognisable_id: user.id,
recognisable_type: 'User',
Expand Down

0 comments on commit ebc3afb

Please sign in to comment.