test/serializers/cache_test.rb in cheap_ams-0.10.5 vs test/serializers/cache_test.rb in cheap_ams-0.10.6
- old
+ new
@@ -7,11 +7,11 @@
ActionController::Base.cache_store.clear
@comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
@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')
@author.posts = [@post]
@author.roles = [@role]
@@ -56,13 +56,13 @@
render_object_with_cache(@comment)
assert_equal(@comment_serializer.attributes.to_json, ActionController::Base.cache_store.fetch(@comment.cache_key).to_json)
end
def test_cache_options_definition
- assert_equal({expires_in: 0.1, skip_digest: true}, @post_serializer.class._cache_options)
+ assert_equal({ expires_in: 0.1, skip_digest: true }, @post_serializer.class._cache_options)
assert_equal(nil, @blog_serializer.class._cache_options)
- assert_equal({expires_in: 1.day, skip_digest: true}, @comment_serializer.class._cache_options)
+ assert_equal({ expires_in: 1.day, skip_digest: true }, @comment_serializer.class._cache_options)
end
def test_fragment_cache_definition
assert_equal([:name], @role_serializer.class._cache_only)
assert_equal([:content], @bio_serializer.class._cache_except)
@@ -116,11 +116,11 @@
}
hash = render_object_with_cache(@location)
assert_equal(hash, expected_result)
- assert_equal({place: 'Nowhere'}, ActionController::Base.cache_store.fetch(@location.cache_key))
+ assert_equal({ place: 'Nowhere' }, ActionController::Base.cache_store.fetch(@location.cache_key))
end
def test_uses_file_digest_in_cache_key
render_object_with_cache(@blog)
assert_equal(@blog_serializer.attributes, ActionController::Base.cache_store.fetch(@blog.cache_key_with_digest))
@@ -129,33 +129,34 @@
def test_cache_digest_definition
assert_equal(::Model::FILE_DIGEST, @post_serializer.class._cache_digest)
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)>'"
file.close
assert_equal ActiveModel::Serializer.digest_caller_file(caller_line), Digest::MD5.hexdigest(contents)
ensure
file.unlink
end
private
+
def render_object_with_cache(obj)
ActiveModel::SerializableResource.new(obj).serializable_hash
end
end
end