forked from heartcombo/devise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for translation scope being preserved when inheriting a con…
…troller issue heartcombo#3367
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
test/controllers/inherited_controller_i18n_messages_test.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,51 @@ | ||
require 'test_helper' | ||
|
||
class SessionsInheritedController < Devise::SessionsController | ||
def test_i18n_scope | ||
set_flash_message(:notice, :signed_in) | ||
end | ||
end | ||
|
||
class AnotherInheritedController < SessionsInheritedController | ||
protected | ||
|
||
def translation_scope | ||
'another' | ||
end | ||
end | ||
|
||
class InheritedControllerTest < ActionController::TestCase | ||
tests SessionsInheritedController | ||
|
||
def setup | ||
@mock_warden = OpenStruct.new | ||
@controller.request.env['warden'] = @mock_warden | ||
@controller.request.env['devise.mapping'] = Devise.mappings[:user] | ||
end | ||
|
||
test 'I18n scope is inherited from Devise::Sessions' do | ||
I18n.expects(:t).with do |message, options| | ||
message == 'user.signed_in' && | ||
options[:scope] == 'devise.sessions' | ||
end | ||
@controller.test_i18n_scope | ||
end | ||
end | ||
|
||
class AnotherInheritedControllerTest < ActionController::TestCase | ||
tests AnotherInheritedController | ||
|
||
def setup | ||
@mock_warden = OpenStruct.new | ||
@controller.request.env['warden'] = @mock_warden | ||
@controller.request.env['devise.mapping'] = Devise.mappings[:user] | ||
end | ||
|
||
test 'I18n scope is overridden' do | ||
I18n.expects(:t).with do |message, options| | ||
message == 'user.signed_in' && | ||
options[:scope] == 'another' | ||
end | ||
@controller.test_i18n_scope | ||
end | ||
end |