diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-10 16:58:19 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-10 16:58:19 -0700 |
commit | f0f6b7fb90b936cb78d786896598486821db6559 (patch) | |
tree | 9a5d7d61be6e70fd4c132457dec965ee41533422 /spec/arel/attributes | |
parent | 1ba8ac0848f40c7fa18c9e7bdac944a50d3c348c (diff) | |
download | rails-f0f6b7fb90b936cb78d786896598486821db6559.tar.gz rails-f0f6b7fb90b936cb78d786896598486821db6559.tar.bz2 rails-f0f6b7fb90b936cb78d786896598486821db6559.zip |
adding not equal node, column names are expected to be symbols
Diffstat (limited to 'spec/arel/attributes')
-rw-r--r-- | spec/arel/attributes/attribute_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/arel/attributes/attribute_spec.rb index ae0f70c5ba..6679ca8b7a 100644 --- a/spec/arel/attributes/attribute_spec.rb +++ b/spec/arel/attributes/attribute_spec.rb @@ -3,6 +3,31 @@ require 'spec_helper' module Arel module Attributes describe 'attribute' do + describe '#not_eq' do + it 'should create a NotEqual node' do + relation = Table.new(:users) + relation[:id].not_eq(10).should be_kind_of Nodes::NotEqual + end + + it 'should generate != in sql' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:id].not_eq(10) + mgr.to_sql.should be_like %{ + SELECT "users"."id" FROM "users" WHERE "users"."id" != 10 + } + end + + it 'should handle nil' do + relation = Table.new(:users) + mgr = relation.project relation[:id] + mgr.where relation[:id].not_eq(nil) + mgr.to_sql.should be_like %{ + SELECT "users"."id" FROM "users" WHERE "users"."id" IS NOT NULL + } + end + end + describe '#gt' do it 'should create a GreaterThan node' do relation = Table.new(:users) |