Skip to content

Commit

Permalink
fix brittle rails 3.0 test/mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
jenseng committed Dec 14, 2012
1 parent e2cd5b1 commit a109c12
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/immigrant_test.rb
Expand Up @@ -20,7 +20,7 @@ def supports_primary_key? # AR <3.2
true
end
def primary_key(table)
table !~ /s_.*s\z/ ? 'id' : nil
table.to_s !~ /s_.*s\z/ ? 'id' : nil
end
end

Expand Down Expand Up @@ -143,19 +143,19 @@ class Fan < MockModel; end

test 'has_and_belongs_to_many should respect the join_table' do
class Author < MockModel
has_and_belongs_to_many :fans, :join_table => :lol_wuts
has_and_belongs_to_many :fans, :join_table => :lols_wuts
end
class Fan < MockModel; end

keys = Immigrant.infer_keys([], [Author, Fan]).first
assert_nothing_raised { keys.map { |key| key.to_ruby(:add) } }
assert_equal(
[foreign_key_definition(
'lol_wuts', 'authors',
'lols_wuts', 'authors',
:column => 'author_id', :primary_key => 'id', :dependent => nil
),
foreign_key_definition(
'lol_wuts', 'fans',
'lols_wuts', 'fans',
:column => 'fan_id', :primary_key => 'id', :dependent => nil
)],
keys
Expand Down

0 comments on commit a109c12

Please sign in to comment.