aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/unit
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-24 22:19:32 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-24 22:19:32 -0800
commit92db013ba3ee4d0a9d92281e614d05f064c22e15 (patch)
tree23585e771ee1a2b1682f66a67d6b6891fab49f24 /spec/active_relation/unit
parentecd072d21951573f59e9515b868224d3732dbdfa (diff)
downloadrails-92db013ba3ee4d0a9d92281e614d05f064c22e15.tar.gz
rails-92db013ba3ee4d0a9d92281e614d05f064c22e15.tar.bz2
rails-92db013ba3ee4d0a9d92281e614d05f064c22e15.zip
quoting issues
Diffstat (limited to 'spec/active_relation/unit')
-rw-r--r--spec/active_relation/unit/predicates/binary_spec.rb3
-rw-r--r--spec/active_relation/unit/predicates/equality_spec.rb8
-rw-r--r--spec/active_relation/unit/primitives/attribute_spec.rb41
-rw-r--r--spec/active_relation/unit/primitives/expression_spec.rb2
-rw-r--r--spec/active_relation/unit/relations/table_spec.rb8
5 files changed, 35 insertions, 27 deletions
diff --git a/spec/active_relation/unit/predicates/binary_spec.rb b/spec/active_relation/unit/predicates/binary_spec.rb
index 44c1a1a7a0..1f6656b9d1 100644
--- a/spec/active_relation/unit/predicates/binary_spec.rb
+++ b/spec/active_relation/unit/predicates/binary_spec.rb
@@ -53,6 +53,9 @@ module ActiveRelation
`users`.`id` <=> `photos`.`id`
""")
end
+
+ it 'appropriately cooerces scalars' do
+ end
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/unit/predicates/equality_spec.rb b/spec/active_relation/unit/predicates/equality_spec.rb
index fd30846c70..499b13383d 100644
--- a/spec/active_relation/unit/predicates/equality_spec.rb
+++ b/spec/active_relation/unit/predicates/equality_spec.rb
@@ -3,10 +3,10 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
module ActiveRelation
describe Equality do
before do
- @relation1 = Table.new(:foo)
- @relation2 = Table.new(:bar)
- @attribute1 = Attribute.new(@relation1, :name)
- @attribute2 = Attribute.new(@relation2, :name)
+ @relation1 = Table.new(:users)
+ @relation2 = Table.new(:photos)
+ @attribute1 = @relation1[:name]
+ @attribute2 = @relation2[:name]
end
describe '==' do
diff --git a/spec/active_relation/unit/primitives/attribute_spec.rb b/spec/active_relation/unit/primitives/attribute_spec.rb
index e5a3792d85..8b4f52c432 100644
--- a/spec/active_relation/unit/primitives/attribute_spec.rb
+++ b/spec/active_relation/unit/primitives/attribute_spec.rb
@@ -4,23 +4,20 @@ module ActiveRelation
describe Attribute do
before do
@relation = Table.new(:users)
+ @attribute = Attribute.new(@relation, :id)
end
describe Attribute::Transformations do
- before do
- @attribute = Attribute.new(@relation, :id)
- end
-
describe '#as' do
it "manufactures an aliased attributed" do
- @attribute.as(:alias).should == Attribute.new(@relation, @attribute.name, :alias, @attribute)
+ @attribute.as(:alias).should == Attribute.new(@relation, @attribute.name, :alias => :alias, :ancestor => @attribute)
end
end
describe '#bind' do
it "manufactures an attribute with the relation bound and self as an ancestor" do
derived_relation = @relation.select(@relation[:id].equals(1))
- @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, nil, @attribute)
+ @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, :ancestor => @attribute)
end
it "returns self if the substituting to the same relation" do
@@ -30,7 +27,7 @@ module ActiveRelation
describe '#qualify' do
it "manufactures an attribute aliased with that attribute's qualified name" do
- @attribute.qualify.should == Attribute.new(@attribute.relation, @attribute.name, @attribute.qualified_name, @attribute)
+ @attribute.qualify.should == Attribute.new(@attribute.relation, @attribute.name, :alias => @attribute.qualified_name, :ancestor => @attribute)
end
end
@@ -41,9 +38,16 @@ module ActiveRelation
end
end
+ describe '#column' do
+ it "" do
+ pending
+ end
+ end
+
describe '#qualified_name' do
it "manufactures an attribute name prefixed with the relation's name" do
- Attribute.new(@relation, :id).qualified_name.should == 'users.id'
+ stub(@relation).prefix_for(anything) { 'bruisers' }
+ Attribute.new(@relation, :id).qualified_name.should == 'bruisers.id'
end
end
@@ -54,25 +58,20 @@ module ActiveRelation
end
it "obtains if the attributes have an overlapping history" do
- Attribute.new(@relation, :name, nil, Attribute.new(@relation, :name)).should =~ Attribute.new(@relation, :name)
- Attribute.new(@relation, :name).should =~ Attribute.new(@relation, :name, nil, Attribute.new(@relation, :name))
+ Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)).should =~ Attribute.new(@relation, :name)
+ Attribute.new(@relation, :name).should =~ Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name))
end
end
end
describe '#to_sql' do
- describe Sql::Strategy do
- before do
- stub(@relation).prefix_for(anything) { 'bruisers' }
- end
-
- it "manufactures sql without an alias if the strategy is Predicate" do
- Attribute.new(@relation, :name, :alias).to_sql(Sql::Predicate.new).should be_like("`bruisers`.`name`")
- end
+ it "" do
+ pending "this test is not sufficiently resilient"
+ end
- it "manufactures sql with an alias if the strategy is Projection" do
- Attribute.new(@relation, :name, :alias).to_sql(Sql::Projection.new).should be_like("`bruisers`.`name` AS 'alias'")
- end
+ it "manufactures sql with an alias" do
+ stub(@relation).prefix_for(anything) { 'bruisers' }
+ Attribute.new(@relation, :name, :alias => :alias).to_sql.should be_like("`bruisers`.`name`")
end
end
diff --git a/spec/active_relation/unit/primitives/expression_spec.rb b/spec/active_relation/unit/primitives/expression_spec.rb
index 5506f52b86..dda35157b0 100644
--- a/spec/active_relation/unit/primitives/expression_spec.rb
+++ b/spec/active_relation/unit/primitives/expression_spec.rb
@@ -31,7 +31,7 @@ module ActiveRelation
describe '#to_attribute' do
it "manufactures an attribute with the expression as an ancestor" do
- @expression.to_attribute.should == Attribute.new(@expression.relation, @expression.alias, nil, @expression)
+ @expression.to_attribute.should == Attribute.new(@expression.relation, @expression.alias, :ancestor => @expression)
end
end
end
diff --git a/spec/active_relation/unit/relations/table_spec.rb b/spec/active_relation/unit/relations/table_spec.rb
index 3b02f80701..f8d4431aa7 100644
--- a/spec/active_relation/unit/relations/table_spec.rb
+++ b/spec/active_relation/unit/relations/table_spec.rb
@@ -45,9 +45,15 @@ module ActiveRelation
end
end
+ describe '#column_for' do
+ it "" do
+ pending
+ end
+ end
+
describe '#prefix_for' do
it "returns the table name if the relation contains the attribute" do
- @relation.prefix_for(@relation[:id]).should == :users
+ @relation.prefix_for(@relation[:id]).should == 'users'
@relation.prefix_for(:does_not_exist).should be_nil
end
end