Some little rails 7.0 spec fixes

Change-Id: Id62960940fbc59563668be147888a8696ccbbdbe
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/293448
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
This commit is contained in:
Jacob Burroughs 2022-06-07 17:46:01 -05:00
parent b5e799022c
commit 0d642c7506
13 changed files with 33 additions and 22 deletions

View File

@ -32,6 +32,6 @@ module GlobalNavigationHelper
private
def render_icon_partial(base, icon)
render "shared/svg/#{base}svg_icon_#{icon}.svg"
render partial: "shared/svg/#{base}svg_icon_#{icon}", formats: [:svg]
end
end

View File

@ -114,7 +114,7 @@
<%= render :partial => 'shared/footer_links' %>
</div>
<a href="http://www.instructure.com" class="ic-Login-footer__logo-link" aria-label="By Instructure">
<%= render "login/canvas/instructure_logo.svg" %>
<%= render partial: "login/canvas/instructure_logo", formats: [:svg] %>
</a>
</footer>
</div> <!-- end ic-Login__content -->

View File

@ -35,7 +35,7 @@
<tr class="login<%= ' blank' unless pseudonym %>" <%= raw %Q(style="display: none") unless pseudonym %>>
<td class="sso-icon" <%= raw %Q(data-pseudonym-id="#{pseudonym.id}") if pseudonym %>>
<% if lookup_context.template_exists?("shared/svg/_svg_icon_#{pseudonym.try(:authentication_provider).try(:auth_type)}.svg") %>
<%= render(partial: "shared/svg/svg_icon_#{pseudonym.authentication_provider.auth_type}.svg") %>
<%= render(partial: "shared/svg/svg_icon_#{pseudonym.authentication_provider.auth_type}", formats: [:svg]) %>
<span class="screenreader-only">
<%= t("This login is for %{provider}", provider: pseudonym.authentication_provider.class.display_name) %>
</span>

View File

@ -746,10 +746,16 @@ class ActiveRecord::Base
self.updated_at = Time.now.utc if touch
if new_record?
self.created_at = updated_at if touch
self.id = self.class._insert_record(attributes_with_values(Rails.version < "7.0" ? attribute_names_for_partial_writes : attribute_names_for_partial_inserts))
self.id = self.class._insert_record(
attributes_with_values(Rails.version < "7.0" ? attribute_names_for_partial_writes : attribute_names_for_partial_inserts)
.transform_values { |attr| attr.is_a?(ActiveModel::Attribute) ? attr.value : attr }
)
@new_record = false
else
update_columns(attributes_with_values(Rails.version < "7.0" ? attribute_names_for_partial_writes : attribute_names_for_partial_updates))
update_columns(
attributes_with_values(Rails.version < "7.0" ? attribute_names_for_partial_writes : attribute_names_for_partial_updates)
.transform_values { |attr| attr.is_a?(ActiveModel::Attribute) ? attr.value : attr }
)
end
changes_applied
end
@ -1164,7 +1170,7 @@ module UsefulBatchEnumerator
found_match = true
raw_update = update.value.value_before_type_cast
raw_update = update.value.is_a?(ActiveModel::Attribute) ? update.value.value_before_type_cast : update.value
# we want to check exact class here, not ancestry, since we want to ignore
# subclasses we don't understand
if pred.instance_of?(Arel::Nodes::Equality)
@ -1172,15 +1178,16 @@ module UsefulBatchEnumerator
elsif pred.instance_of?(Arel::Nodes::NotEqual)
update == pred.right
elsif pred.instance_of?(Arel::Nodes::GreaterThanOrEqual)
raw_update < pred.right.value.value_before_type_cast
raw_update < (pred.right.value.is_a?(ActiveModel::Attribute) ? pred.right.value.value_before_type_cast : pred.right.value)
elsif pred.instance_of?(Arel::Nodes::GreaterThan)
raw_update <= pred.right.value.value_before_type_cast
raw_update <= (pred.right.value.is_a?(ActiveModel::Attribute) ? pred.right.value.value_before_type_cast : pred.right.value)
elsif pred.instance_of?(Arel::Nodes::LessThanOrEqual)
raw_update >= pred.right.value.value_before_type_cast
raw_update >= (pred.right.value.is_a?(ActiveModel::Attribute) ? pred.right.value.value_before_type_cast : pred.right.value)
elsif pred.instance_of?(Arel::Nodes::LessThan)
raw_update > pred.right.value.value_before_type_cast
raw_update > (pred.right.value.is_a?(ActiveModel::Attribute) ? pred.right.value.value_before_type_cast : pred.right.value)
elsif pred.instance_of?(Arel::Nodes::Between)
raw_update < pred.right.left.value.value_before_type_cast || raw_update > pred.right.right.value.value_before_type_cast
raw_update < (pred.right.left.value.is_a?(ActiveModel::Attribute) ? pred.right.left.value.value_before_type_cast : pred.right.left.value) ||
raw_update > (pred.right.right.value.is_a?(ActiveModel::Attribute) ? pred.right.right.value.value_before_type_cast : pred.right.right.value)
elsif pred.instance_of?(Arel::Nodes::In) && pred.right.is_a?(Array)
pred.right.exclude?(update)
elsif pred.instance_of?(Arel::Nodes::NotIn) && pred.right.is_a?(Array)
@ -1188,9 +1195,9 @@ module UsefulBatchEnumerator
elsif pred.instance_of?(Arel::Nodes::HomogeneousIn)
case pred.type
when :in
pred.right.map(&:value).exclude?(update.value.value)
pred.right.map(&:value).exclude?(update.value.is_a?(ActiveModel::Attribute) ? update.value.value : update.value)
when :notin
pred.right.map(&:value).include?(update.value.value)
pred.right.map(&:value).include?(update.value.is_a?(ActiveModel::Attribute) ? update.value.value : update.value)
end
end
end && found_match

