mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
modernizes hash syntax in activemodel
This commit is contained in:
parent
301ce2a6d1
commit
fa911a74e1
4 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@ require "rake/testtask"
|
|||
|
||||
dir = File.dirname(__FILE__)
|
||||
|
||||
task :default => :test
|
||||
task default: :test
|
||||
|
||||
task :package
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class ModelWithAttributesWithSpaces
|
|||
include ActiveModel::AttributeMethods
|
||||
|
||||
def attributes
|
||||
{ :'foo bar' => "value of foo bar"}
|
||||
{ 'foo bar': "value of foo bar"}
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -67,7 +67,7 @@ class ModelWithWeirdNamesAttributes
|
|||
end
|
||||
|
||||
def attributes
|
||||
{ :'a?b' => "value of a?b" }
|
||||
{ 'a?b': "value of a?b" }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -56,7 +56,7 @@ class ActiveModelI18nTests < ActiveModel::TestCase
|
|||
def test_translated_model_attributes_with_attribute_matching_namespaced_model_name
|
||||
I18n.backend.store_translations "en", activemodel: { attributes: {
|
||||
person: { gender: "person gender"},
|
||||
:"person/gender" => { attribute: "person gender attribute" }
|
||||
"person/gender": { attribute: "person gender attribute" }
|
||||
} }
|
||||
|
||||
assert_equal "person gender", Person.human_attribute_name("gender")
|
||||
|
@ -64,12 +64,12 @@ class ActiveModelI18nTests < ActiveModel::TestCase
|
|||
end
|
||||
|
||||
def test_translated_deeply_nested_model_attributes
|
||||
I18n.backend.store_translations "en", activemodel: { attributes: { :"person/contacts/addresses" => { street: "Deeply Nested Address Street" } } }
|
||||
I18n.backend.store_translations "en", activemodel: { attributes: { "person/contacts/addresses": { street: "Deeply Nested Address Street" } } }
|
||||
assert_equal "Deeply Nested Address Street", Person.human_attribute_name("contacts.addresses.street")
|
||||
end
|
||||
|
||||
def test_translated_nested_model_attributes
|
||||
I18n.backend.store_translations "en", activemodel: { attributes: { :"person/addresses" => { street: "Person Address Street" } } }
|
||||
I18n.backend.store_translations "en", activemodel: { attributes: { "person/addresses": { street: "Person Address Street" } } }
|
||||
assert_equal "Person Address Street", Person.human_attribute_name("addresses.street")
|
||||
end
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class ValidatesTest < ActiveModel::TestCase
|
|||
end
|
||||
|
||||
def test_validates_with_namespaced_validator_class
|
||||
Person.validates :karma, :'namespace/email' => true
|
||||
Person.validates :karma, 'namespace/email': true
|
||||
person = Person.new
|
||||
person.valid?
|
||||
assert_equal ["is not an email"], person.errors[:karma]
|
||||
|
|
Loading…
Reference in a new issue