Skip to content

Commit

Permalink
Merge pull request #943 from guialbuk/fix-933
Browse files Browse the repository at this point in the history
Fix #tables deprecation in Rails 5.0  - Fixes #933
  • Loading branch information
Gui Albuk authored Apr 23, 2017
2 parents 9be4dd7 + a9c364b commit 7239d1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def join_table_option_correct?
end

def join_table_exists?
if connection.tables.include?(join_table_name)
if RailsShim.tables_and_views(connection).include?(join_table_name)
true
else
@failure_message = missing_table_message
Expand Down
8 changes: 8 additions & 0 deletions lib/shoulda/matchers/rails_shim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def self.simply_generate_validation_message(attribute, type, model_name, options
I18n.translate(primary_translation_key, translate_options)
end

def self.tables_and_views(connection)
if active_record_major_version >= 5
connection.data_sources
else
connection.tables
end
end

def self.active_record_major_version
::ActiveRecord::VERSION::MAJOR
end
Expand Down

0 comments on commit 7239d1f

Please sign in to comment.