diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/enum_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/hot_compatibility_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/inheritance_test.rb | 11 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 9 |
4 files changed, 25 insertions, 1 deletions
diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index c09e58fbf1..0075df8b8d 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -88,4 +88,8 @@ class EnumTest < ActiveRecord::TestCase assert Book.written.create.written? assert Book.read.create.read? end + + test "_before_type_cast returns the enum label (required for form fields)" do + assert_equal "proposed", @book.status_before_type_cast + end end diff --git a/activerecord/test/cases/hot_compatibility_test.rb b/activerecord/test/cases/hot_compatibility_test.rb index e671979bcf..367d04a154 100644 --- a/activerecord/test/cases/hot_compatibility_test.rb +++ b/activerecord/test/cases/hot_compatibility_test.rb @@ -5,7 +5,7 @@ class HotCompatibilityTest < ActiveRecord::TestCase setup do @klass = Class.new(ActiveRecord::Base) do - connection.create_table :hot_compatibilities, :force => true do |t| + connection.create_table :hot_compatibilities, force: true do |t| t.string :foo t.string :bar end diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index cb0d374ef7..7fd7d42354 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -128,6 +128,17 @@ class InheritanceTest < ActiveRecord::TestCase assert_kind_of Cabbage, cabbage end + def test_alt_becomes_bang_resets_inheritance_type_column + vegetable = Vegetable.create!(name: "Red Pepper") + assert_nil vegetable.custom_type + + cabbage = vegetable.becomes!(Cabbage) + assert_equal "Cabbage", cabbage.custom_type + + vegetable = cabbage.becomes!(Vegetable) + assert_nil cabbage.custom_type + end + def test_inheritance_find_all companies = Company.all.merge!(:order => 'id').to_a assert_kind_of Firm, companies[0], "37signals should be a firm" diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 031da8e6d6..a0896f7f8d 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1524,6 +1524,15 @@ class RelationTest < ActiveRecord::TestCase assert merged.to_sql.include?("bbq") end + def test_unscope_removes_binds + left = Post.where(id: Arel::Nodes::BindParam.new('?')) + column = Post.columns_hash['id'] + left.bind_values += [[column, 20]] + + relation = left.unscope(where: :id) + assert_equal [], relation.bind_values + end + def test_merging_removes_rhs_bind_parameters left = Post.where(id: Arel::Nodes::BindParam.new('?')) column = Post.columns_hash['id'] |