diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/attributes/test_attribute.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb index dd2d9d343e..b50bb60b1e 100644 --- a/test/attributes/test_attribute.rb +++ b/test/attributes/test_attribute.rb @@ -85,6 +85,17 @@ module Arel SELECT * FROM "users" WHERE "users"."karma" > (SELECT AVG("users"."karma") FROM "users") } end + + it 'should accept various data types.' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:name].gt('fake_name') + mgr.to_sql.must_match %{"users"."name" > 'fake_name'} + + current_time = ::Time.now + mgr.where relation[:created_at].gt(current_time) + mgr.to_sql.must_match %{"users"."created_at" > '#{current_time}'} + end end describe '#gt_any' do @@ -133,6 +144,17 @@ module Arel SELECT "users"."id" FROM "users" WHERE "users"."id" >= 10 } end + + it 'should accept various data types.' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:name].gteq('fake_name') + mgr.to_sql.must_match %{"users"."name" >= 'fake_name'} + + current_time = ::Time.now + mgr.where relation[:created_at].gteq(current_time) + mgr.to_sql.must_match %{"users"."created_at" >= '#{current_time}'} + end end describe '#gteq_any' do @@ -181,6 +203,17 @@ module Arel SELECT "users"."id" FROM "users" WHERE "users"."id" < 10 } end + + it 'should accept various data types.' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:name].lt('fake_name') + mgr.to_sql.must_match %{"users"."name" < 'fake_name'} + + current_time = ::Time.now + mgr.where relation[:created_at].lt(current_time) + mgr.to_sql.must_match %{"users"."created_at" < '#{current_time}'} + end end describe '#lt_any' do @@ -229,6 +262,17 @@ module Arel SELECT "users"."id" FROM "users" WHERE "users"."id" <= 10 } end + + it 'should accept various data types.' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:name].lteq('fake_name') + mgr.to_sql.must_match %{"users"."name" <= 'fake_name'} + + current_time = ::Time.now + mgr.where relation[:created_at].lteq(current_time) + mgr.to_sql.must_match %{"users"."created_at" <= '#{current_time}'} + end end describe '#lteq_any' do |