blob: 895ec2a9b65e00a3efc99a34b6cf85f71793ac0d (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
require 'spec_helper'
module Arel
module Sql
describe "Christener" do
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
|