Sha256: d3dfbce85877e7a97b250fa905b30bb210fbd98ce8a8b7a276e4847061321b2c

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
describe ActiveRecord::Base do
  before :each do
    @user = CmUser.new(:name => "Testing")
    @user.save
    @foo = Foo.new(:cm_user_id => @user.id)
    @foo.save
  end

  describe '#joins' do
    it "should work" do
      @user.foos.blank?.should be_false
      found = Foo.joins(:cm_user).select('cm_users.name AS user_name').where('cm_users.id = ?',@user.id).first
      expect(found.user_name).to_not be_blank
    end
  end
  describe '#includes' do
    before(:each) do
      @user.foos.blank?.should be_false
      search = Foo.includes(:cm_user).where('cm_users.id = ?',@user.id)
      search = search.references(:cm_user) if search.respond_to?(:references)
      @found = search.first
    end
    it "should return a results" do
      expect(@found).to be_a(Foo) # Make sure results are returns
    end
    it "should load associations" do
      if @found.respond_to?(:association)
        expect(@found.association(:cm_user)).to be_loaded
      else
        expect(@found.cm_user).to be_loaded
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
connection_manager-1.1.5 spec/lib/integration/cross_schema_spec.rb
connection_manager-1.1.4 spec/lib/integration/cross_schema_spec.rb
connection_manager-1.1.3 spec/lib/integration/cross_schema_spec.rb
connection_manager-1.1.2 spec/lib/integration/cross_schema_spec.rb
connection_manager-1.1.1 spec/lib/integration/cross_schema_spec.rb
connection_manager-1.1.0 spec/lib/integration/cross_schema_spec.rb