File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ def call
22
22
protected
23
23
24
24
def extract_locale
25
- segments = params[:path].split('/')
25
+ path = params[:path] || 'index'
26
+ segments = path.split('/')
26
27
27
- return [default_locale, params[: path] ] unless locales.include?(segments[0]&.to_sym)
28
+ return [default_locale, path] unless locales.include?(segments[0]&.to_sym)
28
29
29
30
[segments.shift, segments.empty? ? 'index' : segments.join('/')]
30
31
end
Original file line number Diff line number Diff line change 9
9
let(:params) { { path: 'index' } }
10
10
let(:locales) { %i[en fr] }
11
11
12
+ context 'the path is nil' do
13
+ let(:params) { { path: nil } }
14
+
15
+ it 'uses the default locale' do
16
+ expect(Maglev::I18n).to receive(:'current_locale=').with(:en)
17
+ subject
18
+ end
19
+
20
+ it "sets the path to 'index'" do
21
+ subject
22
+ expect(params[:path]).to eq 'index'
23
+ end
24
+ end
25
+
12
26
context "the path doesn't contain a locale" do
13
27
it 'uses the default locale' do
14
28
expect(Maglev::I18n).to receive(:'current_locale=').with(:en)
You can’t perform that action at this time.
0 commit comments