Skip to content

Instantly share code, notes, and snippets.

@chanks
Created May 28, 2012 19:35
Sequel nested attributes spec
it "should support creating new objects with composite primary keys" do
a = @Artist.new({:name=>'Ar', :concerts_attributes=>[{:tour => 'To', :date => "2004-04-05"}]})
@db.sqls.should == []
a.save
check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
["INSERT INTO concerts (tour, date, artist_id) VALUES ('To', '2004-04-05', 1)",
"INSERT INTO concerts (artist_id, tour, date) VALUES (1, 'To', '2004-04-05')"
]) # etc.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment