aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/serialization_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
commit55f9b8129a50206513264824abb44088230793c2 (patch)
treeff2f01cabfc7e74b0bd831c2272a5517e4e81e99 /activemodel/test/cases/serialization_test.rb
parentd0bdd74d7f6fae3d69b3681d5bc2d5ef6f55a0f8 (diff)
downloadrails-55f9b8129a50206513264824abb44088230793c2.tar.gz
rails-55f9b8129a50206513264824abb44088230793c2.tar.bz2
rails-55f9b8129a50206513264824abb44088230793c2.zip
Add three new rubocop rules
Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
Diffstat (limited to 'activemodel/test/cases/serialization_test.rb')
-rw-r--r--activemodel/test/cases/serialization_test.rb68
1 files changed, 34 insertions, 34 deletions
diff --git a/activemodel/test/cases/serialization_test.rb b/activemodel/test/cases/serialization_test.rb
index cead0bee22..5ee53285a3 100644
--- a/activemodel/test/cases/serialization_test.rb
+++ b/activemodel/test/cases/serialization_test.rb
@@ -51,32 +51,32 @@ class SerializationTest < ActiveModel::TestCase
end
def test_method_serializable_hash_should_work
- expected = {"name"=>"David", "gender"=>"male", "email"=>"david@example.com"}
+ expected = { "name"=>"David", "gender"=>"male", "email"=>"david@example.com" }
assert_equal expected, @user.serializable_hash
end
def test_method_serializable_hash_should_work_with_only_option
- expected = {"name"=>"David"}
+ expected = { "name"=>"David" }
assert_equal expected, @user.serializable_hash(only: [:name])
end
def test_method_serializable_hash_should_work_with_except_option
- expected = {"gender"=>"male", "email"=>"david@example.com"}
+ expected = { "gender"=>"male", "email"=>"david@example.com" }
assert_equal expected, @user.serializable_hash(except: [:name])
end
def test_method_serializable_hash_should_work_with_methods_option
- expected = {"name"=>"David", "gender"=>"male", "foo"=>"i_am_foo", "bar"=>"i_am_bar", "email"=>"david@example.com"}
+ expected = { "name"=>"David", "gender"=>"male", "foo"=>"i_am_foo", "bar"=>"i_am_bar", "email"=>"david@example.com" }
assert_equal expected, @user.serializable_hash(methods: [:foo, :bar])
end
def test_method_serializable_hash_should_work_with_only_and_methods
- expected = {"foo"=>"i_am_foo", "bar"=>"i_am_bar"}
+ expected = { "foo"=>"i_am_foo", "bar"=>"i_am_bar" }
assert_equal expected, @user.serializable_hash(only: [], methods: [:foo, :bar])
end
def test_method_serializable_hash_should_work_with_except_and_methods
- expected = {"gender"=>"male", "foo"=>"i_am_foo", "bar"=>"i_am_bar"}
+ expected = { "gender"=>"male", "foo"=>"i_am_foo", "bar"=>"i_am_bar" }
assert_equal expected, @user.serializable_hash(except: [:name, :email], methods: [:foo, :bar])
end
@@ -94,21 +94,21 @@ class SerializationTest < ActiveModel::TestCase
end
def test_include_option_with_singular_association
- expected = {"name"=>"David", "gender"=>"male", "email"=>"david@example.com",
- "address"=>{"street"=>"123 Lane", "city"=>"Springfield", "state"=>"CA", "zip"=>11111}}
+ expected = { "name"=>"David", "gender"=>"male", "email"=>"david@example.com",
+ "address"=>{ "street"=>"123 Lane", "city"=>"Springfield", "state"=>"CA", "zip"=>11111 } }
assert_equal expected, @user.serializable_hash(include: :address)
end
def test_include_option_with_plural_association
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "friends"=>[{"name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male"},
- {"name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female"}]}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "friends"=>[{ "name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male" },
+ { "name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female" }] }
assert_equal expected, @user.serializable_hash(include: :friends)
end
def test_include_option_with_empty_association
@user.friends = []
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David", "friends"=>[]}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David", "friends"=>[] }
assert_equal expected, @user.serializable_hash(include: :friends)
end
@@ -124,52 +124,52 @@ class SerializationTest < ActiveModel::TestCase
def test_include_option_with_ary
@user.friends = FriendList.new(@user.friends)
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "friends"=>[{"name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male"},
- {"name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female"}]}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "friends"=>[{ "name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male" },
+ { "name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female" }] }
assert_equal expected, @user.serializable_hash(include: :friends)
end
def test_multiple_includes
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "address"=>{"street"=>"123 Lane", "city"=>"Springfield", "state"=>"CA", "zip"=>11111},
- "friends"=>[{"name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male"},
- {"name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female"}]}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "address"=>{ "street"=>"123 Lane", "city"=>"Springfield", "state"=>"CA", "zip"=>11111 },
+ "friends"=>[{ "name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male" },
+ { "name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female" }] }
assert_equal expected, @user.serializable_hash(include: [:address, :friends])
end
def test_include_with_options
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "address"=>{"street"=>"123 Lane"}}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "address"=>{ "street"=>"123 Lane" } }
assert_equal expected, @user.serializable_hash(include: { address: { only: "street" } })
end
def test_nested_include
@user.friends.first.friends = [@user]
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "friends"=>[{"name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male",
- "friends"=> [{"email"=>"david@example.com", "gender"=>"male", "name"=>"David"}]},
- {"name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female", "friends"=> []}]}
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "friends"=>[{ "name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male",
+ "friends"=> [{ "email"=>"david@example.com", "gender"=>"male", "name"=>"David" }] },
+ { "name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female", "friends"=> [] }] }
assert_equal expected, @user.serializable_hash(include: { friends: { include: :friends } })
end
def test_only_include
- expected = {"name"=>"David", "friends" => [{"name" => "Joe"}, {"name" => "Sue"}]}
+ expected = { "name"=>"David", "friends" => [{ "name" => "Joe" }, { "name" => "Sue" }] }
assert_equal expected, @user.serializable_hash(only: :name, include: { friends: { only: :name } })
end
def test_except_include
- expected = {"name"=>"David", "email"=>"david@example.com",
- "friends"=> [{"name" => "Joe", "email" => "joe@example.com"},
- {"name" => "Sue", "email" => "sue@example.com"}]}
+ expected = { "name"=>"David", "email"=>"david@example.com",
+ "friends"=> [{ "name" => "Joe", "email" => "joe@example.com" },
+ { "name" => "Sue", "email" => "sue@example.com" }] }
assert_equal expected, @user.serializable_hash(except: :gender, include: { friends: { except: :gender } })
end
def test_multiple_includes_with_options
- expected = {"email"=>"david@example.com", "gender"=>"male", "name"=>"David",
- "address"=>{"street"=>"123 Lane"},
- "friends"=>[{"name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male"},
- {"name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female"}]}
- assert_equal expected, @user.serializable_hash(include: [{ address: {only: "street" } }, :friends])
+ expected = { "email"=>"david@example.com", "gender"=>"male", "name"=>"David",
+ "address"=>{ "street"=>"123 Lane" },
+ "friends"=>[{ "name"=>"Joe", "email"=>"joe@example.com", "gender"=>"male" },
+ { "name"=>"Sue", "email"=>"sue@example.com", "gender"=>"female" }] }
+ assert_equal expected, @user.serializable_hash(include: [{ address: { only: "street" } }, :friends])
end
end