-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix setting of locale via routes
mount ... defaults: { locale: :en }
(
#923)
- Loading branch information
1 parent
3794dbf
commit ec385cf
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/app/controllers/good_job/application_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
RSpec.describe GoodJob::ApplicationController, type: :controller do | ||
render_views # seems required for Rails HEAD | ||
|
||
controller do | ||
def index | ||
render plain: "OK" | ||
end | ||
end | ||
|
||
describe "#current_locale" do | ||
it "defers to GET queries of params (to allow setting `mount...defaults: { locale: X })`" do | ||
allow(controller.params).to receive(:[]).with(:locale).and_return(:en) | ||
allow(controller.request.GET).to receive(:[]).with('locale').and_return(:de) | ||
|
||
expect(controller.send(:current_locale)).to eq(:de) | ||
end | ||
end | ||
end |