Add test to ensure errors does not popup when action_name is not defined
This commit is contained in:
parent
c7970189cf
commit
c6057b4d9c
|
@ -11,7 +11,7 @@
|
|||
|
||||
* bug fix
|
||||
* Search for validations on both association and attribute
|
||||
* Use controller.action_name to lookup actoin only when available, to fix issue with Rspec views tests (by github.com/rafaelfranca)
|
||||
* Use controller.action_name to lookup action only when available, to fix issue with Rspec views tests (by github.com/rafaelfranca)
|
||||
|
||||
== 1.2.2
|
||||
|
||||
|
|
|
@ -131,7 +131,9 @@ module SimpleForm
|
|||
|
||||
# The action to be used in lookup.
|
||||
def lookup_action
|
||||
action = template.controller.action_name.to_sym if template.controller.action_name
|
||||
return unless template.controller.action_name
|
||||
|
||||
action = template.controller.action_name.to_sym
|
||||
ACTIONS[action] || action
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,6 +58,15 @@ class LabelTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'label should not explode while looking for i18n translation when action is not set' do
|
||||
def @controller.action_name; nil; end
|
||||
|
||||
assert_nothing_raised do
|
||||
with_label_for @user, :description, :text
|
||||
end
|
||||
assert_select 'label[for=user_description]'
|
||||
end
|
||||
|
||||
test 'label should use i18n based on model and attribute to lookup translation' do
|
||||
store_translations(:en, :simple_form => { :labels => { :user => {
|
||||
:description => 'Descrição'
|
||||
|
|
Loading…
Reference in New Issue