Style/StringLiterals single quote all the things

This commit is contained in:
Benjamin Fleischer
2015-08-30 23:20:25 -05:00
parent 09c97de90d
commit bdfe13c527
36 changed files with 347 additions and 347 deletions

View File

@@ -14,7 +14,7 @@ module ActiveModel
@comment.post = @post
@comment.author = nil
@anonymous_post.author = nil
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@post.blog = @blog
@anonymous_post.blog = nil
@@ -31,14 +31,14 @@ module ActiveModel
serializer = PostSerializer.new(@anonymous_post)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
assert_equal({post: {title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], blog: {id: 999, name: "Custom blog"}, author: nil}}, adapter.serializable_hash)
assert_equal({post: {title: 'Hello!!', body: 'Hello, world!!', id: 43, comments: [], blog: {id: 999, name: 'Custom blog'}, author: nil}}, adapter.serializable_hash)
end
def test_include_nil_author_with_specified_serializer
serializer = PostPreviewSerializer.new(@anonymous_post)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
assert_equal({post: {title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], author: nil}}, adapter.serializable_hash)
assert_equal({post: {title: 'Hello!!', body: 'Hello, world!!', id: 43, comments: [], author: nil}}, adapter.serializable_hash)
end
end
end

View File

@@ -13,7 +13,7 @@ module ActiveModel
@second_post.comments = []
@first_post.author = @author
@second_post.author = @author
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@first_post.blog = @blog
@second_post.blog = nil
@@ -21,15 +21,15 @@ module ActiveModel
end
def test_with_serializer_option
@blog.special_attribute = "Special"
@blog.special_attribute = 'Special'
@blog.articles = [@first_post, @second_post]
serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = {blogs:[{
id: 1,
special_attribute: "Special",
articles: [{id: 1,title: "Hello!!", body: "Hello, world!!"}, {id: 2, title: "New Post", body: "Body"}]
special_attribute: 'Special',
articles: [{id: 1,title: 'Hello!!', body: 'Hello, world!!'}, {id: 2, title: 'New Post', body: 'Body'}]
}]}
assert_equal expected, adapter.serializable_hash
end
@@ -39,30 +39,30 @@ module ActiveModel
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = { posts: [{
title: "Hello!!",
body: "Hello, world!!",
title: 'Hello!!',
body: 'Hello, world!!',
id: 1,
comments: [],
author: {
id: 1,
name: "Steve K."
name: 'Steve K.'
},
blog: {
id: 999,
name: "Custom blog"
name: 'Custom blog'
}
}, {
title: "New Post",
body: "Body",
title: 'New Post',
body: 'Body',
id: 2,
comments: [],
author: {
id: 1,
name: "Steve K."
name: 'Steve K.'
},
blog: {
id: 999,
name: "Custom blog"
name: 'Custom blog'
}
}]}
assert_equal expected, adapter.serializable_hash

View File

@@ -15,9 +15,9 @@ module ActiveModel
@post.author = @author
@first_comment.post = @post
@second_comment.post = @post
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@post.blog = @blog
@tag = Tag.new(id: 1, name: "#hash_tag")
@tag = Tag.new(id: 1, name: '#hash_tag')
@post.tags = [@tag]
end
@@ -36,7 +36,7 @@ module ActiveModel
assert_equal({
id: 42,
tags: [
{"attributes"=>{"id"=>1, "name"=>"#hash_tag"}}
{'attributes'=>{'id'=>1, 'name'=>'#hash_tag'}}
]
}.to_json, adapter.serializable_hash[:post].to_json)
end