diff --git a/lib/shoulda/matchers/active_record/association_matcher.rb b/lib/shoulda/matchers/active_record/association_matcher.rb index cf596e07..f791ca57 100644 --- a/lib/shoulda/matchers/active_record/association_matcher.rb +++ b/lib/shoulda/matchers/active_record/association_matcher.rb @@ -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 diff --git a/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb b/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb index bb97e9bc..4dd54710 100644 --- a/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +++ b/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb @@ -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 diff --git a/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb b/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb index a9314612..882808f4 100644 --- a/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +++ b/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb @@ -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 diff --git a/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb b/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb index 1deaf2ff..0d0503c9 100644 --- a/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +++ b/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb @@ -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