diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 14:03:20 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 14:55:00 -0700 |
commit | e26006fb877f8b9e75d814f3499c7e3dd7dc47b7 (patch) | |
tree | b06ec61ea18a7447224d3d7aa414b5ce9f620420 /spec/sql/christener_spec.rb | |
parent | afcfe97517f6c0c872c0eb79fc505cf85b1a3e74 (diff) | |
download | rails-e26006fb877f8b9e75d814f3499c7e3dd7dc47b7.tar.gz rails-e26006fb877f8b9e75d814f3499c7e3dd7dc47b7.tar.bz2 rails-e26006fb877f8b9e75d814f3499c7e3dd7dc47b7.zip |
adding tests for the christener
Diffstat (limited to 'spec/sql/christener_spec.rb')
-rw-r--r-- | spec/sql/christener_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/sql/christener_spec.rb b/spec/sql/christener_spec.rb new file mode 100644 index 0000000000..d50cb56261 --- /dev/null +++ b/spec/sql/christener_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +module Arel + module Sql + describe "Christener" do + it "returns the same name with two table objects" do + christener = Christener.new + table = Table.new 'users' + table2 = Table.new 'users' + christener.name_for(table).should == 'users' + christener.name_for(table2).should == 'users' + end + + it "returns the first name" do + christener = Christener.new + table = Table.new 'users' + table2 = Table.new 'pictures' + christener.name_for(table).should == 'users' + christener.name_for(table2).should == 'pictures' + christener.name_for(table).should == 'users' + end + + it "returns a unique name for an alias" do + christener = Christener.new + table = Table.new 'users' + table2 = Table.new 'users', :as => 'friends' + christener.name_for(table).should == 'users' + christener.name_for(table2).should == 'friends' + end + + it "returns a unique name for an alias with same name" do + christener = Christener.new + table = Table.new 'users' + table2 = Table.new 'friends', :as => 'users' + christener.name_for(table).should == 'users' + christener.name_for(table2).should == 'users_2' + end + + it "returns alias name" do + christener = Christener.new + table = Table.new 'users' + aliaz = Alias.new table + + christener.name_for(table).should == 'users' + christener.name_for(aliaz).should == 'users_2' + end + + it "returns alias first" do + christener = Christener.new + table = Table.new 'users' + aliaz = Alias.new table + + christener.name_for(aliaz).should == 'users' + christener.name_for(table).should == 'users_2' + end + + it "returns externalization name" do + christener = Christener.new + table = Table.new 'users' + ext = Externalization.new table + + christener.name_for(table).should == 'users' + christener.name_for(ext).should == 'users_external' + end + + it "returns aliases externalizations and tables" do + christener = Christener.new + table = Table.new 'users' + aliaz = Alias.new table + ext = Externalization.new table + + christener.name_for(table).should == 'users' + christener.name_for(aliaz).should == 'users_2' + christener.name_for(ext).should == 'users_external' + end + end + end +end |