aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2008-04-13 17:09:59 -0400
committerBryan Helmkamp <bryan@brynary.com>2008-04-13 17:09:59 -0400
commit968271f718929311797342e211f5ca29506463b9 (patch)
treea25be623a077ce86a19f9ff2cbb9efd6f52dd6c1 /spec
parent1215d8b0b9a44619ea1e77dbce723da12f7f73ea (diff)
downloadrails-968271f718929311797342e211f5ca29506463b9.tar.gz
rails-968271f718929311797342e211f5ca29506463b9.tar.bz2
rails-968271f718929311797342e211f5ca29506463b9.zip
Some pending specs for Insertion, Deletion and Update relating to LIMITs, multiple values and multiple rows
Diffstat (limited to 'spec')
-rw-r--r--spec/active_relation/unit/relations/deletion_spec.rb10
-rw-r--r--spec/active_relation/unit/relations/insertion_spec.rb24
-rw-r--r--spec/active_relation/unit/relations/update_spec.rb19
3 files changed, 53 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/deletion_spec.rb b/spec/active_relation/unit/relations/deletion_spec.rb
index 71ddd8d820..72f3f81b2a 100644
--- a/spec/active_relation/unit/relations/deletion_spec.rb
+++ b/spec/active_relation/unit/relations/deletion_spec.rb
@@ -21,6 +21,16 @@ module ActiveRelation
WHERE `users`.`id` = 1
")
end
+
+ it "manufactures sql deleting a ranged relation" do
+ pending do
+ Deletion.new(@relation[0..0]).to_sql.should be_like("
+ DELETE
+ FROM `users`
+ LIMIT 1
+ ")
+ end
+ end
end
describe '#call' do
diff --git a/spec/active_relation/unit/relations/insertion_spec.rb b/spec/active_relation/unit/relations/insertion_spec.rb
index 7aca7f24c1..e1718e3b25 100644
--- a/spec/active_relation/unit/relations/insertion_spec.rb
+++ b/spec/active_relation/unit/relations/insertion_spec.rb
@@ -7,6 +7,30 @@ module ActiveRelation
end
describe '#to_sql' do
+ 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")
+
+ @insertion.to_sql.should be_like("
+ INSERT
+ INTO `users`
+ (`users`.`name`, `users`.`id`) VALUES ('nick', 1)
+ ")
+ end
+ end
+
describe 'when given values whose types correspond to the types of the attributes' do
before do
@insertion = Insertion.new(@relation, @relation[:name] => "nick")
diff --git a/spec/active_relation/unit/relations/update_spec.rb b/spec/active_relation/unit/relations/update_spec.rb
index 5c234fe759..6634dc67d1 100644
--- a/spec/active_relation/unit/relations/update_spec.rb
+++ b/spec/active_relation/unit/relations/update_spec.rb
@@ -7,6 +7,25 @@ module ActiveRelation
end
describe '#to_sql' do
+ it "manufactures sql updating attributes when given multiple attributes" do
+ pending do
+ Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql.should be_like("
+ UPDATE `users`
+ SET `users`.`name` = 'nick', `users`.`id` = 1
+ ")
+ end
+ end
+
+ it "manufactures sql updating attributes when given a ranged relation" do
+ pending do
+ Update.new(@relation[0..0], @relation[:name] => "nick").to_sql.should be_like("
+ UPDATE `users`
+ SET `users`.`name` = 'nick'
+ LIMIT 1
+ ")
+ end
+ end
+
describe 'when given values whose types correspond to the types of the attributes' do
before do
@update = Update.new(@relation, @relation[:name] => "nick")