diff options
Diffstat (limited to 'spec/arel/engines/sql/unit/relations/having_spec.rb')
-rw-r--r-- | spec/arel/engines/sql/unit/relations/having_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/relations/having_spec.rb b/spec/arel/engines/sql/unit/relations/having_spec.rb new file mode 100644 index 0000000000..dd170a256f --- /dev/null +++ b/spec/arel/engines/sql/unit/relations/having_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +module Arel + describe Having do + before do + @relation = Table.new(:developers) + end + + describe '#to_sql' do + describe 'when given a predicate' do + it "manufactures sql with where clause conditions" do + sql = @relation.group(@relation[:department]).having("MIN(salary) > 1000").to_sql + + adapter_is :mysql do + sql.should be_like(%Q{ + SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department` + FROM `developers` + GROUP BY `developers`.`department` + HAVING MIN(salary) > 1000 + }) + end + + adapter_is_not :mysql do + sql.should be_like(%Q{ + SELECT "developers"."id", "developers"."name", "developers"."salary", "developers"."department" + FROM "developers" + GROUP BY "developers"."department" + HAVING MIN(salary) > 1000 + }) + end + end + end + end + end +end + |