spec/unit/middlewares/locale_spec.rb in locomotivecms_steam-1.5.0.beta2 vs spec/unit/middlewares/locale_spec.rb in locomotivecms_steam-1.5.0.beta3
- old
+ new
@@ -21,34 +21,42 @@
'rack.session' => session,
'HTTP_ACCEPT_LANGUAGE' => accept_language)
env['steam.request'] = Rack::Request.new(env)
env['steam.services'] = services
code, env = middleware.call(env)
- [env['steam.locale'], session['steam-locale']&.to_sym]
+ [env['steam.locale'], session['steam-locale']&.to_sym, env['steam.path']]
end
+ describe 'locale defined in the path' do
+
+ let(:url) { 'http://models.example.com/de/hello-de/foo' }
+
+ it { is_expected.to eq [:de, :de, '/hello-de/foo'] }
+
+ end
+
describe 'no locale defined in the path' do
describe 'first connexion' do
context 'without accept-language header' do
- it { is_expected.to eq [:de, :de] }
+ it { is_expected.to eq [:de, :de, '/'] }
end
context 'with accept-language header' do
let(:accept_language) { 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' }
- it { is_expected.to eq [:fr, :fr] }
+ it { is_expected.to eq [:fr, :fr, '/'] }
context 'with url path' do
let(:url) { 'http://models.example.com/werkzeug' }
- it { is_expected.to eq [:de, :de] }
+ it { is_expected.to eq [:de, :de, '/werkzeug'] }
end
end
@@ -56,11 +64,11 @@
context 'user with session, use it' do
let(:session) { {'steam-locale' => 'en'} }
- it { is_expected.to eq [:en, :en] }
+ it { is_expected.to eq [:en, :en, '/'] }
end
end
@@ -68,26 +76,26 @@
context 'the locale is blank' do
let(:url) { 'http://models.example.com?locale=' }
- it { is_expected.to eq [:de, :de] }
+ it { is_expected.to eq [:de, :de, '/'] }
end
context 'the locale exists' do
let(:url) { 'http://models.example.com?locale=en' }
- it { is_expected.to eq [:en, :en] }
+ it { is_expected.to eq [:en, :en, '/'] }
end
context 'the locale is unknown' do
let(:url) { 'http://models.example.com?locale=onload' }
- it { is_expected.to eq [:de, :de] }
+ it { is_expected.to eq [:de, :de, '/'] }
end
end
end