blob: 0a41c4d3fc4684c3eef1082852348c377285ecd9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
require 'spec_helper'
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
dm.to_sql.must_be_like %{ DELETE FROM "users" }
end
it 'chains' do
table = Table.new(:users)
dm = Arel::DeleteManager.new Table.engine
check dm.from(table).must_equal dm
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)
dm.to_sql.must_be_like %{ DELETE FROM "users" WHERE "users"."id" = 10}
end
it 'chains' do
table = Table.new(:users)
dm = Arel::DeleteManager.new Table.engine
check dm.where(table[:id].eq(10)).must_equal dm
end
end
# HACK
# describe "TreeManager" do
# before do
# table = Table.new :users
# Arel::DeleteManager.new(Table.engine).tap do |manager|
# manager.where(table[:id].eq(10))
# end
# end
#
# it_should_behave_like "TreeManager"
# end
end
end
|