diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-30 14:10:55 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-30 14:10:55 -0800 |
commit | bfc398cb7083c41becf6e4938c0a80a6659a1caa (patch) | |
tree | b44ab8fc56acf2ee333fc64b493f69fbcd2231f0 /activerecord | |
parent | b7a9890d7765a0a6edc1161f58304386266bdf2e (diff) | |
download | rails-bfc398cb7083c41becf6e4938c0a80a6659a1caa.tar.gz rails-bfc398cb7083c41becf6e4938c0a80a6659a1caa.tar.bz2 rails-bfc398cb7083c41becf6e4938c0a80a6659a1caa.zip |
adding a test for ActiveRecord::Relation
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb new file mode 100644 index 0000000000..96856ac22b --- /dev/null +++ b/activerecord/test/cases/relation_test.rb @@ -0,0 +1,56 @@ +require "cases/helper" + +module ActiveRecord + class RelationTest < ActiveRecord::TestCase + def test_construction + relation = nil + assert_nothing_raised do + relation = Relation.new :a, :b + end + assert_equal :a, relation.klass + assert_equal :b, relation.table + assert !relation.loaded, 'relation is not loaded' + end + + def test_single_values + assert_equal [:limit, :offset, :lock, :readonly, :create_with, :from].sort, + Relation::SINGLE_VALUE_METHODS.sort + end + + def test_initialize_single_values + relation = Relation.new :a, :b + Relation::SINGLE_VALUE_METHODS.each do |method| + assert_nil relation.send("#{method}_value"), method.to_s + end + end + + def test_association_methods + assert_equal [:includes, :eager_load, :preload].sort, + Relation::ASSOCIATION_METHODS.sort + end + + def test_initialize_association_methods + relation = Relation.new :a, :b + Relation::ASSOCIATION_METHODS.each do |method| + assert_equal [], relation.send("#{method}_values"), method.to_s + end + end + + def test_multi_value_methods + assert_equal [:select, :group, :order, :joins, :where, :having, :bind].sort, + Relation::MULTI_VALUE_METHODS.sort + end + + def test_multi_value_initialize + relation = Relation.new :a, :b + Relation::MULTI_VALUE_METHODS.each do |method| + assert_equal [], relation.send("#{method}_values"), method.to_s + end + end + + def test_extensions + relation = Relation.new :a, :b + assert_equal [], relation.extensions + end + end +end |