Fix #tables deprecation in Rails 5.0 and keep compatibility with Rails 4.x
This commit is contained in:
parent
90c0728cf7
commit
a6d09aa5de
|
@ -38,7 +38,7 @@ module Shoulda
|
|||
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
|
||||
|
|
|
@ -55,6 +55,14 @@ module Shoulda
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue