diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-12 20:13:04 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-12 20:13:04 -0800 |
commit | d2bf57135f7293a1998a25bd828b0c470cf6b85c (patch) | |
tree | 8b93b35b8d4f4e5997dbdcfd220d32947d704d65 | |
parent | a33ab1b34e74c3b1d6f3bae4a2477527e5f8ca55 (diff) | |
download | rails-d2bf57135f7293a1998a25bd828b0c470cf6b85c.tar.gz rails-d2bf57135f7293a1998a25bd828b0c470cf6b85c.tar.bz2 rails-d2bf57135f7293a1998a25bd828b0c470cf6b85c.zip |
Add specs for simple in memory joins.
-rw-r--r-- | spec/relations/join_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/relations/join_spec.rb b/spec/relations/join_spec.rb new file mode 100644 index 0000000000..47e468a9f9 --- /dev/null +++ b/spec/relations/join_spec.rb @@ -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
\ No newline at end of file |