1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Using ActiveRecord::Base.connection is presumptuous. You must infer the home of the join table using the parent model. This allows developers to define HABTM relationships in other databases and still use the 'have_and_belong_to_many' matcher.

This commit is contained in:
Karle Durante 2012-09-18 15:31:17 -04:00 committed by Jason Draper
parent f6edb1589f
commit 41c763d276

View file

@ -243,7 +243,7 @@ module Shoulda # :nodoc:
def join_table_exists? def join_table_exists?
if @macro != :has_and_belongs_to_many || if @macro != :has_and_belongs_to_many ||
::ActiveRecord::Base.connection.tables.include?(join_table) model_class.connection.tables.include?(join_table)
true true
else else
@missing = "join table #{join_table} doesn't exist" @missing = "join table #{join_table} doesn't exist"