mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add specs for simple in memory joins.
This commit is contained in:
parent
a33ab1b34e
commit
d2bf57135f
1 changed files with 40 additions and 0 deletions
40
spec/relations/join_spec.rb
Normal file
40
spec/relations/join_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Arel" do
|
||||
before :all do
|
||||
@owner = Arel::Model.build do |r|
|
||||
r.engine Arel::Testing::Engine.new
|
||||
|
||||
r.attribute :id, Arel::Attributes::Integer
|
||||
end
|
||||
|
||||
@thing = Arel::Model.build do |r|
|
||||
r.engine Arel::Testing::Engine.new
|
||||
|
||||
r.attribute :id, Arel::Attributes::Integer
|
||||
r.attribute :owner_id, Arel::Attributes::Integer
|
||||
r.attribute :age, Arel::Attributes::Integer
|
||||
end
|
||||
end
|
||||
|
||||
describe "Join" do
|
||||
before :all do
|
||||
@relation = @thing.join(@owner).on(@thing[:owner_id].eq(@owner[:id]))
|
||||
@expected = []
|
||||
|
||||
3.times do |owner_id|
|
||||
@owner.insert([owner_id])
|
||||
|
||||
8.times do |i|
|
||||
thing_id = owner_id * 8 + i
|
||||
age = 2 * thing_id
|
||||
|
||||
@thing.insert([thing_id, owner_id, age])
|
||||
@expected << Arel::Row.new(@relation, [thing_id, owner_id, age, owner_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_should_behave_like 'A Relation'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue