aboutsummaryrefslogblamecommitdiffstats
path: root/test/test_delete_manager.rb
blob: fd12c5acd2fecb13e9f4da118d5453fb14880a74 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
                













                                                 
                                                       




                                                 
                                    








                                                 
                                                                              




                                                 
                                                 



         
require '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
        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
        dm.where(table[:id].eq(10)).must_equal dm
      end
    end
  end
end