use Rails.version check instead of CANVAS_RAILS variable
refs DE-523 Change-Id: I7baff2f4a6dee7beb518c6d1151a3027a7572f57 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/287809 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> QA-Review: Aaron Ogata <aogata@instructure.com> Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
parent
641d0523f1
commit
9098145ff5
|
@ -46,7 +46,7 @@ module Auditors::ActiveRecord
|
||||||
log "*" * 80
|
log "*" * 80
|
||||||
end
|
end
|
||||||
unless Rails.env.test?
|
unless Rails.env.test?
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Messages
|
||||||
log "Done. Bye!"
|
log "Done. Bye!"
|
||||||
log "*" * 80
|
log "*" * 80
|
||||||
unless Rails.env.test?
|
unless Rails.env.test?
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Quizzes::QuizSubmissionEventPartitioner
|
||||||
log "Done. Bye!"
|
log "Done. Bye!"
|
||||||
log "*" * 80
|
log "*" * 80
|
||||||
unless in_migration || Rails.env.test?
|
unless in_migration || Rails.env.test?
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
|
@ -37,7 +37,7 @@ class SimplyVersioned::Partitioner
|
||||||
log "Done. Bye!"
|
log "Done. Bye!"
|
||||||
log "*" * 80
|
log "*" * 80
|
||||||
unless Rails.env.test?
|
unless Rails.env.test?
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
|
@ -400,7 +400,7 @@ class StreamItem < ActiveRecord::Base
|
||||||
StreamItem.vacuum
|
StreamItem.vacuum
|
||||||
StreamItemInstance.vacuum
|
StreamItemInstance.vacuum
|
||||||
unless Rails.env.test?
|
unless Rails.env.test?
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
ActiveRecord::Base.connection_pool.current_pool.disconnect!
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
|
@ -23,5 +23,5 @@ class UnshardedRecord < ::ActiveRecord::Base
|
||||||
self.abstract_class = true
|
self.abstract_class = true
|
||||||
|
|
||||||
# This line is conditional just so if it is eager-loaded nothing breaks
|
# This line is conditional just so if it is eager-loaded nothing breaks
|
||||||
self.shard_category = :unsharded if CANVAS_RAILS6_0
|
self.shard_category = :unsharded if Rails.version < "6.1"
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,7 +130,7 @@ module CanvasRails
|
||||||
Canvas::Plugins::DefaultPlugins.apply_all
|
Canvas::Plugins::DefaultPlugins.apply_all
|
||||||
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = true
|
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = true
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
# On rails 6.1, this comes from switchman; on rails 6.0 canvas provides it
|
# On rails 6.1, this comes from switchman; on rails 6.0 canvas provides it
|
||||||
require_relative "#{__dir__}/../app/models/unsharded_record.rb"
|
require_relative "#{__dir__}/../app/models/unsharded_record.rb"
|
||||||
Switchman::UnshardedRecord = UnshardedRecord
|
Switchman::UnshardedRecord = UnshardedRecord
|
||||||
|
|
|
@ -610,7 +610,7 @@ class ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.current_xlog_location
|
def self.current_xlog_location
|
||||||
Shard.current(send(CANVAS_RAILS6_0 ? :shard_category : :connection_classes)).database_server.unguard do
|
Shard.current(send(Rails.version < "6.1" ? :shard_category : :connection_classes)).database_server.unguard do
|
||||||
GuardRail.activate(:primary) do
|
GuardRail.activate(:primary) do
|
||||||
if Rails.env.test? ? in_transaction_in_test? : connection.open_transactions > 0
|
if Rails.env.test? ? in_transaction_in_test? : connection.open_transactions > 0
|
||||||
raise "don't run current_xlog_location in a transaction"
|
raise "don't run current_xlog_location in a transaction"
|
||||||
|
@ -709,7 +709,7 @@ class ActiveRecord::Base
|
||||||
changes_applied
|
changes_applied
|
||||||
end
|
end
|
||||||
|
|
||||||
unless CANVAS_RAILS6_0
|
if Rails.version >= "6.1"
|
||||||
def self.override_db_configs(override)
|
def self.override_db_configs(override)
|
||||||
configurations.configs_for.each do |config|
|
configurations.configs_for.each do |config|
|
||||||
config.instance_variable_set(:@configuration_hash, config.configuration_hash.merge(override).freeze)
|
config.instance_variable_set(:@configuration_hash, config.configuration_hash.merge(override).freeze)
|
||||||
|
@ -732,7 +732,7 @@ module UsefulFindInBatches
|
||||||
else
|
else
|
||||||
enum_for(:find_each, start: start, finish: finish, order: order, **kwargs) do
|
enum_for(:find_each, start: start, finish: finish, order: order, **kwargs) do
|
||||||
relation = self
|
relation = self
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
apply_limits(relation, start, finish).size
|
apply_limits(relation, start, finish).size
|
||||||
else
|
else
|
||||||
apply_limits(relation, start, finish, order).size
|
apply_limits(relation, start, finish, order).size
|
||||||
|
@ -746,7 +746,7 @@ module UsefulFindInBatches
|
||||||
relation = self
|
relation = self
|
||||||
unless block_given?
|
unless block_given?
|
||||||
return to_enum(:find_in_batches, start: start, finish: finish, order: order, batch_size: batch_size, **kwargs) do
|
return to_enum(:find_in_batches, start: start, finish: finish, order: order, batch_size: batch_size, **kwargs) do
|
||||||
total = if CANVAS_RAILS6_0
|
total = if Rails.version < "6.1"
|
||||||
apply_limits(relation, start, finish).size
|
apply_limits(relation, start, finish).size
|
||||||
else
|
else
|
||||||
apply_limits(relation, start, finish, order).size
|
apply_limits(relation, start, finish, order).size
|
||||||
|
@ -776,7 +776,7 @@ module UsefulFindInBatches
|
||||||
if strategy == :id
|
if strategy == :id
|
||||||
raise ArgumentError, "GROUP BY is incompatible with :id batches strategy" unless group_values.empty?
|
raise ArgumentError, "GROUP BY is incompatible with :id batches strategy" unless group_values.empty?
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
return activate { |r| r.call_super(:in_batches, UsefulFindInBatches, start: start, finish: finish, **kwargs, &block) }
|
return activate { |r| r.call_super(:in_batches, UsefulFindInBatches, start: start, finish: finish, **kwargs, &block) }
|
||||||
else
|
else
|
||||||
return activate { |r| r.call_super(:in_batches, UsefulFindInBatches, start: start, finish: finish, order: order, **kwargs, &block) }
|
return activate { |r| r.call_super(:in_batches, UsefulFindInBatches, start: start, finish: finish, order: order, **kwargs, &block) }
|
||||||
|
@ -825,7 +825,7 @@ module UsefulFindInBatches
|
||||||
|
|
||||||
def in_batches_with_cursor(of: 1000, start: nil, finish: nil, order: :asc, load: false)
|
def in_batches_with_cursor(of: 1000, start: nil, finish: nil, order: :asc, load: false)
|
||||||
klass.transaction do
|
klass.transaction do
|
||||||
relation = if CANVAS_RAILS6_0
|
relation = if Rails.version < "6.1"
|
||||||
apply_limits(clone, start, finish)
|
apply_limits(clone, start, finish)
|
||||||
else
|
else
|
||||||
apply_limits(clone, start, finish, order)
|
apply_limits(clone, start, finish, order)
|
||||||
|
@ -869,7 +869,7 @@ module UsefulFindInBatches
|
||||||
limited_query = limit(0).to_sql
|
limited_query = limit(0).to_sql
|
||||||
|
|
||||||
relation = self
|
relation = self
|
||||||
relation_for_copy = if CANVAS_RAILS6_0
|
relation_for_copy = if Rails.version < "6.1"
|
||||||
apply_limits(relation, start, finish)
|
apply_limits(relation, start, finish)
|
||||||
else
|
else
|
||||||
apply_limits(relation, start, finish, order)
|
apply_limits(relation, start, finish, order)
|
||||||
|
@ -967,7 +967,7 @@ module UsefulFindInBatches
|
||||||
# and yields the objects in batches in the same order as the scope specified
|
# and yields the objects in batches in the same order as the scope specified
|
||||||
# so the DB connection can be fully recycled during each block.
|
# so the DB connection can be fully recycled during each block.
|
||||||
def in_batches_with_pluck_ids(of: 1000, start: nil, finish: nil, order: :asc, load: false)
|
def in_batches_with_pluck_ids(of: 1000, start: nil, finish: nil, order: :asc, load: false)
|
||||||
relation = if CANVAS_RAILS6_0
|
relation = if Rails.version < "6.1"
|
||||||
apply_limits(self, start, finish)
|
apply_limits(self, start, finish)
|
||||||
else
|
else
|
||||||
apply_limits(self, start, finish, order)
|
apply_limits(self, start, finish, order)
|
||||||
|
@ -999,7 +999,7 @@ module UsefulFindInBatches
|
||||||
group, or order)."
|
group, or order)."
|
||||||
end
|
end
|
||||||
|
|
||||||
relation = if CANVAS_RAILS6_0
|
relation = if Rails.version < "6.1"
|
||||||
apply_limits(self, start, finish)
|
apply_limits(self, start, finish)
|
||||||
else
|
else
|
||||||
apply_limits(self, start, finish, order)
|
apply_limits(self, start, finish, order)
|
||||||
|
@ -1144,7 +1144,7 @@ module UsefulBatchEnumerator
|
||||||
@relation.send(:_substitute_values, updates).any? do |(attr, update)|
|
@relation.send(:_substitute_values, updates).any? do |(attr, update)|
|
||||||
found_match = false
|
found_match = false
|
||||||
predicates.any? do |pred|
|
predicates.any? do |pred|
|
||||||
next unless pred.is_a?(Arel::Nodes::Binary) || (!CANVAS_RAILS6_0 && pred.is_a?(Arel::Nodes::HomogeneousIn))
|
next unless pred.is_a?(Arel::Nodes::Binary) || (Rails.version >= "6.1" && pred.is_a?(Arel::Nodes::HomogeneousIn))
|
||||||
next unless pred.left == attr
|
next unless pred.left == attr
|
||||||
|
|
||||||
found_match = true
|
found_match = true
|
||||||
|
@ -1170,7 +1170,7 @@ module UsefulBatchEnumerator
|
||||||
pred.right.exclude?(update)
|
pred.right.exclude?(update)
|
||||||
elsif pred.instance_of?(Arel::Nodes::NotIn) && pred.right.is_a?(Array)
|
elsif pred.instance_of?(Arel::Nodes::NotIn) && pred.right.is_a?(Array)
|
||||||
pred.right.include?(update)
|
pred.right.include?(update)
|
||||||
elsif !CANVAS_RAILS6_0 && pred.instance_of?(Arel::Nodes::HomogeneousIn)
|
elsif Rails.version >= "6.1" && pred.instance_of?(Arel::Nodes::HomogeneousIn)
|
||||||
case pred.type
|
case pred.type
|
||||||
when :in
|
when :in
|
||||||
pred.right.map(&:value).exclude?(update.value.value)
|
pred.right.map(&:value).exclude?(update.value.value)
|
||||||
|
@ -1368,7 +1368,7 @@ module UpdateAndDeleteWithJoins
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_all(updates, *args)
|
def update_all(updates, *args)
|
||||||
db = Shard.current(klass.send(CANVAS_RAILS6_0 ? :shard_category : :connection_classes)).database_server
|
db = Shard.current(klass.send(Rails.version < "6.1" ? :shard_category : :connection_classes)).database_server
|
||||||
if joins_values.empty?
|
if joins_values.empty?
|
||||||
if ::GuardRail.environment == db.guard_rail_environment
|
if ::GuardRail.environment == db.guard_rail_environment
|
||||||
return super
|
return super
|
||||||
|
@ -1618,7 +1618,7 @@ module Migrator
|
||||||
super.select(&:runnable?)
|
super.select(&:runnable?)
|
||||||
end
|
end
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
def execute_migration_in_transaction(migration, direct)
|
def execute_migration_in_transaction(migration, direct)
|
||||||
old_in_migration, ActiveRecord::Base.in_migration = ActiveRecord::Base.in_migration, true
|
old_in_migration, ActiveRecord::Base.in_migration = ActiveRecord::Base.in_migration, true
|
||||||
if defined?(Marginalia)
|
if defined?(Marginalia)
|
||||||
|
@ -1785,7 +1785,7 @@ ActiveRecord::Associations::CollectionAssociation.class_eval do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
module UnscopeCallbacks
|
module UnscopeCallbacks
|
||||||
def run_callbacks(kind)
|
def run_callbacks(kind)
|
||||||
return super if __callbacks[kind].empty?
|
return super if __callbacks[kind].empty?
|
||||||
|
@ -2002,7 +2002,7 @@ ActiveRecord::Relation.prepend(DontExplicitlyNameColumnsBecauseOfIgnores)
|
||||||
module PreserveShardAfterTransaction
|
module PreserveShardAfterTransaction
|
||||||
def after_transaction_commit(&block)
|
def after_transaction_commit(&block)
|
||||||
shards = Shard.send(:active_shards)
|
shards = Shard.send(:active_shards)
|
||||||
shards[CANVAS_RAILS6_0 ? :delayed_jobs : Delayed::Backend::ActiveRecord::AbstractJob] = Shard.current.delayed_jobs_shard if ::ActiveRecord::Migration.open_migrations.positive?
|
shards[Rails.version < "6.1" ? :delayed_jobs : Delayed::Backend::ActiveRecord::AbstractJob] = Shard.current.delayed_jobs_shard if ::ActiveRecord::Migration.open_migrations.positive?
|
||||||
super { Shard.activate(shards, &block) }
|
super { Shard.activate(shards, &block) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2051,7 +2051,7 @@ ActiveRecord::ConnectionAdapters::ConnectionPool.prepend(RestoreConnectionConnec
|
||||||
module MaxRuntimeConnectionPool
|
module MaxRuntimeConnectionPool
|
||||||
def max_runtime
|
def max_runtime
|
||||||
# TODO: Rails 6.1 uses a PoolConfig object instead
|
# TODO: Rails 6.1 uses a PoolConfig object instead
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
@spec.config[:max_runtime]
|
@spec.config[:max_runtime]
|
||||||
else
|
else
|
||||||
db_config.configuration_hash[:max_runtime]
|
db_config.configuration_hash[:max_runtime]
|
||||||
|
@ -2172,7 +2172,7 @@ module UserContentSerialization
|
||||||
end
|
end
|
||||||
ActiveRecord::Base.include(UserContentSerialization)
|
ActiveRecord::Base.include(UserContentSerialization)
|
||||||
|
|
||||||
unless CANVAS_RAILS6_0
|
if Rails.version >= "6.1"
|
||||||
# Hopefully this can be removed with https://github.com/rails/rails/commit/6beee45c3f071c6a17149be0fabb1697609edbe8
|
# Hopefully this can be removed with https://github.com/rails/rails/commit/6beee45c3f071c6a17149be0fabb1697609edbe8
|
||||||
# having made a released version of rails; if not bump the rails version in this comment and leave the comment to be revisited
|
# having made a released version of rails; if not bump the rails version in this comment and leave the comment to be revisited
|
||||||
# on the next rails bump
|
# on the next rails bump
|
||||||
|
|
|
@ -69,7 +69,7 @@ Delayed::Settings.queue = "canvas_queue"
|
||||||
Delayed::Settings.select_random_from_batch = -> { Setting.get("jobs_select_random", "false") == "true" }
|
Delayed::Settings.select_random_from_batch = -> { Setting.get("jobs_select_random", "false") == "true" }
|
||||||
Delayed::Settings.sleep_delay = -> { Setting.get("delayed_jobs_sleep_delay", "2.0").to_f }
|
Delayed::Settings.sleep_delay = -> { Setting.get("delayed_jobs_sleep_delay", "2.0").to_f }
|
||||||
Delayed::Settings.sleep_delay_stagger = -> { Setting.get("delayed_jobs_sleep_delay_stagger", "2.0").to_f }
|
Delayed::Settings.sleep_delay_stagger = -> { Setting.get("delayed_jobs_sleep_delay_stagger", "2.0").to_f }
|
||||||
Delayed::Settings.worker_procname_prefix = -> { "#{Shard.current(CANVAS_RAILS6_0 ? :delayed_jobs : Delayed::Backend::ActiveRecord::AbstractJob).id}~" }
|
Delayed::Settings.worker_procname_prefix = -> { "#{Shard.current(Rails.version < "6.1" ? :delayed_jobs : Delayed::Backend::ActiveRecord::AbstractJob).id}~" }
|
||||||
Delayed::Settings.worker_health_check_type = Delayed::CLI.instance&.config&.dig("health_check", "type")&.to_sym || :none
|
Delayed::Settings.worker_health_check_type = Delayed::CLI.instance&.config&.dig("health_check", "type")&.to_sym || :none
|
||||||
Delayed::Settings.worker_health_check_config = Delayed::CLI.instance&.config&.[]("health_check")
|
Delayed::Settings.worker_health_check_config = Delayed::CLI.instance&.config&.[]("health_check")
|
||||||
# transitional
|
# transitional
|
||||||
|
|
|
@ -21,7 +21,7 @@ if ENV["RAILS_DATABASE_ENVIRONMENT"]
|
||||||
GuardRail.activate!(ENV["RAILS_DATABASE_ENVIRONMENT"].to_sym)
|
GuardRail.activate!(ENV["RAILS_DATABASE_ENVIRONMENT"].to_sym)
|
||||||
end
|
end
|
||||||
if ENV["RAILS_DATABASE_USER"]
|
if ENV["RAILS_DATABASE_USER"]
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
GuardRail.apply_config!(username: ENV["RAILS_DATABASE_USER"], password: nil)
|
GuardRail.apply_config!(username: ENV["RAILS_DATABASE_USER"], password: nil)
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.override_db_configs(username: ENV["RAILS_DATABASE_USER"], password: nil)
|
ActiveRecord::Base.override_db_configs(username: ENV["RAILS_DATABASE_USER"], password: nil)
|
||||||
|
|
|
@ -177,7 +177,7 @@ module PostgreSQLAdapterExtensions
|
||||||
[index_name, index_type, index_columns, index_options, algorithm, using]
|
[index_name, index_type, index_columns, index_options, algorithm, using]
|
||||||
end
|
end
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
def remove_index(table_name, options = {})
|
def remove_index(table_name, options = {})
|
||||||
table = ActiveRecord::ConnectionAdapters::PostgreSQL::Utils.extract_schema_qualified_name(table_name.to_s)
|
table = ActiveRecord::ConnectionAdapters::PostgreSQL::Utils.extract_schema_qualified_name(table_name.to_s)
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ module PostgreSQLAdapterExtensions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
def index_name_for_remove(table_name, options = {})
|
def index_name_for_remove(table_name, options = {})
|
||||||
return options[:name] if can_remove_index_by_name?(options)
|
return options[:name] if can_remove_index_by_name?(options)
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ module ReferenceDefinitionExtensions
|
||||||
end
|
end
|
||||||
|
|
||||||
if index
|
if index
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
table.index(column_names, index_options)
|
table.index(column_names, index_options)
|
||||||
else
|
else
|
||||||
table.index(column_names, **index_options(table.name))
|
table.index(column_names, **index_options(table.name))
|
||||||
|
@ -445,7 +445,7 @@ module SchemaStatementsExtensions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::SchemaCreation.prepend(SchemaCreationExtensions)
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::SchemaCreation.prepend(SchemaCreationExtensions)
|
||||||
else
|
else
|
||||||
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaCreation.prepend(SchemaCreationExtensions)
|
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaCreation.prepend(SchemaCreationExtensions)
|
||||||
|
|
|
@ -310,7 +310,7 @@ module CanvasSecurity
|
||||||
if db_hash.nil? || overwrite
|
if db_hash.nil? || overwrite
|
||||||
begin
|
begin
|
||||||
settings_store.set("encryption_key_hash", Digest::SHA1.hexdigest(encryption_key))
|
settings_store.set("encryption_key_hash", Digest::SHA1.hexdigest(encryption_key))
|
||||||
rescue *[ActiveRecord::StatementInvalid, (CANVAS_RAILS6_0 ? nil : ActiveRecord::ConnectionNotEstablished)].compact
|
rescue *[ActiveRecord::StatementInvalid, (Rails.version < "6.1" ? nil : ActiveRecord::ConnectionNotEstablished)].compact
|
||||||
# the db may not exist yet
|
# the db may not exist yet
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -762,7 +762,7 @@ describe ActiveRecord::Migration::CommandRecorder do
|
||||||
[:add_index, [:accounts, :id, { if_not_exists: true }]],
|
[:add_index, [:accounts, :id, { if_not_exists: true }]],
|
||||||
[:add_foreign_key, [:enrollments, :users, { if_not_exists: true }]],
|
[:add_foreign_key, [:enrollments, :users, { if_not_exists: true }]],
|
||||||
[:add_column, [:courses, :id, :integer, { limit: 8, if_not_exists: true }], nil],
|
[:add_column, [:courses, :id, :integer, { limit: 8, if_not_exists: true }], nil],
|
||||||
(if CANVAS_RAILS6_0
|
(if Rails.version < "6.1"
|
||||||
[:remove_index, [:accounts, { algorithm: :concurrently, column: :course_template_id, if_exists: true }]]
|
[:remove_index, [:accounts, { algorithm: :concurrently, column: :course_template_id, if_exists: true }]]
|
||||||
else
|
else
|
||||||
[:remove_index, [:accounts, :course_template_id, { algorithm: :concurrently, if_exists: true }], nil]
|
[:remove_index, [:accounts, :course_template_id, { algorithm: :concurrently, if_exists: true }], nil]
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe I18n do
|
||||||
# HINT: if this spec fails, run `rake i18n:generate_js`...
|
# HINT: if this spec fails, run `rake i18n:generate_js`...
|
||||||
# it probably means you added a format or a new language
|
# it probably means you added a format or a new language
|
||||||
it "is up-to-date" do
|
it "is up-to-date" do
|
||||||
skip("Rails 6.0 specific") unless CANVAS_RAILS6_0
|
skip("Rails 6.0 specific") if Rails.version >= "6.1"
|
||||||
|
|
||||||
file_contents = File.read("public/javascripts/translations/_core_en.js")
|
file_contents = File.read("public/javascripts/translations/_core_en.js")
|
||||||
translations = I18n.backend.send(:translations)[:en].slice(*I18nTasks::Utils::CORE_KEYS)
|
translations = I18n.backend.send(:translations)[:en].slice(*I18nTasks::Utils::CORE_KEYS)
|
||||||
|
|
|
@ -884,7 +884,7 @@ end
|
||||||
describe ActiveRecord::ConnectionAdapters::ConnectionPool do
|
describe ActiveRecord::ConnectionAdapters::ConnectionPool do
|
||||||
# create a private pool, with the same config as the regular pool, but ensure
|
# create a private pool, with the same config as the regular pool, but ensure
|
||||||
# max_runtime is set
|
# max_runtime is set
|
||||||
if CANVAS_RAILS6_0
|
if Rails.version < "6.1"
|
||||||
let(:spec) do
|
let(:spec) do
|
||||||
ActiveRecord::ConnectionAdapters::ConnectionSpecification.new(
|
ActiveRecord::ConnectionAdapters::ConnectionSpecification.new(
|
||||||
"spec",
|
"spec",
|
||||||
|
|
|
@ -43,7 +43,6 @@ describe "i18n js" do
|
||||||
|
|
||||||
context "locales" do
|
context "locales" do
|
||||||
it "pulls in core translations for all locales" do
|
it "pulls in core translations for all locales" do
|
||||||
skip("Rails 6.0 specific") unless CANVAS_RAILS6_0
|
|
||||||
skip("USE_OPTIMIZED_JS=true") unless ENV["USE_OPTIMIZED_JS"]
|
skip("USE_OPTIMIZED_JS=true") unless ENV["USE_OPTIMIZED_JS"]
|
||||||
skip("RAILS_LOAD_ALL_LOCALES=true") unless ENV["RAILS_LOAD_ALL_LOCALES"]
|
skip("RAILS_LOAD_ALL_LOCALES=true") unless ENV["RAILS_LOAD_ALL_LOCALES"]
|
||||||
core_keys = I18nTasks::Utils::CORE_KEYS
|
core_keys = I18nTasks::Utils::CORE_KEYS
|
||||||
|
|
|
@ -73,9 +73,9 @@ module TestDatabaseUtils
|
||||||
private
|
private
|
||||||
|
|
||||||
def each_connection(&block)
|
def each_connection(&block)
|
||||||
::Shard.with_each_shard(CANVAS_RAILS6_0 ? ::Shard.categories : ::Shard.sharded_models) do
|
::Shard.with_each_shard(Rails.version < "6.1" ? ::Shard.categories : ::Shard.sharded_models) do
|
||||||
models = ::ActiveRecord::Base.descendants
|
models = ::ActiveRecord::Base.descendants
|
||||||
models.reject! { |m| CANVAS_RAILS6_0 ? m.shard_category == :unsharded : m.connection_classes == [::Switchman::UnshardedRecord] } unless ::Shard.current.default?
|
models.reject! { |m| Rails.version < "6.1" ? m.shard_category == :unsharded : m.connection_classes == [::Switchman::UnshardedRecord] } unless ::Shard.current.default?
|
||||||
model_connections = models.map(&:connection).uniq
|
model_connections = models.map(&:connection).uniq
|
||||||
model_connections.each(&block)
|
model_connections.each(&block)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue