aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/unit/relations/insertion_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/active_relation/unit/relations/insertion_spec.rb')
-rw-r--r--spec/active_relation/unit/relations/insertion_spec.rb32
1 files changed, 21 insertions, 11 deletions
diff --git a/spec/active_relation/unit/relations/insertion_spec.rb b/spec/active_relation/unit/relations/insertion_spec.rb
index e01e7792e2..e1718e3b25 100644
--- a/spec/active_relation/unit/relations/insertion_spec.rb
+++ b/spec/active_relation/unit/relations/insertion_spec.rb
@@ -7,44 +7,54 @@ module ActiveRelation
end
describe '#to_sql' do
- describe 'when given values whose types correspond to the types of the attributes' do
- before do
- @insertion = Insertion.new(@relation, @relation[:name] => "nick")
+ it 'manufactures sql inserting data when given multiple rows' do
+ pending do
+ @insertion = Insertion.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"])
+
+ @insertion.to_sql.should be_like("
+ INSERT
+ INTO `users`
+ (`users`.`name`) VALUES ('nick'), ('bryan')
+ ")
end
+ end
+
+ it 'manufactures sql inserting data when given multiple values' do
+ pending do
+ @insertion = Insertion.new(@relation, @relation[:id] => "1", @relation[:name] => "nick")
- it 'manufactures sql inserting data' do
@insertion.to_sql.should be_like("
INSERT
INTO `users`
- (`users`.`name`) VALUES ('nick')
+ (`users`.`name`, `users`.`id`) VALUES ('nick', 1)
")
end
end
- describe 'when given values whose types differ from from the types of the attributes' do
+ describe 'when given values whose types correspond to the types of the attributes' do
before do
- @insertion = Insertion.new(@relation, @relation[:id] => '1-asdf')
+ @insertion = Insertion.new(@relation, @relation[:name] => "nick")
end
it 'manufactures sql inserting data' do
@insertion.to_sql.should be_like("
INSERT
INTO `users`
- (`users`.`id`) VALUES (1)
+ (`users`.`name`) VALUES ('nick')
")
end
end
- describe 'when given values whose types correspond to the type of the attribtues' do
+ describe 'when given values whose types differ from from the types of the attributes' do
before do
- @insertion = Insertion.new(@relation, @relation[:name] => "nick")
+ @insertion = Insertion.new(@relation, @relation[:id] => '1-asdf')
end
it 'manufactures sql inserting data' do
@insertion.to_sql.should be_like("
INSERT
INTO `users`
- (`users`.`name`) VALUES ('nick')
+ (`users`.`id`) VALUES (1)
")
end
end