Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix habtm matcher to support symbols for join_table #1323

Merged
merged 1 commit into from Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/shoulda/matchers/active_record/association_matcher.rb
Expand Up @@ -920,21 +920,21 @@ def have_one(name)
# asserts that the table you're referring to actually exists.
#
# class Person < ActiveRecord::Base
# has_and_belongs_to_many :issues, join_table: 'people_tickets'
# has_and_belongs_to_many :issues, join_table: :people_tickets
# end
#
# # RSpec
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:issues).
# join_table('people_tickets')
# join_table(:people_tickets)
# end
# end
#
# # Minitest (Shoulda)
# class PersonTest < ActiveSupport::TestCase
# should have_and_belong_to_many(:issues).
# join_table('people_tickets')
# join_table(:people_tickets)
# end
#
# ##### validate
Expand Down
Expand Up @@ -29,7 +29,7 @@ def join_table_option_correct?
if option_verifier.correct_for_string?(:join_table, options[:join_table_name])
true
else
@failure_message = "#{name} should use '#{options[:join_table_name]}' for :join_table option"
@failure_message = "#{name} should use #{options[:join_table_name].inspect} for :join_table option"
false
end
else
Expand All @@ -38,7 +38,7 @@ def join_table_option_correct?
end

def join_table_exists?
if RailsShim.tables_and_views(connection).include?(join_table_name)
if RailsShim.tables_and_views(connection).include?(join_table_name.to_s)
true
else
@failure_message = missing_table_message
Expand Down