aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-10-03 06:49:27 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-10-03 06:49:27 +0900
commit444cf0d6424dcfaef009b9046b23c281791f0e9b (patch)
tree617ec8b219e57343aaeb611172a0d2c633589884 /activerecord/test/cases
parenta92fa726003880f5d28367459ddaf134c44b1697 (diff)
downloadrails-444cf0d6424dcfaef009b9046b23c281791f0e9b.tar.gz
rails-444cf0d6424dcfaef009b9046b23c281791f0e9b.tar.bz2
rails-444cf0d6424dcfaef009b9046b23c281791f0e9b.zip
Remove unnecessary `respond_to?(:indexes)` checking
Currently all adapters (postgresql, mysql2, sqlite3, oracle-enhanced, and sqlserver) implemented `indexes` and schema dumper expects implemented `indexes`. https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/schema_dumper.rb#L208 Therefore `respond_to?(:indexes)` checking is unnecessary.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/adapter_test.rb23
1 files changed, 9 insertions, 14 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb
index 8fa0645b0f..6862863443 100644
--- a/activerecord/test/cases/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
@@ -69,20 +69,15 @@ module ActiveRecord
def test_indexes
idx_name = "accounts_idx"
- if @connection.respond_to?(:indexes)
- indexes = @connection.indexes("accounts")
- assert indexes.empty?
-
- @connection.add_index :accounts, :firm_id, name: idx_name
- indexes = @connection.indexes("accounts")
- assert_equal "accounts", indexes.first.table
- assert_equal idx_name, indexes.first.name
- assert !indexes.first.unique
- assert_equal ["firm_id"], indexes.first.columns
- else
- warn "#{@connection.class} does not respond to #indexes"
- end
-
+ indexes = @connection.indexes("accounts")
+ assert indexes.empty?
+
+ @connection.add_index :accounts, :firm_id, name: idx_name
+ indexes = @connection.indexes("accounts")
+ assert_equal "accounts", indexes.first.table
+ assert_equal idx_name, indexes.first.name
+ assert !indexes.first.unique
+ assert_equal ["firm_id"], indexes.first.columns
ensure
@connection.remove_index(:accounts, name: idx_name) rescue nil
end