diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-30 14:47:55 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-30 14:47:55 -0800 |
commit | 795dc3d15fee02c9ccc9da08c8fcee0830a4962a (patch) | |
tree | 7aa9f86ad1139b81d1c17a25a3c33a49a2e19aca | |
parent | 6c32290bac460ce53ea2d29b50047248f9f0de92 (diff) | |
download | rails-795dc3d15fee02c9ccc9da08c8fcee0830a4962a.tar.gz rails-795dc3d15fee02c9ccc9da08c8fcee0830a4962a.tar.bz2 rails-795dc3d15fee02c9ccc9da08c8fcee0830a4962a.zip |
adding more tests surrounding where_values_hash
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 3629f6f806..cc2c2c1446 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -1,8 +1,12 @@ require "cases/helper" +require 'models/post' +require 'models/comment' module ActiveRecord class RelationTest < ActiveRecord::TestCase - class FakeTable < Struct.new(:table_name) + fixtures :posts, :comments + + class FakeKlass < Struct.new(:table_name) end def test_construction @@ -56,7 +60,7 @@ module ActiveRecord assert_equal [], relation.extensions end - def test_where_values_hash + def test_empty_where_values_hash relation = Relation.new :a, :b assert_equal({}, relation.where_values_hash) @@ -64,8 +68,20 @@ module ActiveRecord assert_equal({}, relation.where_values_hash) end + def test_has_values + relation = Relation.new Post, Post.arel_table + relation.where_values << relation.table[:id].eq(10) + assert_equal({:id => 10}, relation.where_values_hash) + end + + def test_values_wrong_table + relation = Relation.new Post, Post.arel_table + relation.where_values << Comment.arel_table[:id].eq(10) + assert_equal({}, relation.where_values_hash) + end + def test_table_name_delegates_to_klass - relation = Relation.new FakeTable.new('foo'), :b + relation = Relation.new FakeKlass.new('foo'), :b assert_equal 'foo', relation.table_name end |