1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

TreeManager classes deep-copy their statements.

This commit is contained in:
Mike Dalessio 2010-08-16 23:33:41 -04:00
parent 0403efa4c6
commit 788f33fb59
6 changed files with 49 additions and 0 deletions

View file

@ -15,5 +15,10 @@ module Arel
viz = Visitors::ToSql.new @engine
viz.accept @head
end
def initialize_copy other
super
@head = @head.clone
end
end
end

View file

@ -110,5 +110,16 @@ module Arel
}
end
end
describe "TreeManager" do
subject do
table = Table.new(:users)
Arel::InsertManager.new(Table.engine).tap do |manager|
manager.insert [[table[:id], nil]]
end
end
it_should_behave_like "TreeManager"
end
end
end

View file

@ -166,5 +166,16 @@ module Arel
manager.to_sql.should be_like 'SELECT "users"."id" FROM "users"'
end
end
describe "TreeManager" do
subject do
table = Table.new :users
Arel::SelectManager.new(Table.engine).tap do |manager|
manager.from(table).project(table['id'])
end
end
it_should_behave_like "TreeManager"
end
end
end

View file

@ -73,5 +73,17 @@ module Arel
um.where(table[:id].eq(1)).should == um
end
end
describe "TreeManager" do
subject do
table = Table.new :users
Arel::UpdateManager.new(Table.engine).tap do |manager|
manager.table table
manager.where table[:id].eq(1)
end
end
it_should_behave_like "TreeManager"
end
end
end

View file

@ -5,6 +5,7 @@ require 'arel'
require 'support/matchers/be_like'
require 'support/check'
Dir[File.join(File.dirname(__FILE__),'support/shared/*')].each { |f| require f }
if adapter = ENV['ADAPTER']
require "support/connections/#{adapter}_connection.rb"

View file

@ -0,0 +1,9 @@
shared_examples_for "TreeManager" do
describe "clone" do
it "clones the insert statement" do
subject.instance_variable_get("@head").should_receive(:clone).and_return(:foo) # TODO: ick.
dolly = subject.clone
dolly.instance_variable_get("@head").should == :foo
end
end
end