File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 23
23
expect ( people ( :bob ) . reload . nationality2 ) . to eql ( "DE" )
24
24
end
25
25
end
26
+
27
+ describe 'handling of locale' do
28
+ it 'it should correctly set locale cookie' do
29
+ # Check if locale cookie is not set by default
30
+ get :index , params : { locale : :fr }
31
+ expect ( response . cookies [ 'locale' ] ) . to be_nil
32
+
33
+ # Check if locale cookie is set if it is changed by user
34
+ get :index , params : { locale : :fr , set_by_user : true }
35
+ expect ( response . cookies [ 'locale' ] ) . to eql ( 'fr' )
36
+
37
+ # Cookie should not be changed if user requests page with other locale
38
+ get :index , params : { locale : :en }
39
+ expect ( response . cookies [ 'locale' ] ) . to be_nil
40
+ end
41
+ end
26
42
end
Original file line number Diff line number Diff line change 29
29
context "Set locale via dropdown" do
30
30
before ( :each ) do
31
31
visit people_path
32
- select 'Italiano' , from : "i18n_language"
33
32
end
34
33
35
34
it "Should open profile with correct language and preserve language in cookie" do
36
- # Simulate revisit without a locale in the url
35
+ select 'Italiano' , from : "i18n_language"
36
+
37
+ select_from_slim_select ( "#person_id_person" , bob . name )
38
+ expect ( page ) . to have_text ( "Dati personali" )
39
+
40
+ # Visiting page with locale explicitly defined in route should use locale from route
41
+ visit '/en/'
42
+ select_from_slim_select ( "#person_id_person" , bob . name )
43
+ expect ( page ) . to have_text ( "Personal details" )
44
+
45
+ # Simulate revisit without a locale in the url, which should use locale from cookie
37
46
visit '/'
38
47
39
48
select_from_slim_select ( "#person_id_person" , bob . name )
You can’t perform that action at this time.
0 commit comments