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

@@ -21,7 +21,7 @@ module ActiveModel
@comment.author = nil
@post.author = @author
@anonymous_post.author = nil
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@blog.writer = @author
@blog.articles = [@post, @anonymous_post]
@author.posts = []
@@ -32,7 +32,7 @@ module ActiveModel
end
def test_includes_post_id
expected = { data: { type: "posts", id: "42" } }
expected = { data: { type: 'posts', id: '42' } }
assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:post])
end
@@ -40,16 +40,16 @@ module ActiveModel
def test_includes_linked_post
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'post')
expected = [{
id: "42",
type: "posts",
id: '42',
type: 'posts',
attributes: {
title: 'New Post',
body: 'Body',
},
relationships: {
comments: { data: [ { type: "comments", id: "1" } ] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
comments: { data: [ { type: 'comments', id: '1' } ] },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}]
assert_equal expected, @adapter.serializable_hash[:included]
@@ -58,15 +58,15 @@ module ActiveModel
def test_limiting_linked_post_fields
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'post', fields: {post: [:title]})
expected = [{
id: "42",
type: "posts",
id: '42',
type: 'posts',
attributes: {
title: 'New Post'
},
relationships: {
comments: { data: [ { type: "comments", id: "1" } ] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
comments: { data: [ { type: 'comments', id: '1' } ] },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}]
assert_equal expected, @adapter.serializable_hash[:included]
@@ -76,7 +76,7 @@ module ActiveModel
serializer = PostSerializer.new(@anonymous_post)
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
assert_equal({comments: { data: [] }, blog: { data: { type: "blogs", id: "999" } }, author: { data: nil }}, adapter.serializable_hash[:data][:relationships])
assert_equal({comments: { data: [] }, blog: { data: { type: 'blogs', id: '999' } }, author: { data: nil }}, adapter.serializable_hash[:data][:relationships])
end
def test_include_type_for_association_when_different_than_name
@@ -86,19 +86,19 @@ module ActiveModel
expected = {
writer: {
data: {
type: "authors",
id: "1"
type: 'authors',
id: '1'
}
},
articles: {
data: [
{
type: "posts",
id: "42"
type: 'posts',
id: '42'
},
{
type: "posts",
id: "43"
type: 'posts',
id: '43'
}
]
}
@@ -112,10 +112,10 @@ module ActiveModel
linked = adapter.serializable_hash[:included]
expected = [
{
id: "1",
type: "authors",
id: '1',
type: 'authors',
attributes: {
name: "Steve K."
name: 'Steve K.'
},
relationships: {
posts: { data: [] },
@@ -123,27 +123,27 @@ module ActiveModel
bio: { data: nil }
}
},{
id: "42",
type: "posts",
id: '42',
type: 'posts',
attributes: {
title: "New Post",
body: "Body"
title: 'New Post',
body: 'Body'
},
relationships: {
comments: { data: [ { type: "comments", id: "1" } ] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
comments: { data: [ { type: 'comments', id: '1' } ] },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}, {
id: "43",
type: "posts",
id: '43',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: nil }
}
}

View File

@@ -27,29 +27,29 @@ module ActiveModel
def test_include_multiple_posts
expected = [
{
id: "1",
type: "posts",
id: '1',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
},
{
id: "2",
type: "posts",
id: '2',
type: 'posts',
attributes: {
title: "New Post",
body: "Body"
title: 'New Post',
body: 'Body'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}
]
@@ -62,27 +62,27 @@ module ActiveModel
expected = [
{
id: "1",
type: "posts",
id: '1',
type: 'posts',
attributes: {
title: "Hello!!"
title: 'Hello!!'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
},
{
id: "2",
type: "posts",
id: '2',
type: 'posts',
attributes: {
title: "New Post"
title: 'New Post'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}
]

View File

@@ -27,8 +27,8 @@ module ActiveModel
def test_includes_comment_ids
expected = {
data: [
{ type: "posts", id: "1"},
{ type: "posts", id: "2"}
{ type: 'posts', id: '1'},
{ type: 'posts', id: '2'}
]
}

View File

@@ -58,9 +58,9 @@ module ActiveModel
},
{
id: @author.id.to_s,
type: "authors",
type: 'authors',
relationships: {
posts: { data: [ {type: "posts", id: @post.id.to_s } ] }
posts: { data: [ {type: 'posts', id: @post.id.to_s } ] }
}
}
]
@@ -70,7 +70,7 @@ module ActiveModel
def test_includes_author_id
expected = {
data: { type: "authors", id: @author.id.to_s }
data: { type: 'authors', id: @author.id.to_s }
}
assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:author])

View File

@@ -22,12 +22,12 @@ module ActiveModel
@second_comment.post = @post
@post.author = @author
@post_without_comments.author = nil
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@blog.writer = @author
@blog.articles = [@post]
@post.blog = @blog
@post_without_comments.blog = nil
@tag = Tag.new(id: 1, name: "#hash_tag")
@tag = Tag.new(id: 1, name: '#hash_tag')
@post.tags = [@tag]
@serializer = PostSerializer.new(@post)
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
@@ -36,7 +36,7 @@ module ActiveModel
end
def test_includes_comment_ids
expected = { data: [ { type: "comments", id: "1" }, { type: "comments", id: "2" } ] }
expected = { data: [ { type: 'comments', id: '1' }, { type: 'comments', id: '2' } ] }
assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:comments])
end
@@ -44,23 +44,23 @@ module ActiveModel
def test_includes_linked_comments
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments')
expected = [{
id: "1",
type: "comments",
id: '1',
type: 'comments',
attributes: {
body: 'ZOMG A COMMENT'
},
relationships: {
post: { data: { type: "posts", id: "1" } },
post: { data: { type: 'posts', id: '1' } },
author: { data: nil }
}
}, {
id: "2",
type: "comments",
id: '2',
type: 'comments',
attributes: {
body: 'ZOMG ANOTHER COMMENT'
},
relationships: {
post: { data: { type: "posts", id: "1" } },
post: { data: { type: 'posts', id: '1' } },
author: { data: nil }
}
}]
@@ -70,17 +70,17 @@ module ActiveModel
def test_limit_fields_of_linked_comments
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments', fields: {comment: [:id]})
expected = [{
id: "1",
type: "comments",
id: '1',
type: 'comments',
relationships: {
post: { data: { type: "posts", id: "1" } },
post: { data: { type: 'posts', id: '1' } },
author: { data: nil }
}
}, {
id: "2",
type: "comments",
id: '2',
type: 'comments',
relationships: {
post: { data: { type: "posts", id: "1" } },
post: { data: { type: 'posts', id: '1' } },
author: { data: nil }
}
}]
@@ -101,8 +101,8 @@ module ActiveModel
expected = {
data: [{
type: "posts",
id: "1"
type: 'posts',
id: '1'
}]
}
assert_equal expected, actual
@@ -114,8 +114,8 @@ module ActiveModel
assert_equal({
data: {
id: "1",
type: "posts",
id: '1',
type: 'posts',
relationships: {
tags: { data: [@tag.as_json]}
}
@@ -129,8 +129,8 @@ module ActiveModel
assert_equal({
data: {
id: "1",
type: "virtual_values",
id: '1',
type: 'virtual_values',
relationships: {
maker: {data: {id: 1}},
reviews: {data: [{id: 1}, {id: 2}]}

View File

@@ -19,7 +19,7 @@ module ActiveModel
@comment.author = nil
@post.author = @author
@anonymous_post.author = nil
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@blog.writer = @author
@blog.articles = [@post, @anonymous_post]
@author.posts = []
@@ -32,7 +32,7 @@ module ActiveModel
end
def test_includes_bio_id
expected = { data: { type: "bios", id: "43" } }
expected = { data: { type: 'bios', id: '43' } }
assert_equal(expected, @adapter.serializable_hash[:data][:relationships][:bio])
end
@@ -42,14 +42,14 @@ module ActiveModel
expected = [
{
id: "43",
type: "bios",
id: '43',
type: 'bios',
attributes: {
content:"AMS Contributor",
content:'AMS Contributor',
rating: nil
},
relationships: {
author: { data: { type: "authors", id: "1" } }
author: { data: { type: 'authors', id: '1' } }
}
}
]
@@ -63,8 +63,8 @@ module ActiveModel
expected = {
data: {
id: "1",
type: "virtual_values",
id: '1',
type: 'virtual_values',
relationships: {
maker: {data: {id: 1}},
reviews: {data: [{id: 1}, {id: 2}]}

View File

@@ -14,7 +14,7 @@ module ActiveModel
@first_comment.post = @post
@second_comment.post = @post
@post.author = @author
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@post.blog = @blog
end
@@ -25,11 +25,11 @@ module ActiveModel
assert_equal({
reviews: { data: [
{type: "comments", id: "1"},
{type: "comments", id: "2"}
{type: 'comments', id: '1'},
{type: 'comments', id: '2'}
]},
writer: { data: {type: "authors", id: "1"} },
site: { data: {type: "blogs", id: "1" } }
writer: { data: {type: 'authors', id: '1'} },
site: { data: {type: 'blogs', id: '1' } }
}, adapter.serializable_hash[:data][:relationships])
end
end

View File

@@ -53,94 +53,94 @@ module ActiveModel
expected = {
data: [
{
id: "10",
type: "posts",
id: '10',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: { data: [ { type: "comments", id: '1' }, { type: "comments", id: '2' } ] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
comments: { data: [ { type: 'comments', id: '1' }, { type: 'comments', id: '2' } ] },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
},
{
id: "20",
type: "posts",
id: '20',
type: 'posts',
attributes: {
title: "New Post",
body: "Body"
title: 'New Post',
body: 'Body'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "2" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '2' } }
}
}
],
included: [
{
id: "1",
type: "comments",
id: '1',
type: 'comments',
attributes: {
body: "ZOMG A COMMENT"
body: 'ZOMG A COMMENT'
},
relationships: {
post: { data: { type: "posts", id: "10" } },
post: { data: { type: 'posts', id: '10' } },
author: { data: nil }
}
}, {
id: "2",
type: "comments",
id: '2',
type: 'comments',
attributes: {
body: "ZOMG ANOTHER COMMENT",
body: 'ZOMG ANOTHER COMMENT',
},
relationships: {
post: { data: { type: "posts", id: "10" } },
post: { data: { type: 'posts', id: '10' } },
author: { data: nil }
}
}, {
id: "1",
type: "authors",
id: '1',
type: 'authors',
attributes: {
name: "Steve K."
name: 'Steve K.'
},
relationships: {
posts: { data: [ { type: "posts", id: "10" }, { type: "posts", id: "30" } ] },
posts: { data: [ { type: 'posts', id: '10' }, { type: 'posts', id: '30' } ] },
roles: { data: [] },
bio: { data: { type: "bios", id: "1" } }
bio: { data: { type: 'bios', id: '1' } }
}
}, {
id: "1",
type: "bios",
id: '1',
type: 'bios',
attributes: {
content: "AMS Contributor",
content: 'AMS Contributor',
rating: nil
},
relationships: {
author: { data: { type: "authors", id: "1" } }
author: { data: { type: 'authors', id: '1' } }
}
}, {
id: "2",
type: "authors",
id: '2',
type: 'authors',
attributes: {
name: "Tenderlove"
name: 'Tenderlove'
},
relationships: {
posts: { data: [ { type: "posts", id:"20" } ] },
posts: { data: [ { type: 'posts', id:'20' } ] },
roles: { data: [] },
bio: { data: { type: "bios", id: "2" } }
bio: { data: { type: 'bios', id: '2' } }
}
}, {
id: "2",
type: "bios",
id: '2',
type: 'bios',
attributes: {
rating: nil,
content: "Rails Contributor",
content: 'Rails Contributor',
},
relationships: {
author: { data: { type: "authors", id: "2" } }
author: { data: { type: 'authors', id: '2' } }
}
}
]
@@ -162,39 +162,39 @@ module ActiveModel
expected = [
{
id: "1",
type: "authors",
id: '1',
type: 'authors',
attributes: {
name: "Steve K."
name: 'Steve K.'
},
relationships: {
posts: { data: [ { type: "posts", id: "10"}, { type: "posts", id: "30" }] },
posts: { data: [ { type: 'posts', id: '10'}, { type: 'posts', id: '30' }] },
roles: { data: [] },
bio: { data: { type: "bios", id: "1" }}
bio: { data: { type: 'bios', id: '1' }}
}
}, {
id: "10",
type: "posts",
id: '10',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: { data: [ { type: "comments", id: "1"}, { type: "comments", id: "2" }] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
comments: { data: [ { type: 'comments', id: '1'}, { type: 'comments', id: '2' }] },
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}, {
id: "30",
type: "posts",
id: '30',
type: 'posts',
attributes: {
title: "Yet Another Post",
body: "Body"
title: 'Yet Another Post',
body: 'Body'
},
relationships: {
comments: { data: [] },
blog: { data: { type: "blogs", id: "999" } },
author: { data: { type: "authors", id: "1" } }
blog: { data: { type: 'blogs', id: '999' } },
author: { data: { type: 'authors', id: '1' } }
}
}
]
@@ -229,21 +229,21 @@ module ActiveModel
expected = [
{
id: "10",
type: "posts",
id: '10',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: {
data: [{type: "comments", id: "1"}, {type: "comments", id: "2"}]
data: [{type: 'comments', id: '1'}, {type: 'comments', id: '2'}]
},
blog: {
data: {type: "blogs", id: "999"}
data: {type: 'blogs', id: '999'}
},
author: {
data: {type: "authors", id: "1"}
data: {type: 'authors', id: '1'}
}
}
}
@@ -262,14 +262,14 @@ module ActiveModel
expected = {
data: {
id: "10",
type: "posts",
id: '10',
type: 'posts',
attributes: {
title: "Hello!!",
body: "Hello, world!!"
title: 'Hello!!',
body: 'Hello, world!!'
},
relationships: {
comments: { data: [ { type: "comments", id: '1' }, { type: "comments", id: '2' } ] },
comments: { data: [ { type: 'comments', id: '1' }, { type: 'comments', id: '2' } ] },
author: { data: nil }
}
}

View File

@@ -43,9 +43,9 @@ module ActiveModel
def data
{ data:[
{ id:"1", type:"profiles", attributes:{name:"Name 1", description:"Description 1" } },
{ id:"2", type:"profiles", attributes:{name:"Name 2", description:"Description 2" } },
{ id:"3", type:"profiles", attributes:{name:"Name 3", description:"Description 3" } }
{ id:'1', type:'profiles', attributes:{name:'Name 1', description:'Description 1' } },
{ id:'2', type:'profiles', attributes:{name:'Name 2', description:'Description 2' } },
{ id:'3', type:'profiles', attributes:{name:'Name 3', description:'Description 3' } }
]
}
end

View File

@@ -21,7 +21,7 @@ module ActiveModel
@comment.author = nil
@post.author = @author
@anonymous_post.author = nil
@blog = Blog.new(id: 1, name: "My Blog!!")
@blog = Blog.new(id: 1, name: 'My Blog!!')
@blog.writer = @author
@blog.articles = [@post, @anonymous_post]
@author.posts = []