diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 18:32:47 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 18:32:47 -0700 |
commit | a0dc6900330b7ec78785a80fe8b72595384635a0 (patch) | |
tree | 2f73c8433cecf638fd53c33e09803b1012b61759 /spec | |
parent | ae0fe8f6c8c41b5abf8ced6a99b19dacdf8f57eb (diff) | |
download | rails-a0dc6900330b7ec78785a80fe8b72595384635a0.tar.gz rails-a0dc6900330b7ec78785a80fe8b72595384635a0.tar.bz2 rails-a0dc6900330b7ec78785a80fe8b72595384635a0.zip |
fixed bug with take/skip
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/unit/relations/relation_spec.rb | 12 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/skip_spec.rb | 10 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/take_spec.rb | 10 |
3 files changed, 22 insertions, 10 deletions
diff --git a/spec/active_relation/unit/relations/relation_spec.rb b/spec/active_relation/unit/relations/relation_spec.rb index d10ae490de..2a04276aeb 100644 --- a/spec/active_relation/unit/relations/relation_spec.rb +++ b/spec/active_relation/unit/relations/relation_spec.rb @@ -106,6 +106,18 @@ module ActiveRelation end end + describe '#take' do + it "manufactures a take relation" do + @relation.take(5).should == Take.new(@relation, 5) + end + end + + describe '#skip' do + it "manufactures a skip relation" do + @relation.skip(4).should == Skip.new(@relation, 4) + end + end + describe '#call' do it 'executes a select_all on the connection' do mock(connection = Object.new).select_all(@relation.to_sql) diff --git a/spec/active_relation/unit/relations/skip_spec.rb b/spec/active_relation/unit/relations/skip_spec.rb index 77f2b8db27..d50ef715ee 100644 --- a/spec/active_relation/unit/relations/skip_spec.rb +++ b/spec/active_relation/unit/relations/skip_spec.rb @@ -4,27 +4,27 @@ module ActiveRelation describe Skip do before do @relation = Table.new(:users) - @skip = 4 + @skipped = 4 end describe '#qualify' do it "descends" do - Skip.new(@relation, @skip).qualify.should == Skip.new(@relation, @skip).descend(&:qualify) + Skip.new(@relation, @skipped).qualify.should == Skip.new(@relation, @skipped).descend(&:qualify) end end describe '#descend' do it "distributes a block over the relation" do - Skip.new(@relation, @skip).descend(&:qualify).should == Skip.new(@relation.descend(&:qualify), @skip) + Skip.new(@relation, @skipped).descend(&:qualify).should == Skip.new(@relation.descend(&:qualify), @skipped) end end describe '#to_sql' do it "manufactures sql with limit and offset" do - Skip.new(@relation, @skip).to_s.should be_like(" + Skip.new(@relation, @skipped).to_s.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` - OFFSET #{@skip} + OFFSET #{@skipped} ") end end diff --git a/spec/active_relation/unit/relations/take_spec.rb b/spec/active_relation/unit/relations/take_spec.rb index 6523ff85f9..beaa9e2f8c 100644 --- a/spec/active_relation/unit/relations/take_spec.rb +++ b/spec/active_relation/unit/relations/take_spec.rb @@ -4,27 +4,27 @@ module ActiveRelation describe Take do before do @relation = Table.new(:users) - @take = 4 + @takene = 4 end describe '#qualify' do it "descends" do - Take.new(@relation, @take).qualify.should == Take.new(@relation, @take).descend(&:qualify) + Take.new(@relation, @takene).qualify.should == Take.new(@relation, @takene).descend(&:qualify) end end describe '#descend' do it "distributes a block over the relation" do - Take.new(@relation, @take).descend(&:qualify).should == Take.new(@relation.descend(&:qualify), @take) + Take.new(@relation, @takene).descend(&:qualify).should == Take.new(@relation.descend(&:qualify), @takene) end end describe '#to_sql' do it "manufactures sql with limit and offset" do - Take.new(@relation, @take).to_s.should be_like(" + Take.new(@relation, @takene).to_s.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` - LIMIT #{@take} + LIMIT #{@takene} ") end end |