diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-01-01 16:44:33 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-01-01 16:44:33 -0800 |
commit | 6c89e3818d85e3169a7fb8de27b25357c2259881 (patch) | |
tree | 2ffe9fbe8765239733a864646ce71f9551736151 /spec/integration | |
parent | 0496a59e1fe0caf2d295defb588a00460cf15efb (diff) | |
download | rails-6c89e3818d85e3169a7fb8de27b25357c2259881.tar.gz rails-6c89e3818d85e3169a7fb8de27b25357c2259881.tar.bz2 rails-6c89e3818d85e3169a7fb8de27b25357c2259881.zip |
integration test
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/scratch_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/integration/scratch_spec.rb b/spec/integration/scratch_spec.rb new file mode 100644 index 0000000000..6426d2478d --- /dev/null +++ b/spec/integration/scratch_spec.rb @@ -0,0 +1,37 @@ +require File.join(File.dirname(__FILE__), '..', 'spec_helper') + +describe 'Relational Algebra' do + before do + User = TableRelation.new(:users) + Photo = TableRelation.new(:photos) + Camera = TableRelation.new(:cameras) + user = User.select(User[:id] == 1) + @user_photos = (user << Photo).on(user[:id] == Photo[:user_id]) + end + + it 'simulates User.has_many :photos' do + @user_photos.to_sql.should == SelectBuilder.new do + select { all } + from :users do + left_outer_join :photos do + equals { column :users, :id; column :photos, :user_id } + end + end + where do + equals { column :users, :id; value 1 } + end + end + @user_photos.to_sql.to_s.should be_like(""" + SELECT * + FROM users + LEFT OUTER JOIN photos + ON users.id = photos.user_id + WHERE + users.id = 1 + """) + end + + it 'simulating a User.has_many :cameras :through => :photos' do + user_cameras = (@user_photos << Camera).on(@user_photos[:camera_id] == Camera[:id]) + end +end
\ No newline at end of file |