aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-12 18:15:28 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-12 18:15:28 -0300
commitd23df0ec8a50b50024f8d4dc5d91a47509df9b1f (patch)
treebd70b551cab1af27874ac6e31e617a15505b9f9b /test
parent1ee24112e8b42879f02fcee995e222dcabb2cb64 (diff)
parent112cb940aa17a0979b9f6282c07ace2f6a0896c1 (diff)
downloadrails-d23df0ec8a50b50024f8d4dc5d91a47509df9b1f.tar.gz
rails-d23df0ec8a50b50024f8d4dc5d91a47509df9b1f.tar.bz2
rails-d23df0ec8a50b50024f8d4dc5d91a47509df9b1f.zip
Merge pull request #306 from mxhold/master
Add SelectManager#distinct_on to set/unset Arel::Nodes::DistinctOn quantifier
Diffstat (limited to 'test')
-rw-r--r--test/test_select_manager.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb
index 3380bbec6f..1ffb56fd9f 100644
--- a/test/test_select_manager.rb
+++ b/test/test_select_manager.rb
@@ -1158,5 +1158,26 @@ module Arel
manager.distinct(false).must_equal manager
end
end
+
+ describe 'distinct_on' do
+ it 'sets the quantifier' do
+ manager = Arel::SelectManager.new Table.engine
+ table = Table.new :users
+
+ manager.distinct_on(table['id'])
+ manager.ast.cores.last.set_quantifier.must_equal Arel::Nodes::DistinctOn.new(table['id'])
+
+ manager.distinct_on(false)
+ manager.ast.cores.last.set_quantifier.must_equal nil
+ end
+
+ it "chains" do
+ manager = Arel::SelectManager.new Table.engine
+ table = Table.new :users
+
+ manager.distinct_on(table['id']).must_equal manager
+ manager.distinct_on(false).must_equal manager
+ end
+ end
end
end