From 9617db2078e8a85c8944392c21dd748f932bbd80 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 18:26:20 +0200 Subject: applies new string literal convention in activerecord/test The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default. --- .../test/cases/attribute_decorators_test.rb | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'activerecord/test/cases/attribute_decorators_test.rb') diff --git a/activerecord/test/cases/attribute_decorators_test.rb b/activerecord/test/cases/attribute_decorators_test.rb index 2aeb2601c2..cfa6ed1da6 100644 --- a/activerecord/test/cases/attribute_decorators_test.rb +++ b/activerecord/test/cases/attribute_decorators_test.rb @@ -1,9 +1,9 @@ -require 'cases/helper' +require "cases/helper" module ActiveRecord class AttributeDecoratorsTest < ActiveRecord::TestCase class Model < ActiveRecord::Base - self.table_name = 'attribute_decorators_model' + self.table_name = "attribute_decorators_model" end class StringDecorator < SimpleDelegator @@ -28,19 +28,19 @@ module ActiveRecord teardown do return unless @connection - @connection.drop_table 'attribute_decorators_model', if_exists: true + @connection.drop_table "attribute_decorators_model", if_exists: true Model.attribute_type_decorations.clear Model.reset_column_information end test "attributes can be decorated" do - model = Model.new(a_string: 'Hello') - assert_equal 'Hello', model.a_string + model = Model.new(a_string: "Hello") + assert_equal "Hello", model.a_string Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } - model = Model.new(a_string: 'Hello') - assert_equal 'Hello decorated!', model.a_string + model = Model.new(a_string: "Hello") + assert_equal "Hello decorated!", model.a_string end test "decoration does not eagerly load existing columns" do @@ -51,54 +51,54 @@ module ActiveRecord end test "undecorated columns are not touched" do - Model.attribute :another_string, :string, default: 'something or other' + Model.attribute :another_string, :string, default: "something or other" Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } - assert_equal 'something or other', Model.new.another_string + assert_equal "something or other", Model.new.another_string end test "decorators can be chained" do Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } Model.decorate_attribute_type(:a_string, :other) { |t| StringDecorator.new(t) } - model = Model.new(a_string: 'Hello!') + model = Model.new(a_string: "Hello!") - assert_equal 'Hello! decorated! decorated!', model.a_string + assert_equal "Hello! decorated! decorated!", model.a_string end test "decoration of the same type multiple times is idempotent" do Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } - model = Model.new(a_string: 'Hello') - assert_equal 'Hello decorated!', model.a_string + model = Model.new(a_string: "Hello") + assert_equal "Hello decorated!", model.a_string end test "decorations occur in order of declaration" do Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } Model.decorate_attribute_type(:a_string, :other) do |type| - StringDecorator.new(type, 'decorated again!') + StringDecorator.new(type, "decorated again!") end - model = Model.new(a_string: 'Hello!') + model = Model.new(a_string: "Hello!") - assert_equal 'Hello! decorated! decorated again!', model.a_string + assert_equal "Hello! decorated! decorated again!", model.a_string end test "decorating attributes does not modify parent classes" do - Model.attribute :another_string, :string, default: 'whatever' + Model.attribute :another_string, :string, default: "whatever" Model.decorate_attribute_type(:a_string, :test) { |t| StringDecorator.new(t) } child_class = Class.new(Model) child_class.decorate_attribute_type(:another_string, :test) { |t| StringDecorator.new(t) } child_class.decorate_attribute_type(:a_string, :other) { |t| StringDecorator.new(t) } - model = Model.new(a_string: 'Hello!') - child = child_class.new(a_string: 'Hello!') + model = Model.new(a_string: "Hello!") + child = child_class.new(a_string: "Hello!") - assert_equal 'Hello! decorated!', model.a_string - assert_equal 'whatever', model.another_string - assert_equal 'Hello! decorated! decorated!', child.a_string - assert_equal 'whatever decorated!', child.another_string + assert_equal "Hello! decorated!", model.a_string + assert_equal "whatever", model.another_string + assert_equal "Hello! decorated! decorated!", child.a_string + assert_equal "whatever decorated!", child.another_string end class Multiplier < SimpleDelegator @@ -116,9 +116,9 @@ module ActiveRecord Multiplier.new(type) end - model = Model.new(a_string: 'whatever', an_int: 1) + model = Model.new(a_string: "whatever", an_int: 1) - assert_equal 'whatever', model.a_string + assert_equal "whatever", model.a_string assert_equal 2, model.an_int end end -- cgit v1.2.3