Skip to content

Commit d74ccdd

Browse files
committed
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>
1 parent 1b411cc commit d74ccdd

10 files changed

Lines changed: 13 additions & 13 deletions

File tree

app/controllers/calendar_events_api_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def public_feed
712712
calendar.add_event(ics_event) if ics_event
713713
end
714714

715-
render :text => calendar.to_ical
715+
render plain: calendar.to_ical
716716
end
717717
format.atom do
718718
feed = Atom::Feed.new do |f|

app/models/account_notification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def self.for_user_and_account(user, account)
8080
end
8181
end
8282

83-
roles = user.enrollments.shard(user).active.uniq.pluck(:type)
83+
roles = user.enrollments.shard(user).active.distinct.pluck(:type)
8484

8585
if roles == ['StudentEnrollment'] && !account.include_students_in_global_survey?
8686
current.reject! { |announcement| announcement.required_account_service == 'account_survey_notifications' }

app/models/appointment_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def sub_context_codes
208208
codes[:full] &= restrict_to_codes
209209
codes[:limited] &= restrict_to_codes
210210
end
211-
uniq.
211+
distinct.
212212
joins("JOIN #{AppointmentGroupContext.quoted_table_name} agc " \
213213
"ON appointment_groups.id = agc.appointment_group_id " \
214214
"LEFT JOIN #{AppointmentGroupSubContext.quoted_table_name} sc " \

app/models/attachment.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,13 @@ def handle_duplicates(method, opts = {})
679679
end
680680
end
681681
elsif method == :overwrite
682-
atts.update_all(:replacement_attachment_id => self) # so we can find the new file in content links
682+
atts.update_all(replacement_attachment_id: self.id) # so we can find the new file in content links
683683
copy_access_attributes!(atts) unless atts.empty?
684684
atts.each do |a|
685685
# update content tags to refer to the new file
686-
ContentTag.where(:content_id => a, :content_type => 'Attachment').update_all(:content_id => self)
686+
ContentTag.where(:content_id => a, :content_type => 'Attachment').update_all(content_id: self.id)
687687
# update replacement pointers pointing at the overwritten file
688-
context.attachments.where(:replacement_attachment_id => a).update_all(:replacement_attachment_id => self)
688+
context.attachments.where(:replacement_attachment_id => a).update_all(replacement_attachment_id: self.id)
689689
# delete the overwritten file (unless the caller is queueing them up)
690690
a.destroy unless opts[:caller_will_destroy]
691691
deleted_attachments << a

app/models/calendar_event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def sync_parent_event
293293
end
294294

295295
def cache_child_event_ranges!
296-
events = child_events(true)
296+
events = CANVAS_RAILS4_2 ? child_events(true) : child_events.reload
297297

298298
if events.present?
299299
CalendarEvent.where(:id => self).

app/models/conversation_message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def self.preload_latest(conversation_participants, author=nil)
108108
end
109109

110110
def after_participants_created_broadcast
111-
conversation_message_participants(true) # reload this association so we get latest data
111+
CANVAS_RAILS4_2 ? conversation_message_participants(true) : conversation_message_participants.reload # reload this association so we get latest data
112112
@re_send_message = true
113113
broadcast_notifications
114114
queue_create_stream_items

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ def common_account_chain(in_root_account)
16791679
current_and_concluded.
16801680
where(user_id: self).
16811681
joins(:course).
1682-
uniq.
1682+
distinct.
16831683
pluck(:account_id)
16841684

16851685
longest_chain = [in_root_account]

config/initializers/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def find_in_batches_needs_temp_table?
645645
order_values.any? ||
646646
group_values.any? ||
647647
select_values.to_s =~ /DISTINCT/i ||
648-
uniq_value ||
648+
distinct_value ||
649649
select_values_necessitate_temp_table?
650650
end
651651
private :find_in_batches_needs_temp_table?

lib/dates_overridable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def self.precache_enrollments_for_multiple_assignments(assignments, user)
8989
Shard.partition_by_shard(assignments) do |shard_assignments|
9090
Enrollment.where(course_id: shard_assignments.map(&:context), user_id: user).
9191
active.
92-
uniq.
92+
distinct.
9393
# duplicate the subquery logic of ObserverEnrollment.observed_users, where it verifies the observee exists
9494
where("associated_user_id IS NULL OR EXISTS (
9595
SELECT 1 FROM #{Enrollment.quoted_table_name} e2

lib/messageable_user/calculator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def uncached_messageable_sections
774774
def uncached_messageable_groups
775775
fully_visible_scope = GroupMembership.
776776
select("group_memberships.group_id AS group_id").
777-
uniq.
777+
distinct.
778778
joins(:user, :group).
779779
where(:workflow_state => 'accepted').
780780
where("groups.workflow_state<>'deleted'").
@@ -783,7 +783,7 @@ def uncached_messageable_groups
783783

784784
section_visible_scope = GroupMembership.
785785
select("group_memberships.group_id AS group_id").
786-
uniq.
786+
distinct.
787787
joins(:user, :group).
788788
joins(<<-SQL).
789789
INNER JOIN #{Enrollment.quoted_table_name} ON

0 commit comments

Comments
 (0)