blob: 32a54e72fa9fe5894e55b7f731e2cf04b7a69d3b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
|