2010-10-18 19:54:50 -04:00
|
|
|
require 'helper'
|
2010-08-18 14:32:44 -04:00
|
|
|
|
|
|
|
module Arel
|
|
|
|
describe 'delete manager' do
|
|
|
|
describe 'new' do
|
|
|
|
it 'takes an engine' do
|
|
|
|
Arel::DeleteManager.new Table.engine
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'from' do
|
|
|
|
it 'uses from' do
|
|
|
|
table = Table.new(:users)
|
|
|
|
dm = Arel::DeleteManager.new Table.engine
|
|
|
|
dm.from table
|
2010-10-18 18:41:21 -04:00
|
|
|
dm.to_sql.must_be_like %{ DELETE FROM "users" }
|
2010-08-18 14:32:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'chains' do
|
|
|
|
table = Table.new(:users)
|
|
|
|
dm = Arel::DeleteManager.new Table.engine
|
2010-10-18 19:36:49 -04:00
|
|
|
dm.from(table).must_equal dm
|
2010-08-18 14:32:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'where' do
|
|
|
|
it 'uses where values' do
|
|
|
|
table = Table.new(:users)
|
|
|
|
dm = Arel::DeleteManager.new Table.engine
|
|
|
|
dm.from table
|
|
|
|
dm.where table[:id].eq(10)
|
2010-10-18 18:41:21 -04:00
|
|
|
dm.to_sql.must_be_like %{ DELETE FROM "users" WHERE "users"."id" = 10}
|
2010-08-18 14:32:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'chains' do
|
|
|
|
table = Table.new(:users)
|
|
|
|
dm = Arel::DeleteManager.new Table.engine
|
2010-10-18 19:36:49 -04:00
|
|
|
dm.where(table[:id].eq(10)).must_equal dm
|
2010-08-18 14:32:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|