Rename AssociationMatcher#join_table

Free up the `join_table` name so that users can specify a `join_table`
option when testing their associations.
This commit is contained in:
Jacob Morris 2014-07-23 16:38:48 -06:00 committed by Elliot Winkler
parent 9748869091
commit 26a35978f6
4 changed files with 10 additions and 10 deletions

View File

@ -823,7 +823,7 @@ module Shoulda
# @private
class AssociationMatcher
delegate :reflection, :model_class, :associated_class, :through?,
:join_table, :polymorphic?, to: :reflector
:join_table_name, :polymorphic?, to: :reflector
def initialize(macro, name)
@macro = macro

View File

@ -8,7 +8,7 @@ module Shoulda
alias :missing_option :failure_message
delegate :model_class, :join_table, :associated_class,
delegate :model_class, :join_table_name, :associated_class,
to: :association_matcher
delegate :connection, to: :model_class
@ -24,7 +24,7 @@ module Shoulda
end
def join_table_exists?
if connection.tables.include?(join_table)
if connection.tables.include?(join_table_name)
true
else
@failure_message = missing_table_message
@ -60,16 +60,16 @@ module Shoulda
end
def actual_join_table_columns
connection.columns(join_table).map(&:name)
connection.columns(join_table_name).map(&:name)
end
def missing_table_message
"join table #{join_table} doesn't exist"
"join table #{join_table_name} doesn't exist"
end
def missing_columns_message
missing = missing_columns.join(', ')
"join table #{join_table} missing #{column_label}: #{missing}"
"join table #{join_table_name} missing #{column_label}: #{missing}"
end
def column_label

View File

@ -24,15 +24,15 @@ module Shoulda
reflection.options[:through]
end
def join_table
join_table =
def join_table_name
join_table_name =
if has_and_belongs_to_many_name_table_name
has_and_belongs_to_many_name_table_name
else
reflection.join_table
end
join_table.to_s
join_table_name.to_s
end
def association_relation

View File

@ -4,7 +4,7 @@ module Shoulda
module AssociationMatchers
# @private
class ModelReflector
delegate :associated_class, :through?, :join_table,
delegate :associated_class, :through?, :join_table_name,
:association_relation, :polymorphic?, :foreign_key,
:association_foreign_key, to: :reflection