aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-27 09:52:54 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-27 09:52:54 -0700
commitaac9da257f291ad8d2d4f914528881c240848bb2 (patch)
tree4ba06fbdc5f8f2d2a533abc7e7b3c0f14ad5d1aa /test
parentd36a769234911c8374e09069eb054d4c60eb1b99 (diff)
downloadrails-aac9da257f291ad8d2d4f914528881c240848bb2.tar.gz
rails-aac9da257f291ad8d2d4f914528881c240848bb2.tar.bz2
rails-aac9da257f291ad8d2d4f914528881c240848bb2.zip
Change the interface of `having` to match that of `where`
These two clauses have nearly identical semantics with regards to how they would be constructed as an AST. It doesn't make sense for their interfaces to be separate.
Diffstat (limited to 'test')
-rw-r--r--test/nodes/test_select_core.rb8
-rw-r--r--test/test_select_manager.rb10
-rw-r--r--test/visitors/test_depth_first.rb5
-rw-r--r--test/visitors/test_dot.rb1
4 files changed, 11 insertions, 13 deletions
diff --git a/test/nodes/test_select_core.rb b/test/nodes/test_select_core.rb
index ca4f070444..4114bcf4ff 100644
--- a/test/nodes/test_select_core.rb
+++ b/test/nodes/test_select_core.rb
@@ -34,14 +34,14 @@ module Arel
core1.wheres = %w[g h i]
core1.groups = %w[j k l]
core1.windows = %w[m n o]
- core1.having = %w[p q r]
+ core1.havings = %w[p q r]
core2 = SelectCore.new
core2.froms = %w[a b c]
core2.projections = %w[d e f]
core2.wheres = %w[g h i]
core2.groups = %w[j k l]
core2.windows = %w[m n o]
- core2.having = %w[p q r]
+ core2.havings = %w[p q r]
array = [core1, core2]
assert_equal 1, array.uniq.size
end
@@ -53,14 +53,14 @@ module Arel
core1.wheres = %w[g h i]
core1.groups = %w[j k l]
core1.windows = %w[m n o]
- core1.having = %w[p q r]
+ core1.havings = %w[p q r]
core2 = SelectCore.new
core2.froms = %w[a b c]
core2.projections = %w[d e f]
core2.wheres = %w[g h i]
core2.groups = %w[j k l]
core2.windows = %w[m n o]
- core2.having = %w[l o l]
+ core2.havings = %w[l o l]
array = [core1, core2]
assert_equal 2, array.uniq.size
end
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb
index 809f0de8df..7192027df4 100644
--- a/test/test_select_manager.rb
+++ b/test/test_select_manager.rb
@@ -111,22 +111,22 @@ module Arel
it 'converts strings to SQLLiterals' do
table = Table.new :users
mgr = table.from
- mgr.having 'foo'
+ mgr.having Arel.sql('foo')
mgr.to_sql.must_be_like %{ SELECT FROM "users" HAVING foo }
end
it 'can have multiple items specified separately' do
table = Table.new :users
mgr = table.from
- mgr.having 'foo'
- mgr.having 'bar'
+ mgr.having Arel.sql('foo')
+ mgr.having Arel.sql('bar')
mgr.to_sql.must_be_like %{ SELECT FROM "users" HAVING foo AND bar }
end
- it 'can have multiple items specified together' do
+ it 'can receive any node' do
table = Table.new :users
mgr = table.from
- mgr.having 'foo', 'bar'
+ mgr.having Arel::Nodes::And.new([Arel.sql('foo'), Arel.sql('bar')])
mgr.to_sql.must_be_like %{ SELECT FROM "users" HAVING foo AND bar }
end
end
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index d50ea3e59a..3356759b7d 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -30,7 +30,6 @@ module Arel
Arel::Nodes::Grouping,
Arel::Nodes::Offset,
Arel::Nodes::Ordering,
- Arel::Nodes::Having,
Arel::Nodes::StringJoin,
Arel::Nodes::UnqualifiedColumn,
Arel::Nodes::Top,
@@ -206,7 +205,7 @@ module Arel
core.wheres << :c
core.groups << :d
core.windows << :e
- core.having = :f
+ core.havings << :f
@visitor.accept core
assert_equal [
@@ -216,7 +215,7 @@ module Arel
:c, core.wheres,
:d, core.groups,
:e, core.windows,
- :f,
+ :f, core.havings,
core], @collector.calls
end
diff --git a/test/visitors/test_dot.rb b/test/visitors/test_dot.rb
index 7763350f5c..4dc3c9c6c5 100644
--- a/test/visitors/test_dot.rb
+++ b/test/visitors/test_dot.rb
@@ -34,7 +34,6 @@ module Arel
Arel::Nodes::Grouping,
Arel::Nodes::Offset,
Arel::Nodes::Ordering,
- Arel::Nodes::Having,
Arel::Nodes::UnqualifiedColumn,
Arel::Nodes::Top,
Arel::Nodes::Limit,