diff options
Diffstat (limited to 'spec/active_relation/unit/relations/order_spec.rb')
-rw-r--r-- | spec/active_relation/unit/relations/order_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/order_spec.rb b/spec/active_relation/unit/relations/order_spec.rb new file mode 100644 index 0000000000..15f08d70ee --- /dev/null +++ b/spec/active_relation/unit/relations/order_spec.rb @@ -0,0 +1,35 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module ActiveRelation + describe Order do + before do + @relation = Table.new(:users) + @attribute = @relation[:id] + end + + describe '#qualify' do + it "descends" do + Order.new(@relation, @attribute).qualify. \ + should == Order.new(@relation, @attribute).descend(&:qualify) + end + end + + describe '#descend' do + it "distributes over the relation and attributes" do + Order.new(@relation, @attribute).descend(&:qualify). \ + should == Order.new(@relation.descend(&:qualify), @attribute.qualify) + end + end + + describe '#to_sql' do + it "manufactures sql with an order clause" do + Order.new(@relation, @attribute).to_sql.should be_like(""" + SELECT `users`.`id`, `users`.`name` + FROM `users` + ORDER BY `users`.`id` + """) + end + end + end +end +
\ No newline at end of file |