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

@@ -74,7 +74,7 @@ module ActiveModel
assert_equal key, :tags
assert_equal serializer, nil
assert_equal [{ attributes: { name: "#hashtagged" }}].to_json, options[:virtual_value].to_json
assert_equal [{ attributes: { name: '#hashtagged' }}].to_json, options[:virtual_value].to_json
end
end

View File

@@ -4,7 +4,7 @@ module ActiveModel
class Serializer
class AttributeTest < Minitest::Test
def setup
@blog = Blog.new({ id: 1, name: 'AMS Hints', type: "stuff" })
@blog = Blog.new({ id: 1, name: 'AMS Hints', type: 'stuff' })
@blog_serializer = AlternateBlogSerializer.new(@blog)
end
@@ -15,14 +15,14 @@ module ActiveModel
def test_json_serializable_hash
adapter = ActiveModel::Serializer::Adapter::Json.new(@blog_serializer)
assert_equal({blog: { id:1, title:"AMS Hints"}}, adapter.serializable_hash)
assert_equal({blog: { id:1, title:'AMS Hints'}}, adapter.serializable_hash)
end
def test_attribute_inheritance_with_key
inherited_klass = Class.new(AlternateBlogSerializer)
blog_serializer = inherited_klass.new(@blog)
adapter = ActiveModel::Serializer::Adapter::FlattenJson.new(blog_serializer)
assert_equal({:id=>1, :title=>"AMS Hints"}, adapter.serializable_hash)
assert_equal({:id=>1, :title=>'AMS Hints'}, adapter.serializable_hash)
end
def test_multiple_calls_with_the_same_attribute
@@ -40,7 +40,7 @@ module ActiveModel
end
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer.new(@blog))
assert_equal({ blog: { id: "AMS Hints" } }, adapter.serializable_hash)
assert_equal({ blog: { id: 'AMS Hints' } }, adapter.serializable_hash)
end
def test_type_attribute
@@ -55,7 +55,7 @@ module ActiveModel
assert_equal({ blog: { type: 1} }, adapter.serializable_hash)
adapter = ActiveModel::Serializer::Adapter::Json.new(attributes_serializer.new(@blog))
assert_equal({ blog: { type: "stuff" } }, adapter.serializable_hash)
assert_equal({ blog: { type: 'stuff' } }, adapter.serializable_hash)
end
end
end

View File