View File

@ -890,7 +890,11 @@ describe ActiveRecord::ConnectionAdapters::ConnectionPool do
"primary",
ActiveRecord::Base.configurations.configs_for(env_name: "test", name: "primary").configuration_hash.merge(max_runtime: 30)
)
ActiveRecord::ConnectionAdapters::PoolConfig.new(ActiveRecord::Base, config)
if Rails.version < "7.0"
ActiveRecord::ConnectionAdapters::PoolConfig.new(ActiveRecord::Base, config)
else
ActiveRecord::ConnectionAdapters::PoolConfig.new(ActiveRecord::Base, config, :primary, :test)
end
end
let(:pool) { ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec) }

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "accounts/settings.html.erb" do
describe "accounts/settings" do
before do
assign(:account_roles, [])
assign(:course_roles, [])

View File

@ -21,7 +21,7 @@
require "spec_helper"
require_relative "../views_helper"
describe "assignments/_submission_sidebar.html.erb" do
describe "assignments/_submission_sidebar" do
let(:course) { Course.create! }
let(:student) { User.create! }
let(:teacher) { User.create! }

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "communication_channels/confirm.html.erb" do
describe "communication_channels/confirm" do
before do
user_factory
assign(:user, @user)

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "courses/settings.html.erb" do
describe "courses/settings" do
before :once do
@subaccount = account_model(parent_account: Account.default, name: "subaccount")
@other_subaccount = account_model(parent_account: Account.default)

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "courses/_settings_sidebar.html.erb" do
describe "courses/_settings_sidebar" do
before do
course_with_teacher(active_all: true)
@course.sis_source_id = "so_special_sis_id"

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "courses/statistics.html.erb" do
describe "courses/statistics" do
before do
course_with_teacher(active_all: true)
assign(:range_start, Date.parse("Jan 1 2000"))

View File

@ -21,7 +21,7 @@
require_relative "../../../spec_helper"
require_relative "../../views_helper"
describe "login/canvas/new.html.erb" do
describe "login/canvas/new" do
before do
assign(:domain_root_account, Account.default)
end

View File

@ -20,7 +20,7 @@
require_relative "../views_helper"
describe "users/_logins.html.erb" do
describe "users/_logins" do
describe "sis_source_id edit box" do
before do
user_with_pseudonym