diff options
author | Carl Lerche <carllerche@mac.com> | 2010-04-02 19:04:23 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-04-02 19:04:23 -0700 |
commit | a46922e4a1089c9880c30b389e1e1d9dfbab02ae (patch) | |
tree | 2115e291ff1799d662bbb445b96060f2d029cc0d /spec/attributes | |
parent | 233ee77f4511255ff2ff7c0b0ebf1cee13e7fc10 (diff) | |
download | rails-a46922e4a1089c9880c30b389e1e1d9dfbab02ae.tar.gz rails-a46922e4a1089c9880c30b389e1e1d9dfbab02ae.tar.bz2 rails-a46922e4a1089c9880c30b389e1e1d9dfbab02ae.zip |
Create an Arel::Header class representing a relation's attributes
Diffstat (limited to 'spec/attributes')
-rw-r--r-- | spec/attributes/header_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/attributes/header_spec.rb b/spec/attributes/header_spec.rb new file mode 100644 index 0000000000..5811041734 --- /dev/null +++ b/spec/attributes/header_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +module Arel + describe "Header" do + before :all do + @relation = Model.build do |r| + r.attribute :id, Attributes::Integer + r.attribute :name, Attributes::String + r.attribute :age, Attributes::Integer + end + + @other = Model.build do |r| + r.attribute :foo, Attributes::String + end + + @subset = Model.build do |r| + r.attribute :id, Attributes::Integer + end + end + + it "finds attributes by name" do + @relation.attributes[:name].should == Attributes::String.new(@relation, :name) + end + + describe "#union" do + it "keeps all attributes from disjoint headers" do + (@relation.attributes.union @other.attributes).to_ary.should have(4).items + end + + it "keeps all attributes from both relations even if they seem like subsets" do + (@relation.attributes.union @subset.attributes).to_ary.should have(4).items + end + end + end +end
\ No newline at end of file |