rails 5: fix several deprecation warnings

Change-Id: I43a3a36da77d19e81257fb923b34e431f3d6cbfa
Reviewed-on: https://gerrit.instructure.com/104952
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2017-03-13 16:08:22 -06:00
parent 1b411ccef9
commit d74ccdd308
10 changed files with 13 additions and 13 deletions

View File

@ -712,7 +712,7 @@ class CalendarEventsApiController < ApplicationController
calendar.add_event(ics_event) if ics_event
end
render :text => calendar.to_ical
render plain: calendar.to_ical
end
format.atom do
feed = Atom::Feed.new do |f|

View File

@ -80,7 +80,7 @@ class AccountNotification < ActiveRecord::Base
end
end
roles = user.enrollments.shard(user).active.uniq.pluck(:type)
roles = user.enrollments.shard(user).active.distinct.pluck(:type)
if roles == ['StudentEnrollment'] && !account.include_students_in_global_survey?
current.reject! { |announcement| announcement.required_account_service == 'account_survey_notifications' }

View File

@ -208,7 +208,7 @@ class AppointmentGroup < ActiveRecord::Base
codes[:full] &= restrict_to_codes
codes[:limited] &= restrict_to_codes
end
uniq.
distinct.
joins("JOIN #{AppointmentGroupContext.quoted_table_name} agc " \
"ON appointment_groups.id = agc.appointment_group_id " \
"LEFT JOIN #{AppointmentGroupSubContext.quoted_table_name} sc " \

View File

@ -679,13 +679,13 @@ class Attachment < ActiveRecord::Base
end
end
elsif method == :overwrite
atts.update_all(:replacement_attachment_id => self) # so we can find the new file in content links
atts.update_all(replacement_attachment_id: self.id) # so we can find the new file in content links
copy_access_attributes!(atts) unless atts.empty?
atts.each do |a|
# update content tags to refer to the new file
ContentTag.where(:content_id => a, :content_type => 'Attachment').update_all(:content_id => self)
ContentTag.where(:content_id => a, :content_type => 'Attachment').update_all(content_id: self.id)
# update replacement pointers pointing at the overwritten file
context.attachments.where(:replacement_attachment_id => a).update_all(:replacement_attachment_id => self)
context.attachments.where(:replacement_attachment_id => a).update_all(replacement_attachment_id: self.id)
# delete the overwritten file (unless the caller is queueing them up)
a.destroy unless opts[:caller_will_destroy]
deleted_attachments << a

View File

@ -293,7 +293,7 @@ class CalendarEvent < ActiveRecord::Base
end
def cache_child_event_ranges!
events = child_events(true)
events = CANVAS_RAILS4_2 ? child_events(true) : child_events.reload
if events.present?
CalendarEvent.where(:id => self).

View File

@ -108,7 +108,7 @@ class ConversationMessage < ActiveRecord::Base
end
def after_participants_created_broadcast
conversation_message_participants(true) # reload this association so we get latest data
CANVAS_RAILS4_2 ? conversation_message_participants(true) : conversation_message_participants.reload # reload this association so we get latest data
@re_send_message = true
broadcast_notifications
queue_create_stream_items

View File

@ -1679,7 +1679,7 @@ class User < ActiveRecord::Base
current_and_concluded.
where(user_id: self).
joins(:course).
uniq.
distinct.
pluck(:account_id)
longest_chain = [in_root_account]

View File

@ -645,7 +645,7 @@ ActiveRecord::Relation.class_eval do
order_values.any? ||
group_values.any? ||
select_values.to_s =~ /DISTINCT/i ||
uniq_value ||
distinct_value ||
select_values_necessitate_temp_table?
end
private :find_in_batches_needs_temp_table?

View File

@ -89,7 +89,7 @@ module DatesOverridable
Shard.partition_by_shard(assignments) do |shard_assignments|
Enrollment.where(course_id: shard_assignments.map(&:context), user_id: user).
active.
uniq.
distinct.
# duplicate the subquery logic of ObserverEnrollment.observed_users, where it verifies the observee exists
where("associated_user_id IS NULL OR EXISTS (
SELECT 1 FROM #{Enrollment.quoted_table_name} e2

View File

@ -774,7 +774,7 @@ class MessageableUser
def uncached_messageable_groups
fully_visible_scope = GroupMembership.
select("group_memberships.group_id AS group_id").
uniq.
distinct.
joins(:user, :group).
where(:workflow_state => 'accepted').
where("groups.workflow_state<>'deleted'").
@ -783,7 +783,7 @@ class MessageableUser
section_visible_scope = GroupMembership.
select("group_memberships.group_id AS group_id").
uniq.
distinct.
joins(:user, :group).
joins(<<-SQL).
INNER JOIN #{Enrollment.quoted_table_name} ON