@@ -6,7 +6,7 @@ module ActiveModel
def setup
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@profile_serializer = ProfileSerializer.new(@profile)
@comment = Comment.new(id: 1, body: "ZOMG!!", date: "2015")
@comment = Comment.new(id: 1, body: 'ZOMG!!', date: '2015')
@serializer_klass = Class.new(CommentSerializer)
@serializer_klass_with_new_attributes = Class.new(CommentSerializer) do
attributes :date, :likes
@@ -35,7 +35,7 @@ module ActiveModel
def test_attributes_inheritance
serializer = @serializer_klass.new(@comment)
assert_equal({id: 1, body: "ZOMG!!"},
assert_equal({id: 1, body: 'ZOMG!!'},
serializer.attributes)
end
@@ -46,7 +46,7 @@ module ActiveModel
def test_attribute_inheritance_with_new_attribute
serializer = @serializer_klass_with_new_attributes.new(@comment)
assert_equal({id: 1, body: "ZOMG!!", date: "2015", likes: nil},
assert_equal({id: 1, body: 'ZOMG!!', date: '2015', likes: nil},
serializer.attributes)
end

View File

@@ -9,7 +9,7 @@ module ActiveModel
@post = Post.new(title: 'New Post', body: 'Body')
@bio = Bio.new(id: 1, content: 'AMS Contributor')
@author = Author.new(name: 'Joao M. D. Moura')
@blog = Blog.new(id: 999, name: "Custom blog", writer: @author, articles: [])
@blog = Blog.new(id: 999, name: 'Custom blog', writer: @author, articles: [])
@role = Role.new(name: 'Great Author')
@location = Location.new(lat: '-23.550520', lng: '-46.633309')
@place = Place.new(name: 'Amazing Place')
@@ -131,20 +131,20 @@ module ActiveModel
end
def test_serializer_file_path_on_nix
path = "/Users/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb"
path = '/Users/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb'
caller_line = "#{path}:1:in `<top (required)>'"
assert_equal caller_line[ActiveModel::Serializer::CALLER_FILE], path
end
def test_serializer_file_path_on_windows
path = "c:/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb"
path = 'c:/git/emberjs/ember-crm-backend/app/serializers/lead_serializer.rb'
caller_line = "#{path}:1:in `<top (required)>'"
assert_equal caller_line[ActiveModel::Serializer::CALLER_FILE], path
end
def test_digest_caller_file
contents = "puts 'AMS rocks'!"
file = Tempfile.new("some_ruby.rb")
file = Tempfile.new('some_ruby.rb')
file.write(contents)
path = file.path
caller_line = "#{path}:1:in `<top (required)>'"

View File

@@ -7,8 +7,8 @@ module ActiveModel
ActionController::Base.cache_store.clear
@blog = Blog.new(id: 1,
name: 'AMS Hints',
writer: Author.new(id: 2, name: "Steve"),
articles: [Post.new(id: 3, title: "AMS")])
writer: Author.new(id: 2, name: 'Steve'),
articles: [Post.new(id: 3, title: 'AMS')])
end
def test_meta_is_present_with_root
@@ -17,9 +17,9 @@ module ActiveModel
expected = {
blog: {
id: 1,
title: "AMS Hints"
title: 'AMS Hints'
},
"meta" => {
'meta' => {
total: 10
}
}
@@ -31,20 +31,20 @@ module ActiveModel
adapter = load_adapter(meta: {total: 10})
expected = {
id: 1,
title: "AMS Hints"
title: 'AMS Hints'
}
assert_equal expected, adapter.as_json
end
def test_meta_key_is_used
serializer = AlternateBlogSerializer.new(@blog, meta: {total: 10}, meta_key: "haha_meta")
serializer = AlternateBlogSerializer.new(@blog, meta: {total: 10}, meta_key: 'haha_meta')
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = {
blog: {
id: 1,
title: "AMS Hints"
title: 'AMS Hints'
},
"haha_meta" => {
'haha_meta' => {
total: 10
}
}
@@ -52,15 +52,15 @@ module ActiveModel
end
def test_meta_key_is_used_with_json_api
serializer = AlternateBlogSerializer.new(@blog, meta: {total: 10}, meta_key: "haha_meta")
serializer = AlternateBlogSerializer.new(@blog, meta: {total: 10}, meta_key: 'haha_meta')
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
expected = {
data: {
id: "1",
type: "blogs",
attributes: { title: "AMS Hints" }
id: '1',
type: 'blogs',
attributes: { title: 'AMS Hints' }
},
"haha_meta" => { total: 10 }
'haha_meta' => { total: 10 }
}
assert_equal expected, adapter.as_json
end
@@ -71,14 +71,14 @@ module ActiveModel
adapter = ActiveModel::Serializer::Adapter::FlattenJson.new(serializer)
expected = [{
id: 1,
name: "AMS Hints",
name: 'AMS Hints',
writer: {
id: 2,
name: "Steve"
name: 'Steve'
},
articles: [{
id: 3,
title: "AMS",
title: 'AMS',
body: nil
}]
}]
@@ -86,20 +86,20 @@ module ActiveModel
end
def test_meta_is_present_on_arrays_with_root
serializer = ArraySerializer.new([@blog], meta: {total: 10}, meta_key: "haha_meta")
serializer = ArraySerializer.new([@blog], meta: {total: 10}, meta_key: 'haha_meta')
# JSON adapter adds root by default
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = {
blogs: [{
id: 1,
name: "AMS Hints",
name: 'AMS Hints',
writer: {
id: 2,
name: "Steve"
name: 'Steve'
},
articles: [{
id: 3,
title: "AMS",
title: 'AMS',
body: nil
}]
}],