Permalink
Browse files

Improve spec for modifying joined datasets

  • Loading branch information...
1 parent a71d39d commit 571e8e812c703a4d95891ecadaff7d8419aa3b0c @jeremyevans committed Nov 21, 2009
Showing with 12 additions and 10 deletions.
  1. +12 −10 spec/integration/dataset_test.rb
@@ -876,32 +876,34 @@ def uprev
before do
@db = INTEGRATION_DB
@db.create_table!(:a){Integer :a; Integer :d}
- @db.create_table!(:b){Integer :b}
- @db.create_table!(:c){Integer :c}
- @ds = @db.from(:a, :b).join(:c, :c=>:b.identifier).where(:d=>:b).order(:a)
+ @db.create_table!(:b){Integer :b; Integer :e}
+ @db.create_table!(:c){Integer :c; Integer :f}
+ @ds = @db.from(:a, :b).join(:c, :c=>:e.identifier).where(:d=>:b, :f=>6).order(:a)
@db[:a].insert(1, 2)
@db[:a].insert(3, 4)
- @db[:b].insert(2)
- @db[:c].insert(2)
+ @db[:b].insert(2, 5)
+ @db[:c].insert(5, 6)
+ @db[:b].insert(4, 7)
+ @db[:c].insert(7, 8)
end
after do
@db.drop_table(:a, :b, :c)
end
it "#update should allow updating joined datasets" do
@ds.update(:a=>10)
- @ds.all.should == [{:c=>2, :b=>2, :a=>10, :d=>2}]
+ @ds.all.should == [{:c=>5, :b=>2, :a=>10, :d=>2, :e=>5, :f=>6}]
@db[:a].order(:a).all.should == [{:a=>3, :d=>4}, {:a=>10, :d=>2}]
- @db[:b].all.should == [{:b=>2}]
- @db[:c].all.should == [{:c=>2}]
+ @db[:b].order(:b).all.should == [{:b=>2, :e=>5}, {:b=>4, :e=>7}]
+ @db[:c].order(:c).all.should == [{:c=>5, :f=>6}, {:c=>7, :f=>8}]
end
it "#delete should allow deleting from joined datasets" do
@ds.delete
@ds.all.should == []
@db[:a].order(:a).all.should == [{:a=>3, :d=>4}]
- @db[:b].all.should == [{:b=>2}]
- @db[:c].all.should == [{:c=>2}]
+ @db[:b].order(:b).all.should == [{:b=>2, :e=>5}, {:b=>4, :e=>7}]
+ @db[:c].order(:c).all.should == [{:c=>5, :f=>6}, {:c=>7, :f=>8}]
end
end
end

0 comments on commit 571e8e8

Please sign in to comment.