aboutsummaryrefslogtreecommitdiffstats
path: root/spec/relations/table_relation_spec.rb
blob: 038037234415e4fb7e4909f74e7bfef22f17ef26 (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
require File.join(File.dirname(__FILE__), '..', 'spec_helper')

describe TableRelation do
  before do
    @relation = TableRelation.new(:users)
  end
  
  describe '#to_sql' do
    it "returns a simple SELECT query" do
      @relation.to_sql.should == SelectBuilder.new do |s|
        select do
          column :users, :name
          column :users, :id
        end
        from :users
      end
    end
  end
  
  describe '#attributes' do
    it 'manufactures attributes corresponding to columns in the table' do
      pending
    end
  end
  
  describe '#qualify' do
    it 'manufactures a rename relation with all attribute names qualified' do
      @relation.qualify.should == RenameRelation.new(
        RenameRelation.new(@relation, @relation[:id] => 'users.id'), @relation[:name] => 'users.name'
      )
    end
  end
end