Sha256: d573047855d88080e42f42eb9794f74f9cd33121cbd519c9c589a9e686e1bb2f

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require 'models/post'

describe "Table definition" do

  let(:connection) { ::ActiveRecord::Migration.connection }

  unless ::ActiveRecord::Base.connection.class.include?(
      RedhillonrailsCore::ActiveRecord::ConnectionAdapters::Sqlite3Adapter)

    it "sets table_name of foreign key definition when running migrations" do
      connection.create_table :votes, :force => true do |t|
        t.integer :kind
        t.integer :application_id
        t.integer :user_id
        t.foreign_key :user_id, :users, :id
      end

      Vote = Class.new(ActiveRecord::Base)
      Vote.foreign_keys.size.should == 1
      Vote.foreign_keys[0].table_name.should == 'votes'
      connection.drop_table :votes
    end

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
aspgems-redhillonrails_core-2.0.0.beta4 spec/table_definition_spec.rb
redhillonrails_core-2.0.0.pre spec/table_definition_spec.rb
redhillonrails_core-1.2.0 spec/table_definition_spec.rb