aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/unit/relations/deletion_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/active_relation/unit/relations/deletion_spec.rb')
-rw-r--r--spec/active_relation/unit/relations/deletion_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/deletion_spec.rb b/spec/active_relation/unit/relations/deletion_spec.rb
new file mode 100644
index 0000000000..1a536e7aed
--- /dev/null
+++ b/spec/active_relation/unit/relations/deletion_spec.rb
@@ -0,0 +1,26 @@
+require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
+
+module ActiveRelation
+ describe Deletion do
+ before do
+ @relation = Table.new(:users)
+ end
+
+ describe '#to_sql' do
+ it 'manufactures sql deleting a table relation' do
+ Deletion.new(@relation).to_sql.should be_like("""
+ DELETE
+ FROM `users`
+ """)
+ end
+
+ it 'manufactures sql deleting a selection relation' do
+ Deletion.new(@relation.select(@relation[:id].equals(1))).to_sql.should be_like("""
+ DELETE
+ FROM `users`
+ WHERE `users`.`id` = 1
+ """)
+ end
+ end
+ end
+end \ No newline at end of file