rails 6: s/update_attributes/update/g

Change-Id: Ie137c1040260b363979160e1f0558883577ebebd
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/222510
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
Cody Cutrer 2020-01-08 16:39:02 -07:00
parent 871c46f6c0
commit a81944a73a
236 changed files with 676 additions and 676 deletions

View File

@ -779,7 +779,7 @@ class AccountsController < ApplicationController
render :json => @account.errors, :status => :unauthorized
else
success = @account.errors.empty?
success &&= @account.update_attributes(account_settings.merge(quota_settings)) rescue false
success &&= @account.update(account_settings.merge(quota_settings)) rescue false
if success
# Successfully completed
@ -984,7 +984,7 @@ class AccountsController < ApplicationController
# Set default Dashboard view
set_default_dashboard_view(params.dig(:account, :settings)&.delete(:default_dashboard_view))
if @account.update_attributes(strong_account_params)
if @account.update(strong_account_params)
update_user_dashboards
format.html { redirect_to account_settings_url(@account) }
format.json { render :json => @account }

View File

@ -36,7 +36,7 @@ class AlertsController < ApplicationController
if authorized_action(@context, @current_user, :manage_interaction_alerts)
convert_recipients
@alert = @context.alerts.find(params[:id])
if @alert.update_attributes(alert_params)
if @alert.update(alert_params)
headers['Location'] = named_context_url(@context, :context_alert_url, @alert.id)
render :json => @alert.as_json(:include => :criteria)
else

View File

@ -473,7 +473,7 @@ class AppointmentGroupsController < ApplicationController
@group.contexts = contexts if contexts
if authorized_action(@group, @current_user, :update)
publish = params[:appointment_group].delete(:publish) == "1"
if (publish && params[:appointment_group].blank?) || @group.update_attributes(appointment_group_params)
if (publish && params[:appointment_group].blank?) || @group.update(appointment_group_params)
@group.publish! if publish
render :json => appointment_group_json(@group, @current_user, session)
else

View File

@ -41,7 +41,7 @@ class AssessmentQuestionsController < ApplicationController
params[:assessment_question] ||= {}
params[:assessment_question][:form_question_data] ||= params[:question]
@question.edited_independent_of_quiz_question
if @question.with_versioning { @question.update_attributes(assessment_question_params) }
if @question.with_versioning { @question.update(assessment_question_params) }
render json: question_json(@question, @current_user, session, [:assessment_question])
else
render :json => @question.errors, :status => :bad_request

View File

@ -131,7 +131,7 @@ class Bookmarks::BookmarksController < ApplicationController
#
# @returns Folder
def update
if @bookmark.update_attributes(valid_params) && set_position
if @bookmark.update(valid_params) && set_position
show
else
render_errors

View File

@ -649,7 +649,7 @@ class CalendarEventsApiController < ApplicationController
if params_for_update[:description].present?
params_for_update[:description] = process_incoming_html_content(params_for_update[:description])
end
if @event.update_attributes(params_for_update)
if @event.update(params_for_update)
render :json => event_json(@event, @current_user, session)
else
render :json => @event.errors, :status => :bad_request

View File

@ -74,7 +74,7 @@ class CalendarEventsController < ApplicationController
def edit
@event = @context.calendar_events.find(params[:id])
if @event.grants_right?(@current_user, session, :update)
@event.update_attributes!(params.permit(:title, :start_at, :end_at, :location_name, :location_address))
@event.update!(params.permit(:title, :start_at, :end_at, :location_name, :location_address))
end
if authorized_action(@event, @current_user, :update_content)
render :new
@ -87,7 +87,7 @@ class CalendarEventsController < ApplicationController
respond_to do |format|
params[:calendar_event][:time_zone_edited] = Time.zone.name if params[:calendar_event]
@event.updating_user = @current_user
if @event.update_attributes(calendar_event_params)
if @event.update(calendar_event_params)
log_asset_access(@event, "calendar", "calendar", 'participate')
flash[:notice] = t 'notices.updated', "Event was successfully updated."
format.html { redirect_to calendar_url_for(@context) }

View File

@ -250,7 +250,7 @@ class ConferencesController < ApplicationController
respond_to do |format|
params[:web_conference].try(:delete, :long_running)
params[:web_conference].try(:delete, :conference_type)
if @conference.update_attributes(conference_params)
if @conference.update(conference_params)
# TODO: ability to dis-invite people
members.uniq.each do |u|
@conference.add_invitee(u)

View File

@ -272,7 +272,7 @@ class ContentSharesController < ApplicationController
def update
@content_share = @current_user.content_shares.find(params[:id])
update_params = params.permit(:read_state)
if @content_share.update_attributes(update_params)
if @content_share.update(update_params)
render json: content_share_json(@content_share, @current_user, session)
else
render json: @content_share.errors.to_json, :status => 400

View File

@ -425,7 +425,7 @@ class ContextModulesApiController < ApplicationController
end
relock_warning = @module.relock_warning?
if @module.update_attributes(module_parameters) && set_position
if @module.update(module_parameters) && set_position
json = module_json(@module, @current_user, session, nil)
json['relock_warning'] = true if relock_warning || @module.relock_warning?
json['publish_warning'] = publish_warning.present?

View File

@ -648,7 +648,7 @@ class ContextModulesController < ApplicationController
elsif params[:unpublish]
@module.unpublish
end
if @module.update_attributes(context_module_params)
if @module.update(context_module_params)
json = @module.as_json(:include => :content_tags, :methods => :workflow_state, :permissions => {:user => @current_user, :session => session})
json['context_module']['relock_warning'] = true if @module.relock_warning?
render :json => json

View File

@ -646,7 +646,7 @@ class ConversationsController < ApplicationController
# "participants": [{"id": 1, "name": "Joe", "full_name": "Joe TA"}]
# }
def update
if @conversation.update_attributes(params.require(:conversation).permit(*API_ALLOWED_FIELDS))
if @conversation.update(params.require(:conversation).permit(*API_ALLOWED_FIELDS))
render :json => conversation_json(@conversation, @current_user, session)
else
render :json => @conversation.errors, :status => :bad_request

View File

@ -108,7 +108,7 @@ class DiscussionEntriesController < ApplicationController
return if context_file_quota_exceeded?
@entry.editor = @current_user
respond_to do |format|
if @entry.update_attributes(entry_params)
if @entry.update(entry_params)
save_attachment
format.html {
flash[:notice] = t :updated_entry_notice, 'Entry was successfully updated.'

View File

@ -1216,7 +1216,7 @@ class DiscussionTopicsController < ApplicationController
@topic.assignment = nil
end
end
@topic.update_attributes(discussion_topic_hash)
@topic.update(discussion_topic_hash)
@topic.root_topic.try(:save)
end
if !@topic.errors.any? && !@topic.root_topic.try(:errors).try(:any?)

View File

@ -47,7 +47,7 @@ class EportfolioCategoriesController < ApplicationController
if authorized_action(@portfolio, @current_user, :update)
@category = @portfolio.eportfolio_categories.find(params[:id])
respond_to do |format|
if @category.update_attributes(eportfolio_category_params)
if @category.update(eportfolio_category_params)
format.html { redirect_to eportfolio_category_url(@portfolio, @category) }
format.json { render :json => @category }
else

View File

@ -79,7 +79,7 @@ class EportfolioEntriesController < ApplicationController
entry_params[:eportfolio_category] = category
end
respond_to do |format|
if @entry.update_attributes!(entry_params)
if @entry.update!(entry_params)
format.html { redirect_to eportfolio_entry_url(@portfolio, @entry) }
format.json { render :json => @entry }
else

View File

@ -118,7 +118,7 @@ class EportfoliosController < ApplicationController
if update_params
respond_to do |format|
if @portfolio.update_attributes(update_params)
if @portfolio.update(update_params)
@portfolio.ensure_defaults
flash[:notice] = t('notices.updated', "ePortfolio successfully updated")
format.html { redirect_to eportfolio_url(@portfolio) }

View File

@ -333,7 +333,7 @@ class FoldersController < ApplicationController
return unless authorized_action(parent_folder, @current_user, :manage_contents)
folder_params[:parent_folder] = parent_folder
end
if @folder.update_attributes(folder_params)
if @folder.update(folder_params)
if !@folder.parent_folder_id || !@context.folders.where(id: @folder).first
@folder.parent_folder = Folder.root_folders(@context).first
@folder.save

View File

@ -139,7 +139,7 @@ class GradingPeriodsController < ApplicationController
respond_to do |format|
DueDateCacher.with_executing_user(@current_user) do
if grading_period(inherit: false).update_attributes(grading_period_params)
if grading_period(inherit: false).update(grading_period_params)
format.json { render json: serialize_json_api(grading_period(inherit: false)) }
else
format.json do

View File

@ -80,7 +80,7 @@ class GradingStandardsController < ApplicationController
if authorized_action(@standard, @current_user, :manage)
@standard.user = @current_user
respond_to do |format|
if @standard.update_attributes(grading_standard_params)
if @standard.update(grading_standard_params)
format.json { render json: standard_as_json(@standard) }
else
format.json { render json: @standard.errors, status: :bad_request }

View File

@ -190,7 +190,7 @@ class GroupMembershipsController < ApplicationController
attrs.delete(:workflow_state) unless attrs[:workflow_state] == 'accepted'
DueDateCacher.with_executing_user(@current_user) do
if @membership.update_attributes(attrs)
if @membership.update(attrs)
render :json => group_membership_json(@membership, @current_user, session)
else
render :json => @membership.errors, :status => :bad_request

View File

@ -581,7 +581,7 @@ class GroupsController < ApplicationController
end
respond_to do |format|
@group.transaction do
@group.update_attributes(attrs.slice(*SETTABLE_GROUP_ATTRIBUTES))
@group.update(attrs.slice(*SETTABLE_GROUP_ATTRIBUTES))
if attrs[:members]
user_ids = Api.value_to_array(attrs[:members]).map(&:to_i).uniq
if @group.context

View File

@ -163,7 +163,7 @@ module Lti
#
# @returns LineItem
def update
line_item.update_attributes!(line_item_params)
line_item.update!(line_item_params)
update_assignment_title if line_item.assignment_line_item?
render json: LineItemsSerializer.new(line_item, line_item_id(line_item)),
content_type: MIME_TYPE
@ -238,7 +238,7 @@ module Lti
def update_assignment_title
return if line_item_params[:label].blank?
line_item.assignment.update_attributes!(name: line_item_params[:label])
line_item.assignment.update!(name: line_item_params[:label])
end
def resource_link

View File

@ -236,7 +236,7 @@ module Lti
#
# @returns OriginalityReport
def update
if @report.update_attributes(update_report_params)
if @report.update(update_report_params)
@report.send_later_if_production(:copy_to_group_submissions!)
render json: api_json(@report, @current_user, session)
else

View File

@ -47,7 +47,7 @@ class MediaTracksController < ApplicationController
@media_object = MediaObject.active.by_media_id(params[:media_object_id]).first
if authorized_action(@media_object, @current_user, :add_captions)
track = @media_object.media_tracks.where(user_id: @current_user.id, locale: params[:locale]).first_or_initialize
track.update_attributes! params.permit(*TRACK_SETTABLE_ATTRIBUTES)
track.update! params.permit(*TRACK_SETTABLE_ATTRIBUTES)
render :json => media_object_api_json(@media_object, @current_user, session)
end
end

View File

@ -265,7 +265,7 @@ class OutcomeGroupsApiController < ApplicationController
render :json => 'error'.to_json, :status => :bad_request
return
end
@outcome_group.update_attributes(params.permit(:title, :description, :vendor_guid))
@outcome_group.update(params.permit(:title, :description, :vendor_guid))
if params[:parent_outcome_group_id] && params[:parent_outcome_group_id] != @outcome_group.learning_outcome_group_id
new_parent = context_outcome_groups.find(params[:parent_outcome_group_id])
unless new_parent.adopt_outcome_group(@outcome_group)

View File

@ -267,7 +267,7 @@ class OutcomesApiController < ApplicationController
return unless authorized_action(@outcome, @current_user, :update)
update_outcome_criterion(@outcome) if params[:mastery_points] || params[:ratings]
if @outcome.update_attributes(params.permit(*DIRECT_PARAMS))
if @outcome.update(params.permit(*DIRECT_PARAMS))
render :json => outcome_json(@outcome, @current_user, session)
else
render :json => @outcome.errors, :status => :bad_request

View File

@ -267,7 +267,7 @@ class OutcomesController < ApplicationController
@outcome = @context.created_learning_outcomes.find(params[:id])
respond_to do |format|
if @outcome.update_attributes(learning_outcome_params)
if @outcome.update(learning_outcome_params)
flash[:notice] = t :successful_outcome_update, "Outcome successfully updated!"
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
format.json { render :json => @outcome }

View File

@ -210,7 +210,7 @@ class PlannerNotesController < ApplicationController
update_params[:course] = nil
end
end
if note.update_attributes(update_params)
if note.update(update_params)
Rails.cache.delete(planner_meta_cache_key)
render json: planner_note_json(note, @current_user, session), status: :ok
else

View File

@ -151,7 +151,7 @@ module Polling
end
if authorized_action(@poll, @current_user, :update)
if @poll_choice.update_attributes(poll_choice_params)
if @poll_choice.update(poll_choice_params)
render json: serialize_jsonapi(@poll_choice)
else
render json: @poll_choice.errors, status: :bad_request

View File

@ -179,7 +179,7 @@ module Polling
def update
@poll_session = @poll.poll_sessions.find(params[:id])
if authorized_action(@poll, @current_user, :update)
if @poll_session.update_attributes(get_poll_session_params)
if @poll_session.update(get_poll_session_params)
render json: serialize_jsonapi(@poll_session)
else
render json: @poll_session.errors, status: :bad_request

View File

@ -144,7 +144,7 @@ module Polling
if authorized_action(@poll, @current_user, :update)
poll_params.delete(:is_correct) if poll_params && poll_params[:is_correct].blank?
if @poll.update_attributes(poll_params)
if @poll.update(poll_params)
render json: serialize_jsonapi(@poll)
else
render json: @poll.errors, status: :bad_request

View File

@ -343,7 +343,7 @@ class ProfileController < ApplicationController
user_params.delete(:short_name)
user_params.delete(:sortable_name)
end
if @user.update_attributes(user_params)
if @user.update(user_params)
pseudonymed = false
if params[:default_email_id].present?
@email_channel = @user.communication_channels.email.active.where(id: params[:default_email_id]).first
@ -373,7 +373,7 @@ class ProfileController < ApplicationController
pseudonym_params.delete :password_confirmation
end
params[:pseudonym].delete :password_id
if !pseudonym_params.empty? && pseudonym_to_update && !pseudonym_to_update.update_attributes(pseudonym_params)
if !pseudonym_params.empty? && pseudonym_to_update && !pseudonym_to_update.update(pseudonym_params)
pseudonymed = true
flash[:error] = t('errors.profile_update_failed', "Login failed to update")
format.html { redirect_to user_profile_url(@current_user) }

View File

@ -134,7 +134,7 @@ class QuestionBanksController < ApplicationController
def update
@bank = @context.assessment_question_banks.find(params[:id])
if authorized_action(@bank, @current_user, :update)
if @bank.update_attributes(bank_params)
if @bank.update(bank_params)
@bank.reload
render :json => @bank.as_json(:include => {:learning_outcome_alignments => {:include => {:learning_outcome => {:include_root => false}}}})
else

View File

@ -395,7 +395,7 @@ class Quizzes::QuizzesController < ApplicationController
@quiz.content_being_saved_by(@current_user)
@quiz.infer_times
@quiz.transaction do
@quiz.update_attributes!(quiz_params)
@quiz.update!(quiz_params)
batch_update_assignment_overrides(@quiz, overrides, @current_user) unless overrides.nil?
end

View File

@ -280,7 +280,7 @@ class SectionsController < ApplicationController
end
respond_to do |format|
if @section.update_attributes(course_section_params)
if @section.update(course_section_params)
@context.touch
flash[:notice] = t('section_updated', "Section successfully updated!")
format.html { redirect_to course_section_url(@context, @section) }

View File

@ -147,7 +147,7 @@ class SubAccountsController < ApplicationController
def update
@sub_account = subaccount_or_self(params[:id])
params[:account].delete(:parent_account_id)
if @sub_account.update_attributes(account_params)
if @sub_account.update(account_params)
render :json => account_json(@sub_account, @current_user, session, [])
else
render :json => @sub_account.errors, status: 400

View File

@ -134,7 +134,7 @@ class TermsController < ApplicationController
term_params = params.require(:enrollment_term).permit(:name, :start_at, :end_at)
DueDateCacher.with_executing_user(@current_user) do
if validate_dates(@term, term_params, overrides) && @term.update_attributes(term_params)
if validate_dates(@term, term_params, overrides) && @term.update(term_params)
@term.set_overrides(@context, overrides)
render :json => serialized_term
else

View File

@ -44,7 +44,7 @@ class TokensController < ApplicationController
def update
@token = @current_user.access_tokens.find(params[:id])
if @token.update_attributes(access_token_params)
if @token.update(access_token_params)
render :json => @token.as_json(:include_root => false, :methods => [:app_name,:visible_token])
else
render :json => @token.errors, :status => :bad_request

View File

@ -1919,7 +1919,7 @@ class UsersController < ApplicationController
@user.sortable_name_explicitly_set = user_params[:sortable_name].present?
respond_to do |format|
if @user.update_attributes(user_params)
if @user.update(user_params)
@user.avatar_state = (old_avatar_state == :locked ? old_avatar_state : 'approved') if admin_avatar_update
@user.profile.save if @user.profile.changed?
@user.save if admin_avatar_update || update_email

View File

@ -326,7 +326,7 @@ class WikiPagesApiController < ApplicationController
if authorized_action(@page, @current_user, :create)
update_params = get_update_params(Set[:title, :body])
assign_todo_date
if !update_params.is_a?(Symbol) && @page.update_attributes(update_params) && process_front_page
if !update_params.is_a?(Symbol) && @page.update(update_params) && process_front_page
log_asset_access(@page, "wiki", @wiki, 'participate')
apply_assignment_parameters(assignment_params, @page) if @context.feature_enabled?(:conditional_release)
render :json => wiki_page_json(@page, @current_user, session)
@ -398,7 +398,7 @@ class WikiPagesApiController < ApplicationController
if perform_update
assign_todo_date
update_params = get_update_params
if !update_params.is_a?(Symbol) && @page.update_attributes(update_params) && process_front_page
if !update_params.is_a?(Symbol) && @page.update(update_params) && process_front_page
log_asset_access(@page, "wiki", @wiki, 'participate')
@page.context_module_action(@current_user, @context, :contributed)
apply_assignment_parameters(assignment_params, @page) if @context.feature_enabled?(:conditional_release)

View File

@ -48,22 +48,22 @@ class AccountReportRunner < ActiveRecord::Base
def start
@rows ||= []
self.update_attributes!(workflow_state: 'running', started_at: Time.now.utc)
self.update!(workflow_state: 'running', started_at: Time.now.utc)
end
def complete
write_rows
self.update_attributes!(workflow_state: 'completed', ended_at: Time.now.utc)
self.update!(workflow_state: 'completed', ended_at: Time.now.utc)
end
def abort
write_rows
self.update_attributes!(workflow_state: 'aborted', ended_at: Time.now.utc)
self.update!(workflow_state: 'aborted', ended_at: Time.now.utc)
end
def fail
write_rows
self.update_attributes!(workflow_state: 'error', ended_at: Time.now.utc)
self.update!(workflow_state: 'error', ended_at: Time.now.utc)
end
scope :in_progress, -> {where(workflow_state: %w(running))}

View File

@ -147,7 +147,7 @@ class AssessmentRequest < ActiveRecord::Base
def update_planner_override
if saved_change_to_workflow_state? && workflow_state_before_last_save == 'assigned' && workflow_state == 'completed'
override = PlannerOverride.find_by(plannable_id: self.id, plannable_type: 'AssessmentRequest', user: assessor)
override.update_attributes(marked_complete: true) if override.present?
override.update(marked_complete: true) if override.present?
end
end
end

View File

@ -122,6 +122,6 @@ class AssignmentConfigurationToolLookup < ActiveRecord::Base
return unless lti_tool.instance_of? Lti::MessageHandler
tool_proxy = lti_tool.resource_handler.tool_proxy
subscription_helper = Lti::AssignmentSubscriptionsHelper.new(tool_proxy, assignment)
self.update_attributes(subscription_id: subscription_helper.create_subscription)
self.update(subscription_id: subscription_helper.create_subscription)
end
end

View File

@ -96,7 +96,7 @@ class CalendarEvent < ActiveRecord::Base
@child_event_data.each do |data|
if (event = current_events.delete(data[:context_code])&.first)
event.updating_user = @updating_user
event.update_attributes(:start_at => data[:start_at], :end_at => data[:end_at])
event.update(:start_at => data[:start_at], :end_at => data[:end_at])
else
context = @child_event_contexts[data[:context_code]][0]
event = child_events.build(:start_at => data[:start_at], :end_at => data[:end_at])

View File

@ -65,7 +65,7 @@ module Context
user = entry.user || feed.user
# If already existed and has been updated
if entry.entry_changed? && entry.asset
entry.asset.update_attributes(
entry.asset.update(
:title => entry.title,
:message => entry.message
)
@ -77,7 +77,7 @@ module Context
announcement.external_feed_id = feed.id
announcement.user = user
announcement.save
entry.update_attributes(:asset => announcement)
entry.update(:asset => announcement)
end
end
end

View File

@ -356,7 +356,7 @@ class ConversationParticipant < ActiveRecord::Base
StreamItem.send_later_if_production_enqueue_args(:generate_or_update, {:priority => 25}, self.conversation)
end
def update_attributes(hash)
def update(hash)
# subscribed= can update the workflow_state, but an explicit
# workflow_state should trump that. so we do this first
subscribed = (hash.has_key?(:subscribed) ? hash.delete(:subscribed) : hash.delete('subscribed'))

View File

@ -52,7 +52,7 @@ class CrocodocDocument < ActiveRecord::Base
end
if response && response['uuid']
update_attributes :uuid => response['uuid'], :process_state => 'QUEUED'
update :uuid => response['uuid'], :process_state => 'QUEUED'
elsif response.nil?
raise "no response received"
else

View File

@ -391,7 +391,7 @@ class DiscussionEntry < ActiveRecord::Base
end
end
if existing_topic_participant && !existing_topic_participant.subscribed? && !self.discussion_topic.subscription_hold(user, nil, nil)
existing_topic_participant.update_attributes!(:subscribed => true)
existing_topic_participant.update!(:subscribed => true)
end
end
end

View File

@ -40,7 +40,7 @@ class ExternalFeedEntry < ActiveRecord::Base
protected :infer_defaults
def update_feed_attributes(opts)
self.update_attributes(opts)
self.update(opts)
@feed_entry_updated = self.changed?
end

View File

@ -68,7 +68,7 @@ class GoogleDocsCollaboration < Collaboration
user_param = service_user_id
google_adapter_for_user.acl_add(self.document_id, [user_param])
collaborator.update_attributes(:authorized_service_user_id => service_user_id)
collaborator.update(:authorized_service_user_id => service_user_id)
end
else
# no collaboration for this user, lets create it

View File

@ -98,7 +98,7 @@ module Importers
context: assignment.course
)
tool_setting.update_attributes!(
tool_setting.update!(
custom: ts_custom,
custom_parameters: ts_custom_params,
vendor_code: ts_vendor_code,

View File

@ -38,22 +38,22 @@ class ParallelImporter < ActiveRecord::Base
def start
if workflow_state == 'retry'
self.update_attributes!(started_at: Time.now.utc)
self.update!(started_at: Time.now.utc)
else
self.update_attributes!(:workflow_state => "running", :started_at => Time.now.utc)
self.update!(:workflow_state => "running", :started_at => Time.now.utc)
end
end
def fail
self.update_attributes!(:workflow_state => "failed", :ended_at => Time.now.utc)
self.update!(:workflow_state => "failed", :ended_at => Time.now.utc)
end
def abort
self.update_attributes!(:workflow_state => "aborted", :ended_at => Time.now.utc)
self.update!(:workflow_state => "aborted", :ended_at => Time.now.utc)
end
def complete(opts={})
updates = {:workflow_state => "completed", :ended_at => Time.now.utc}.merge(opts)
self.update_attributes!(updates)
self.update!(updates)
end
end

View File

@ -245,7 +245,7 @@ class RubricAssociation < ActiveRecord::Base
end
association.context = context
association.skip_updating_points_possible = params.delete :skip_updating_points_possible
association.update_attributes(params)
association.update(params)
association.association_object = association_object
association
end

View File

@ -92,7 +92,7 @@ class SubmissionComment < ActiveRecord::Base
def publish_other_comments_in_this_group
return unless saved_change_to_draft?
update_other_comments_in_this_group do |comment|
comment.update_attributes(draft: draft)
comment.update(draft: draft)
end
end

View File

@ -93,7 +93,7 @@ describe "BookmarkedCollection" do
it "should apply any restriction block given to the scope" do
course = @scope.order(:id).last
course.update_attributes(:name => 'Matching Name')
course.update(:name => 'Matching Name')
collection = BookmarkedCollection.wrap(IDBookmarker, @scope) do |scope|
scope.where(:name => course.name)

View File

@ -109,14 +109,14 @@ describe "ActsAsUrl" do
it "should_not_update_url_by_default" do
@doc = Document.create!(:title => "Stable as Stone")
@original_url = @doc.url
@doc.update_attributes :title => "New Unstable Madness"
@doc.update :title => "New Unstable Madness"
expect(@original_url).to eq @doc.url
end
it "should_update_url_if_asked" do
@moc = Mocument.create!(:title => "Original")
@original_url = @moc.url
@moc.update_attributes :title => "New and Improved"
@moc.update :title => "New and Improved"
expect(@original_url).to_not eq @moc.url
end

View File

@ -79,7 +79,7 @@ module AccountReports
end
def self.generate_report(account_report)
account_report.update_attributes(workflow_state: 'running', start_at: Time.zone.now)
account_report.update(workflow_state: 'running', start_at: Time.zone.now)
begin
REPORTS[account_report.report_type].proc.call(account_report)
rescue => e

View File

@ -312,7 +312,7 @@ module AccountReports::ReportHelper
return
end
@account_report.update_attributes(total_lines: total_runners)
@account_report.update(total_lines: total_runners)
args = {priority: Delayed::LOW_PRIORITY, max_attempts: 1, n_strand: ["account_report_runner", root_account.global_id]}
@account_report.account_report_runners.find_each do |runner|
@ -379,7 +379,7 @@ module AccountReports::ReportHelper
end
def compile_parallel_report(headers, files: nil)
@account_report.update_attributes(total_lines: @account_report.account_report_rows.count + 1)
@account_report.update(total_lines: @account_report.account_report_rows.count + 1)
files ? compile_parallel_zip_report(files) : write_report_from_rows(headers)
@account_report.delete_account_report_rows
end
@ -465,7 +465,7 @@ module AccountReports::ReportHelper
updates = {}
updates[:current_line] = lineno
updates[:progress] = (lineno.to_f / (report.total_lines + 1) * 100).to_i if report.total_lines
report.update_attributes(updates)
report.update(updates)
if report.workflow_state == 'deleted'
report.workflow_state = 'aborted'
report.save!

View File

@ -138,7 +138,7 @@ module SimplyVersioned
options[:except] = options[:except].map( &:to_s )
self.update_attributes( YAML::load( version.yaml ).except( *options[:except] ) )
self.update( YAML::load( version.yaml ).except( *options[:except] ) )
end
# Invoke the supplied block passing the receiver as the sole block argument with

View File

@ -79,7 +79,7 @@ module Canvas::MessageHelper
raise 'Name is required' unless using[:name]
n = Notification.where(name: using[:name]).first_or_initialize
begin
n.update_attributes(:delay_for => using[:delay_for], :category => using[:category])
n.update(:delay_for => using[:delay_for], :category => using[:category])
rescue => e
if n.new_record?
raise "New notification '#{using[:name]}' creation failed. Message: #{e.message}"

View File

@ -18,7 +18,7 @@
module DataFixup::AddToolProxyToMessageHandler
def self.run
Lti::MessageHandler.where(tool_proxy: nil).find_each do |mh|
mh.update_attributes(tool_proxy: mh.resource_handler.tool_proxy)
mh.update(tool_proxy: mh.resource_handler.tool_proxy)
end
end
end

View File

@ -31,13 +31,13 @@ module DataFixup::PopulateRootAccountIdOnUserObservers
# for the unlikely scenario that somehow an equivalent link was made after the deploy but before the fixup finished
new_id = -1 * retry_count # just in case
updates = {:root_account_id => new_id, :workflow_state => 'deleted'}
shadow.update_attributes(updates) if shadow
link.update_attributes(updates)
shadow.update(updates) if shadow
link.update(updates)
else
updates = {:root_account_id => root_account_id}
updates.merge!(:workflow_state => 'deleted') if destroy
shadow.update_attributes(updates) if shadow
link.update_attributes(updates)
shadow.update(updates) if shadow
link.update(updates)
end
end
end

View File

@ -62,7 +62,7 @@ module PlannerHelper
def self.complete_planner_override(planner_override)
return unless planner_override.is_a? PlannerOverride
planner_override.update_attributes(marked_complete: true)
planner_override.update(marked_complete: true)
clear_planner_cache(planner_override&.user)
end

View File

@ -173,7 +173,7 @@ module Lti
describe "POST #create with JWT access token" do
let(:access_token) do
aud = host rescue (@request || request).host
developer_key.update_attributes(vendor_code: vendor_code)
developer_key.update(vendor_code: vendor_code)
Lti::Oauth2::AccessToken.create_jwt(aud: aud, sub: developer_key.global_id, reg_key: 'reg_key')
end
let(:request_headers) { {Authorization: "Bearer #{access_token}"} }

View File

@ -30,7 +30,7 @@ module Lti
before(:once) { attachment_model }
before :each do
course_factory(active_all: true)
message_handler.update_attributes(message_type: 'basic-lti-launch-request')
message_handler.update(message_type: 'basic-lti-launch-request')
student_in_course active_all: true
teacher_in_course active_all: true
@ -78,7 +78,7 @@ module Lti
@report = OriginalityReport.create!(report_initial_values)
@endpoints[:show] = "/api/lti/assignments/#{@assignment.id}/submissions/#{@submission.id}/originality_report/#{@report.id}"
@endpoints[:alt_show] = "/api/lti/assignments/#{@assignment.id}/files/#{@attachment.id}/originality_report"
@assignment.course.update_attributes(account: tool_proxy.context)
@assignment.course.update(account: tool_proxy.context)
end
it "requires an lti access token" do
@ -98,7 +98,7 @@ module Lti
@assignment.save!
new_tool_proxy = tool_proxy.deep_clone
new_tool_proxy.update_attributes(guid: SecureRandom.uuid)
new_tool_proxy.update(guid: SecureRandom.uuid)
token = Lti::Oauth2::AccessToken.create_jwt(aud: aud, sub: new_tool_proxy.guid)
other_helpers = {Authorization: "Bearer #{token}"}
@ -191,7 +191,7 @@ module Lti
@assignment.tool_settings_tool = message_handler
@assignment.save!
new_tool_proxy = tool_proxy.deep_clone
new_tool_proxy.update_attributes(guid: SecureRandom.uuid)
new_tool_proxy.update(guid: SecureRandom.uuid)
token = Lti::Oauth2::AccessToken.create_jwt(aud: aud, sub: new_tool_proxy.guid)
other_helpers = {Authorization: "Bearer #{token}"}
allow_any_instance_of(Lti::ToolProxy).to receive(:active_in_context?).and_return(true)
@ -273,7 +273,7 @@ module Lti
@report = OriginalityReport.create!(report_initial_values)
@endpoints[:update] = "/api/lti/assignments/#{@assignment.id}/submissions/#{@submission.id}/originality_report/#{@report.id}"
@endpoints[:update_alt] = "/api/lti/assignments/#{@assignment.id}/files/#{@attachment.id}/originality_report"
@assignment.course.update_attributes(account: account)
@assignment.course.update(account: account)
end
it "requires the tool proxy to be associated to the assignment" do
@ -629,7 +629,7 @@ module Lti
describe "POST assignments/:assignment_id/submissions/:submission_id/originality_report (#create)" do
before do
@assignment.course.update_attributes(account: account)
@assignment.course.update(account: account)
end
it "creates an originality report when provided required params" do
@ -712,8 +712,8 @@ module Lti
end
it "does not require an attachment if submission type includes online text entry" do
@submission.assignment.update_attributes!(submission_types: 'online_text_entry')
@submission.update_attributes!(body: 'some text')
@submission.assignment.update!(submission_types: 'online_text_entry')
@submission.update!(body: 'some text')
score = 0.25
post @endpoints[:create], params: {originality_report: {originality_score: score}}, headers: request_headers
@ -722,7 +722,7 @@ module Lti
end
it "does not requre an attachment if submission type does not include online text entry" do
@submission.update_attributes!(body: 'some text')
@submission.update!(body: 'some text')
score = 0.25
post @endpoints[:create], params: {originality_report: {originality_score: score}}, headers: request_headers
expect(response).to be_not_found
@ -885,7 +885,7 @@ module Lti
context 'when attempt is given' do
before do
@submission.assignment.update_attributes!(submission_types: 'online_text_entry')
@submission.assignment.update!(submission_types: 'online_text_entry')
end
def create_version
@ -974,7 +974,7 @@ module Lti
context 'when attempt is not given' do
it 'updates the first originality report created without an attachment' do
@submission.assignment.update_attributes!(submission_types: 'online_text_entry')
@submission.assignment.update!(submission_types: 'online_text_entry')
originality_score = 50
post @endpoints[:create],
params: {

View File

@ -29,7 +29,7 @@ module Lti
before do
allow_any_instance_of(AssignmentSubscriptionsHelper).to receive(:create_subscription) { SecureRandom.uuid }
allow_any_instance_of(AssignmentSubscriptionsHelper).to receive(:destroy_subscription) { {} }
message_handler.update_attributes(capabilities: [Lti::ResourcePlacement::SIMILARITY_DETECTION_LTI2])
message_handler.update(capabilities: [Lti::ResourcePlacement::SIMILARITY_DETECTION_LTI2])
tool_proxy.raw_data['security_contract']['tool_service'] = authorized_services
tool_proxy.save!
assignment.tool_settings_tool = message_handler
@ -44,7 +44,7 @@ module Lti
end
let(:student) do
student = create_users_in_course(course, 2, return_type: :record).first
student.update_attributes(lti_context_id: SecureRandom.uuid)
student.update(lti_context_id: SecureRandom.uuid)
student
end
let(:assignment) do

View File

@ -56,7 +56,7 @@ module Lti
let(:other_tool_proxy) do
tp = tool_proxy.dup
tp.update_attributes(guid: other_tp_guid)
tp.update(guid: other_tp_guid)
tp
end

View File

@ -44,7 +44,7 @@ module Lti
before do
allow_any_instance_of(AssignmentSubscriptionsHelper).to receive(:create_subscription) { SecureRandom.uuid }
allow_any_instance_of(AssignmentSubscriptionsHelper).to receive(:destroy_subscription) { {} }
message_handler.update_attributes(capabilities: [Lti::ResourcePlacement::SIMILARITY_DETECTION_LTI2])
message_handler.update(capabilities: [Lti::ResourcePlacement::SIMILARITY_DETECTION_LTI2])
tool_proxy.raw_data['security_contract']['tool_service'] = authorized_services
tool_proxy.save!
assignment.tool_settings_tool = message_handler
@ -56,7 +56,7 @@ module Lti
let(:canvas_id_endpoint) { "/api/lti/users/#{student.id}" }
let(:student) do
course_with_student(active_all: true, course: course)
@student.update_attributes(lti_context_id: SecureRandom.uuid)
@student.update(lti_context_id: SecureRandom.uuid)
@student
end
let(:expected_student) do
@ -80,7 +80,7 @@ module Lti
it "verifies the tool is associated with at least one of the user's assignments" do
second_course = Course.create!(name: 'second course')
assignment.update_attributes!(course: second_course)
assignment.update!(course: second_course)
get canvas_id_endpoint, params: {id: student.id}, headers: request_headers
expect(response).to be_unauthorized
end
@ -93,7 +93,7 @@ module Lti
context 'course' do
before do
tool_proxy.update_attributes!(context: course)
tool_proxy.update!(context: course)
end
it 'returns a user by lti id' do
@ -152,7 +152,7 @@ module Lti
let(:student_one) do
student_in_course(course: group.context)
@student.update_attributes!(lti_context_id: student_lti_id)
@student.update!(lti_context_id: student_lti_id)
@student
end
@ -163,12 +163,12 @@ module Lti
let(:student_three) do
student_in_course(course: group.context)
@student.update_attributes!(email: 'student@test.com')
@student.update!(email: 'student@test.com')
@student
end
before do
group.context.update_attributes!(account: tool_proxy.account)
group.context.update!(account: tool_proxy.account)
group.add_user(student_one, 'accepted')
group.add_user(student_two, 'accepted')
group.add_user(student_three, 'accepted')
@ -184,13 +184,13 @@ module Lti
end
it 'responds with 401 if group is not in tool context' do
group.context.update_attributes!(account: account_model)
group.context.update!(account: account_model)
get group_index_endpoint, headers: request_headers
expect(response).to be_unauthorized
end
it 'responds with 401 if the group is not active' do
group.update_attributes!(workflow_state: 'deleted')
group.update!(workflow_state: 'deleted')
get group_index_endpoint, headers: request_headers
expect(response).to be_unauthorized
end

View File

@ -965,7 +965,7 @@ describe AssignmentGroupsApiController, type: :request do
Factories::GradingPeriodHelper.new.create_for_group(@grading_period_group, {
start_date: 2.weeks.ago, end_date: 2.days.ago, close_date: 1.day.ago
})
@assignment_group.update_attributes(group_weight: 50)
@assignment_group.update(group_weight: 50)
end
context "as a teacher" do

View File

@ -793,7 +793,7 @@ describe AssignmentOverridesController, type: :request do
end
it "recomputes grades when changing overrides" do
@assignment.update_attributes! only_visible_to_overrides: true, points_possible: 10
@assignment.update! only_visible_to_overrides: true, points_possible: 10
other_assignment = @course.assignments.create! points_possible: 10, context: @course
student1 = @student

View File

@ -1757,7 +1757,7 @@ describe AssignmentsApiController, type: :request do
let(:course) { Course.create!(name: 'test course', account: account) }
let(:teacher) { teacher_in_course(course: course) }
before { account.update_attributes(root_account: root_account) }
before { account.update(root_account: root_account) }
it "checks for tool installation in entire account chain" do
user_session teacher
@ -1845,7 +1845,7 @@ describe AssignmentsApiController, type: :request do
let(:context) { raise 'Override in spec' }
it 'sets the tool correctly' do
tool_proxy.update_attributes(context: context)
tool_proxy.update(context: context)
allow_any_instance_of(AssignmentConfigurationToolLookup).to receive(:create_subscription).and_return true
Lti::ToolProxyBinding.create(context: context, tool_proxy: tool_proxy)
api_create_assignment_in_course(

View File

@ -53,7 +53,7 @@ describe CalendarEventsApiController, type: :request do
it 'should hide location attributes when user is not logged in a public course' do
@me = nil
@user = nil
@course.update_attributes(:is_public => true, :indexed => true)
@course.update(:is_public => true, :indexed => true)
@course.calendar_events.create(
:title => '2',
:start_at => '2012-01-08 12:00:00',
@ -69,7 +69,7 @@ describe CalendarEventsApiController, type: :request do
end
it 'should show location attributes when user logged in a public course' do
@course.update_attributes(:is_public => true, :indexed => true)
@course.update(:is_public => true, :indexed => true)
evt = @course.calendar_events.create(
:title => '2',
:start_at => '2012-01-08 12:00:00',
@ -136,7 +136,7 @@ describe CalendarEventsApiController, type: :request do
@e2 = @user.calendar_events.create!(:title => "today in AKST", :start_at => @akst.parse('2012-01-29 21:00:00')) { |c| c.context = @user }
@e3 = @user.calendar_events.create!(:title => "tomorrow in AKST", :start_at => @akst.parse('2012-01-30 21:00:00')) { |c| c.context = @user }
@user.update_attributes! :time_zone => "Alaska"
@user.update! :time_zone => "Alaska"
end
it "shows today's events in user's timezone, even if UTC has crossed into tomorrow" do

View File

@ -26,7 +26,7 @@ describe ConversationsController, type: :request do
course_with_teacher(:active_course => true, :active_enrollment => true, :user => user_with_pseudonym(:active_user => true))
@course.update_attribute(:name, "the course")
@course.account.role_overrides.create!(permission: 'send_messages_all', role: teacher_role, enabled: false)
@course.default_section.update_attributes(:name => "the section")
@course.default_section.update(:name => "the section")
@other_section = @course.course_sections.create(:name => "the other section")
@me = @user

View File

@ -323,7 +323,7 @@ describe Api::V1::Course do
it "should return blueprint restrictions by type" do
template = MasterCourses::MasterTemplate.set_as_master_course(@course1)
template.update_attributes(:use_default_restrictions_by_type => true,
template.update(:use_default_restrictions_by_type => true,
:default_restrictions_by_type =>
{"Assignment" => {:points => true},
"Quizzes::Quiz" => {:content => true}})
@ -431,7 +431,7 @@ describe CoursesController, type: :request do
course_with_student(:user => @user, :active_all => true)
@course2 = @course
@course2.update_attribute(:sis_source_id, 'TEST-SIS-ONE.2011')
@course2.update_attributes(:default_view => 'assignments')
@course2.update(:default_view => 'assignments')
@user.pseudonym.update_attribute(:sis_user_id, 'user1')
end
@ -1293,7 +1293,7 @@ describe CoursesController, type: :request do
context "when an assignment is due in a closed grading period" do
before(:once) do
@course.update_attributes(group_weighting_scheme: "equal")
@course.update(group_weighting_scheme: "equal")
@grading_period_group = Factories::GradingPeriodGroupHelper.new.create_for_account(@course.root_account)
term = @course.enrollment_term
term.grading_period_group = @grading_period_group
@ -1435,7 +1435,7 @@ describe CoursesController, type: :request do
context "when an assignment is due in a closed grading period" do
before :once do
@course.update_attributes(group_weighting_scheme: "equal")
@course.update(group_weighting_scheme: "equal")
@grading_period_group = Factories::GradingPeriodGroupHelper.new.create_for_account(@course.root_account)
term = @course.enrollment_term
term.grading_period_group = @grading_period_group
@ -3410,7 +3410,7 @@ describe CoursesController, type: :request do
describe "#show" do
it "should get individual course data" do
@course1.root_account.update_attributes(:default_time_zone => 'America/Los_Angeles')
@course1.root_account.update(:default_time_zone => 'America/Los_Angeles')
json = api_call(:get, "/api/v1/courses/#{@course1.id}.json",
{ :controller => 'courses', :action => 'show', :id => @course1.to_param, :format => 'json' })

View File

@ -780,7 +780,7 @@ describe DiscussionTopicsController, type: :request do
end
it "should properly translate a video media comment in the discussion topic's message" do
@topic.update_attributes(
@topic.update(
message: '<p><a id="media_comment_m-spHRwKY5ATHvPQAMKdZV_g" class="instructure_inline_media_comment video_comment" href="/media_objects/m-spHRwKY5ATHvPQAMKdZV_g">this is a media comment</a></p>'
)
@ -800,7 +800,7 @@ describe DiscussionTopicsController, type: :request do
end
it "should properly translate a audio media comment in the discussion topic's message" do
@topic.update_attributes(
@topic.update(
message: '<p><a id="media_comment_m-QgvagKCQATEtJAAMKdZV_g" class="instructure_inline_media_comment audio_comment"></a>this is a media comment</p>'
)
@ -2624,7 +2624,7 @@ describe DiscussionTopicsController, type: :request do
@reply3.change_read_state("read", @user)
# have the teacher edit one of the student's replies
@reply_reply1.editor = @teacher
@reply_reply1.update_attributes(:message => '<p>censored</p>')
@reply_reply1.update(:message => '<p>censored</p>')
@all_entries.each &:reload

View File

@ -736,7 +736,7 @@ describe EnrollmentsApiController, type: :request do
end
it "should not allow self-enrollment in a concluded course" do
@course.update_attributes(:start_at => 2.days.ago, :conclude_at => 1.day.ago,
@course.update(:start_at => 2.days.ago, :conclude_at => 1.day.ago,
:restrict_enrollments_to_course_dates => true)
json = raw_api_call :post, @path, @path_options,
{enrollment: {user_id: 'self', self_enrollment_code: @course.self_enrollment_code}}

View File

@ -190,7 +190,7 @@ describe ExternalToolsController, type: :request do
end
it "returns sessionless launch URL when default URL is not set and placement URL is" do
tool.update_attributes!(url: nil)
tool.update!(url: nil)
params = { id: tool.id.to_s, launch_type: 'course_navigation' }
json = get_sessionless_launch_url(@course, 'course', params)
expect(json).to include('url')

View File

@ -100,7 +100,7 @@ describe GradebookHistoryApiController, type: :request do
it 'routes properly and returns reasonable data' do
grader = user_with_pseudonym(:name => 'Grader', :username => 'grader@example.com', :active_all => 1)
@submission.update_attributes!(:graded_at => date, :grader_id => grader.id, :score => 100)
@submission.update!(:graded_at => date, :grader_id => grader.id, :score => 100)
json = api_call_as_user(@teacher, :get,
"/api/v1/courses/#{@course.id}/gradebook_history/#{date_str}/graders/#{grader.id}/assignments/#{@assignment.id}/submissions.json",
@ -118,7 +118,7 @@ describe GradebookHistoryApiController, type: :request do
end
it 'can find autograded data' do
@submission.update_attributes!(:graded_at => date, :grader_id => -50, :score => 100)
@submission.update!(:graded_at => date, :grader_id => -50, :score => 100)
json = api_call_as_user(@teacher, :get,
"/api/v1/courses/#{@course.id}/gradebook_history/#{date_str}/graders/0/assignments/#{@assignment.id}/submissions.json",
@ -162,13 +162,13 @@ describe GradebookHistoryApiController, type: :request do
def create_versions
@submission1.with_versioning(:explicit => true) {
@submission1.update_attributes!(:graded_at => Time.zone.now, :grader_id => @grader.id, :score => 100) }
@submission1.update!(:graded_at => Time.zone.now, :grader_id => @grader.id, :score => 100) }
@submission2.with_versioning(:explicit => true) {
@submission2.update_attributes!(:graded_at => Time.zone.now, :grader_id => @super_grader.id, :score => 90) }
@submission2.update!(:graded_at => Time.zone.now, :grader_id => @super_grader.id, :score => 90) }
@submission3.with_versioning(:explicit => true) {
@submission3.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80) }
@submission3.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80) }
@submission4.with_versioning(:explicit => true) {
@submission4.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70) }
@submission4.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70) }
end
it 'should return all applicable versions' do
@ -210,7 +210,7 @@ describe GradebookHistoryApiController, type: :request do
it 'should order the most recent versions first' do
@submission3.with_versioning(:explicit => true) {
@submission3.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80)
@submission3.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80)
}
json = api_call_as_user(@teacher, :get, "/api/v1/courses/#{@course.id}/gradebook_history/feed.json", {
@ -227,7 +227,7 @@ describe GradebookHistoryApiController, type: :request do
it 'should optionally restrict by assignment_id' do
@submission4.with_versioning(:explicit => true) {
@submission4.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70)
@submission4.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70)
}
json = api_call_as_user(@teacher, :get, "/api/v1/courses/#{@course.id}/gradebook_history/feed.json?assignment_id=#{@assignment2.id}", {
@ -244,7 +244,7 @@ describe GradebookHistoryApiController, type: :request do
it 'should optionally restrict by user_id' do
@submission4.with_versioning(:explicit => true) {
@submission4.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70)
@submission4.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 70)
}
json = api_call_as_user(@teacher, :get, "/api/v1/courses/#{@course.id}/gradebook_history/feed.json?user_id=#{@student1.id}", {
@ -261,7 +261,7 @@ describe GradebookHistoryApiController, type: :request do
it 'should optionally reverse ordering to oldest version first' do
@submission3.with_versioning(:explicit => true) {
@submission3.update_attributes!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80)
@submission3.update!(:graded_at => 24.hours.ago, :grader_id => @other_grader.id, :score => 80)
}
json = api_call_as_user(@teacher, :get, "/api/v1/courses/#{@course.id}/gradebook_history/feed.json?ascending=1", {

View File

@ -161,7 +161,7 @@ describe Api::V1::GradebookHistory do
let(:harness) { GradebookHistoryHarness.new }
let(:submission) do
s = assignment.submit_homework(student)
s.update_attributes(graded_at: now, score: 90, grade: '90', grader: grader)
s.update(graded_at: now, score: 90, grade: '90', grader: grader)
s
end
let(:course) do
@ -188,7 +188,7 @@ describe Api::V1::GradebookHistory do
@course.enroll_teacher(@grader2)
@assignment = @course.assignments.create!(:title => "some assignment")
@submission = @assignment.submit_homework(student1)
@submission.update_attributes(graded_at: now, grader_id: @grader1.id)
@submission.update(graded_at: now, grader_id: @grader1.id)
@submission.score = 90
@submission.grade = '90'
@submission.grader = @grader2

View File

@ -76,7 +76,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
term = Account.default.enrollment_terms.create!(:name => "termname")
child_course1 = course_factory(:course_name => "immachildcourse1", :active_all => true)
@teacher.update_attribute(:short_name, "displayname")
child_course1.update_attributes(:sis_source_id => "sisid", :course_code => "shortname", :enrollment_term => term)
child_course1.update(:sis_source_id => "sisid", :course_code => "shortname", :enrollment_term => term)
child_course2 = course_factory(:course_name => "immachildcourse2")
[child_course1, child_course2].each{|c| @template.add_child_course!(c)}
@ -372,7 +372,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
assmt_restricts = {:content => true, :points => true}
page_restricts = {:content => true}
@template.update_attributes(:use_default_restrictions_by_type => true,
@template.update(:use_default_restrictions_by_type => true,
:default_restrictions_by_type => {'Assignment' => assmt_restricts, 'WikiPage' => page_restricts})
api_call(:put, @url, @params, {:content_type => 'assignment', :content_id => assmt.id, :restricted => '1'}, {}, {:expected_status => 200})
@ -389,7 +389,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
assmt_restricts = {:content => true, :points => true}
quiz_restricts = {:content => true}
@template.update_attributes(:use_default_restrictions_by_type => true,
@template.update(:use_default_restrictions_by_type => true,
:default_restrictions_by_type => {'Assignment' => assmt_restricts, 'Quizzes::Quiz' => quiz_restricts})
api_call(:put, @url, @params, {:content_type => 'assignment', :content_id => quiz_assmt.id, :restricted => '1'}, {}, {:expected_status => 200})

View File

@ -24,7 +24,7 @@ describe SearchController, type: :request do
@account = Account.default
course_with_teacher(:active_course => true, :active_enrollment => true, :user => user_with_pseudonym(:active_user => true))
@course.update_attribute(:name, "the course")
@course.default_section.update_attributes(:name => "the section")
@course.default_section.update(:name => "the section")
@other_section = @course.course_sections.create(:name => "the other section")
@me = @user

View File

@ -115,7 +115,7 @@ describe UsersController, type: :request do
@course2.enroll_student(@student).accept!
@dt1 = discussion_topic_model(:context => @course1)
@dt2 = discussion_topic_model(:context => @course2)
@course2.update_attributes(:start_at => 2.weeks.ago, :conclude_at => 1.week.ago, :restrict_enrollments_to_course_dates => true)
@course2.update(:start_at => 2.weeks.ago, :conclude_at => 1.week.ago, :restrict_enrollments_to_course_dates => true)
end
json = api_call(:get, "/api/v1/users/self/activity_stream",
{ :controller => "users", :action => "activity_stream", :format => 'json' })
@ -368,7 +368,7 @@ describe UsersController, type: :request do
it "should format graded Submission with comments" do
#set @domain_root_account
@domain_root_account = Account.default
@domain_root_account.update_attributes(:default_time_zone => 'America/Denver')
@domain_root_account.update(:default_time_zone => 'America/Denver')
@assignment = @course.assignments.create!(:title => 'assignment 1', :description => 'hai', :points_possible => '14.2', :submission_types => 'online_text_entry')
@teacher = User.create!(:name => 'teacher')
@ -500,7 +500,7 @@ describe UsersController, type: :request do
it "should format ungraded Submission with comments" do
#set @domain_root_account
@domain_root_account = Account.default
@domain_root_account.update_attributes(:default_time_zone => 'America/Denver')
@domain_root_account.update(:default_time_zone => 'America/Denver')
@assignment = @course.assignments.create!(:title => 'assignment 1', :description => 'hai', :points_possible => '14.2', :submission_types => 'online_text_entry')
@teacher = User.create!(:name => 'teacher')

View File

@ -4017,7 +4017,7 @@ describe 'Submissions API', type: :request do
end
it "creates a online text submission" do
@assignment.update_attributes(:submission_types => 'online_text_entry')
@assignment.update(:submission_types => 'online_text_entry')
json = do_submit(:submission_type => 'online_text_entry', :body => %{<p>
This is <i>some</i> text. The <script src='evil.com'></script> sanitization will take effect.
</p>})
@ -4028,7 +4028,7 @@ describe 'Submissions API', type: :request do
end
it "processs html content in body" do
@assignment.update_attributes(:submission_types => 'online_text_entry')
@assignment.update(:submission_types => 'online_text_entry')
should_process_incoming_user_content(@course) do |content|
do_submit(:submission_type => 'online_text_entry', :body => content)
@submission.body
@ -4036,7 +4036,7 @@ describe 'Submissions API', type: :request do
end
it "creates a file upload submission" do
@assignment.update_attributes(:submission_types => 'online_upload')
@assignment.update(:submission_types => 'online_upload')
a1 = attachment_model(:context => @user)
a2 = attachment_model(:context => @user)
json = do_submit(:submission_type => 'online_upload', :file_ids => [a1.id, a2.id])
@ -4047,7 +4047,7 @@ describe 'Submissions API', type: :request do
end
it "creates a media comment submission" do
@assignment.update_attributes(:submission_types => "media_recording")
@assignment.update(:submission_types => "media_recording")
media_object(:media_id => "3232", :media_type => "audio")
json = do_submit(:submission_type => "media_recording", :media_comment_id => "3232", :media_comment_type => "audio")
expect(json['media_comment'].slice('media_id', 'media_type')).to eq({
@ -4057,7 +4057,7 @@ describe 'Submissions API', type: :request do
end
it "copys files to the submissions folder if they're not there already" do
@assignment.update_attributes(:submission_types => 'online_upload')
@assignment.update(:submission_types => 'online_upload')
a1 = attachment_model(:context => @user, :folder => @user.submissions_folder)
a2 = attachment_model(:context => @user)
json = do_submit(:submission_type => 'online_upload', :file_ids => [a1.id, a2.id])
@ -4072,7 +4072,7 @@ describe 'Submissions API', type: :request do
context "submission file uploads" do
before :once do
@assignment.update_attributes(:submission_types => 'online_upload')
@assignment.update(:submission_types => 'online_upload')
@student1 = @student
course_with_student(:course => @course)
@context = @course
@ -4127,19 +4127,19 @@ describe 'Submissions API', type: :request do
end
it "rejects uploading files when filetype is not allowed" do
@assignment.update_attributes(:allowed_extensions => ['doc'])
@assignment.update(:allowed_extensions => ['doc'])
preflight(name: 'test.txt', size: 12345, content_type: 'text/plain')
assert_status(400)
end
it "allows filetype when restricted and is correct filetype" do
@assignment.update_attributes(:allowed_extensions => ['txt'])
@assignment.update(:allowed_extensions => ['txt'])
preflight(name: 'test.txt', size: 12345, content_type: 'text/plain')
assert_status(200)
end
it "falls back to parsing the extension when an unknown type" do
@assignment.update_attributes(:allowed_extensions => ['beepboop'])
@assignment.update(:allowed_extensions => ['beepboop'])
preflight(name: 'test.beepboop', size: 12345)
assert_status(200)
end
@ -4240,7 +4240,7 @@ describe 'Submissions API', type: :request do
end
it "rejects attachment ids not belonging to the user" do
@assignment.update_attributes(:submission_types => 'online_upload')
@assignment.update(:submission_types => 'online_upload')
a1 = attachment_model(:context => @course)
json = api_call(:post, @url, @args, { :submission => { :submission_type => "online_upload", :file_ids => [a1.id] } }, {}, :expected_status => 400)
expect(json['message']).to eq 'No valid file ids given'

View File

@ -94,8 +94,8 @@ describe TermsApiController, type: :request do
describe "ordering" do
it "should order by start_at first" do
@term1.update_attributes(start_at: 1.day.ago, end_at: 5.days.from_now)
@term2.update_attributes(start_at: 2.days.ago, end_at: 6.days.from_now)
@term1.update(start_at: 1.day.ago, end_at: 5.days.from_now)
@term2.update(start_at: 2.days.ago, end_at: 6.days.from_now)
json = get_terms
expect(json.first['name']).to eq @term1.name
@ -104,8 +104,8 @@ describe TermsApiController, type: :request do
it "should order by end_at second" do
start_at = 1.day.ago
@term1.update_attributes(start_at: start_at, end_at: 6.days.from_now)
@term2.update_attributes(start_at: start_at, end_at: 5.days.from_now)
@term1.update(start_at: start_at, end_at: 6.days.from_now)
@term2.update(start_at: start_at, end_at: 5.days.from_now)
json = get_terms
expect(json.first['name']).to eq @term1.name
@ -115,8 +115,8 @@ describe TermsApiController, type: :request do
it "should order by id last" do
start_at = 1.day.ago
end_at = 5.days.from_now
@term1.update_attributes(start_at: start_at, end_at: end_at)
@term2.update_attributes(start_at: start_at, end_at: end_at)
@term1.update(start_at: start_at, end_at: end_at)
@term2.update(start_at: start_at, end_at: end_at)
json = get_terms
expect(json.first['name']).to eq @term1.name
@ -401,7 +401,7 @@ describe TermsController, type: :request do
end
it "allows removing sis_term_id with :manage_sis permission" do
@term1.update_attributes(sis_source_id: 'SIS Term 2')
@term1.update(sis_source_id: 'SIS Term 2')
expect(@account.grants_right?(@user, :manage_sis)).to be_truthy
json = api_call(:put, "/api/v1/accounts/#{@account.id}/terms/#{@term1.id}",
{ controller: 'terms', action: 'update', format: 'json', account_id: @account.to_param, id: @term1.to_param },

View File

@ -136,7 +136,7 @@ describe UsersController, type: :request do
end
it 'should not crash when mixing items with/without due dates (users controller)' do
@a2.update_attributes(due_at: nil)
@a2.update(due_at: nil)
api_call(:get, "/api/v1/users/self/todo",
controller: "users", action: "todo_items", format: "json")
expect(response).to be_successful
@ -144,7 +144,7 @@ describe UsersController, type: :request do
it 'should not crash when mixing items with/without due dates (courses controller)' do
@teacher_course.enroll_student(@teacher).accept!
@a2.update_attributes(due_at: nil)
@a2.update(due_at: nil)
Assignment.create!(context: @teacher_course, due_at: 1.day.from_now, title: 'text', submission_types: 'online_text_entry', points_possible: 15)
api_call(:get, "/api/v1/courses/#{@teacher_course.id}/todo",
controller: "courses", action: "todo_items",

View File

@ -1692,13 +1692,13 @@ describe "Users API", type: :request do
it "should be able to update a name without changing sortable name if sent together" do
sortable = "Name, Sortable"
@student.update_attributes(:name => "Sortable Name", :sortable_name => sortable)
@student.update(:name => "Sortable Name", :sortable_name => sortable)
api_call(:put, @path, @path_options, {
:user => {:name => "Other Name", :sortable_name => sortable}
})
expect(@student.reload.sortable_name).to eq sortable
@student.update_attributes(:name => "Sortable Name", :sortable_name => sortable) # reset
@student.update(:name => "Sortable Name", :sortable_name => sortable) # reset
api_call(:put, @path, @path_options, {:user => {:name => "Other Name"}}) # only send in the name
expect(@student.reload.sortable_name).to eq "Name, Other" # should auto sync
end

View File

@ -566,7 +566,7 @@ RSpec.describe ApplicationController do
allow(content_tag).to receive(:id).and_return(42)
allow(controller).to receive(:require_user) { user_model }
allow(controller).to receive(:lti_launch_params) {{}}
content_tag.update_attributes!(context: assignment_model)
content_tag.update!(context: assignment_model)
end
context 'display_type == "full_width' do
@ -632,7 +632,7 @@ RSpec.describe ApplicationController do
allow(controller).to receive(:require_user) { user_model }
controller.instance_variable_set(:@current_user, user)
controller.instance_variable_set(:@domain_root_account, course.account)
content_tag.update_attributes!(context: assignment_model)
content_tag.update!(context: assignment_model)
end
describe 'LTI 1.3' do
@ -651,7 +651,7 @@ RSpec.describe ApplicationController do
tool.save!
assignment = assignment_model(submission_types: 'external_tool', external_tool_tag: content_tag)
content_tag.update_attributes!(context: assignment)
content_tag.update!(context: assignment)
end
shared_examples_for 'a placement that caches the launch' do
@ -745,7 +745,7 @@ RSpec.describe ApplicationController do
context 'return_url' do
before do
controller.instance_variable_set(:"@context", course)
content_tag.update_attributes!(context: assignment_model)
content_tag.update!(context: assignment_model)
allow(content_tag.context).to receive(:quiz_lti?).and_return(true)
allow(controller).to receive(:render)
allow(controller).to receive(:lti_launch_params)

View File

@ -500,7 +500,7 @@ describe AssignmentGroupsController do
Factories::GradingPeriodHelper.new.create_for_group(group, {
start_date: 2.days.ago, end_date: 2.days.from_now, close_date: 3.days.from_now
})
@assignment1.update_attributes(due_at: 1.week.ago)
@assignment1.update(due_at: 1.week.ago)
end
it 'does not allow assignments in closed grading periods to be moved into different assignment groups' do

View File

@ -390,7 +390,7 @@ describe AssignmentsController do
end
before :each do
@assignment.update_attributes(
@assignment.update(
moderated_grading: true,
final_grader: @other_teacher,
grader_count: 2
@ -592,7 +592,7 @@ describe AssignmentsController do
it "should assign 'similarity_pledge'" do
pledge = 'I made this'
@course.account.update_attributes(turnitin_pledge: pledge)
@course.account.update(turnitin_pledge: pledge)
get 'show', params: {:course_id => @course.id, :id => assignment.id}
expect(assigns[:similarity_pledge]).to eq pledge
end
@ -621,7 +621,7 @@ describe AssignmentsController do
a = @course.assignments.create(:title => "some assignment")
pledge = 'tii pledge'
allow_any_instance_of(Assignment).to receive(:turnitin_enabled?).and_return(true)
@course.account.update_attributes(turnitin_pledge: pledge)
@course.account.update(turnitin_pledge: pledge)
get 'show', params: {:course_id => @course.id, :id => a.id}
expect(assigns[:similarity_pledge]).to eq pledge
end
@ -1492,7 +1492,7 @@ describe AssignmentsController do
allow_any_instance_of(AssignmentConfigurationToolLookup).to receive(:create_subscription).and_return true
allow(Lti::ToolProxy).to receive(:find_active_proxies_for_context).with(@course) { Lti::ToolProxy.where(id: tool_proxy.id) }
tool_proxy.resources << resource_handler
tool_proxy.update_attributes!(context: @course)
tool_proxy.update!(context: @course)
AssignmentConfigurationToolLookup.create!(
assignment: @assignment,

View File

@ -47,7 +47,7 @@ describe Bookmarks::BookmarksController do
end
it "includes data" do
bookmark.update_attributes(data: {foo: "bar"})
bookmark.update(data: {foo: "bar"})
get 'show', params: {id: bookmark.id}, format: 'json'
json = json_parse
expect(json["data"]["foo"]).to eq("bar")

View File

@ -1256,7 +1256,7 @@ describe CommunicationChannelsController do
it "should not re-send registration to a registered user when trying to re-send invitation for an unavailable course" do
course_with_teacher_logged_in(active_all: true)
@course.update_attributes(:start_at => 1.week.from_now, :restrict_student_future_view => true,
@course.update(:start_at => 1.week.from_now, :restrict_student_future_view => true,
:restrict_enrollments_to_course_dates => true)
user_with_pseudonym(:active_all => true) # new user

View File

@ -45,7 +45,7 @@ describe ConversationsController do
conversation
term = @course.root_account.enrollment_terms.create! :name => "Fall"
@course.update_attributes! :enrollment_term => term
@course.update! :enrollment_term => term
get 'index'
expect(response).to be_successful

View File

@ -129,7 +129,7 @@ describe CoursesController do
inactive_enroll = @course.enroll_student(@student, :section => section2, :allow_multiple_enrollments => true)
inactive_enroll.deactivate
@course.update_attributes(:start_at => 2.days.ago, :conclude_at => 1.day.ago, :restrict_enrollments_to_course_dates => true)
@course.update(:start_at => 2.days.ago, :conclude_at => 1.day.ago, :restrict_enrollments_to_course_dates => true)
user_session(@student)
@ -206,13 +206,13 @@ describe CoursesController do
# section date in past
course1 = Account.default.courses.create! start_at: 2.months.ago, conclude_at: 1.month.from_now
course1.default_section.update_attributes(:end_at => 1.month.ago)
course1.default_section.update(:end_at => 1.month.ago)
course1.offer!
enrollment1 = course_with_student course: course1, user: @student, active_all: true
# by section date, in future
course2 = Account.default.courses.create! start_at: 2.months.ago, conclude_at: 1.month.ago
course2.default_section.update_attributes(:end_at => 1.month.from_now)
course2.default_section.update(:end_at => 1.month.from_now)
course2.offer!
enrollment2 = course_with_student course: course2, user: @student, active_all: true
@ -790,9 +790,9 @@ describe CoursesController do
it "should accept an enrollment for a restricted by dates course" do
course_with_student_logged_in(:active_all => true)
@course.update_attributes(:restrict_enrollments_to_course_dates => true,
@course.update(:restrict_enrollments_to_course_dates => true,
:start_at => Time.now + 2.weeks)
@enrollment.update_attributes(:workflow_state => 'invited', last_activity_at: nil)
@enrollment.update(:workflow_state => 'invited', last_activity_at: nil)
post 'enrollment_invitation', params: {:course_id => @course.id, :accept => '1',
:invitation => @enrollment.uuid}

View File

@ -364,7 +364,7 @@ describe DiscussionEntriesController do
end
it 'respects podcast_has_student_posts for course discussions' do
@topic.update_attributes(podcast_enabled: true, podcast_has_student_posts: false)
@topic.update(podcast_enabled: true, podcast_has_student_posts: false)
get 'public_feed', params: {:discussion_topic_id => @topic.id, :feed_code => @enrollment.feed_code}, :format => 'rss'
expect(assigns[:discussion_entries].length).to eql 0
end
@ -375,7 +375,7 @@ describe DiscussionEntriesController do
@topic = @group.discussion_topics.create(title: "group topic", user: @teacher)
@entry = @topic.discussion_entries.create(message: "some message", user: @student)
@topic.update_attributes(podcast_enabled: true, podcast_has_student_posts: false)
@topic.update(podcast_enabled: true, podcast_has_student_posts: false)
get 'public_feed', params: {:discussion_topic_id => @topic.id, :feed_code => membership.feed_code}, :format => 'rss'
expect(assigns[:discussion_entries].length).to eql 1
end

View File

@ -1006,7 +1006,7 @@ describe DiscussionTopicsController do
it 'should remove a todo date from a topic' do
user_session(@teacher)
@topic.update_attributes(todo_date: 1.day.from_now.in_time_zone('America/New_York'))
@topic.update(todo_date: 1.day.from_now.in_time_zone('America/New_York'))
put 'update', params: {course_id: @course.id, topic_id: @topic.id, todo_date: nil}, format: 'json'
expect(@topic.reload.todo_date).to be nil
end
@ -1046,7 +1046,7 @@ describe DiscussionTopicsController do
it 'should remove an existing todo date when changing a topic from ungraded to graded' do
user_session(@teacher)
@topic.update_attributes(todo_date: 1.day.from_now)
@topic.update(todo_date: 1.day.from_now)
put 'update', params: {course_id: @course.id, topic_id: @topic.id,
assignment: {submission_types: ['discussion_topic'], name: 'Graded Topic 1'}}, format: 'json'
expect(response.code).to eq '200'

View File

@ -1720,7 +1720,7 @@ describe ExternalToolsController do
it 'redirects if there is no launch url associated with the tool' do
no_url_tool = new_valid_tool(@course)
no_url_tool.update_attributes!(url: nil)
no_url_tool.update!(url: nil)
params = {:course_id => @course.id, id: no_url_tool.id}
expect(get :generate_sessionless_launch, params: params).to redirect_to course_url(@course)
end

View File

@ -49,10 +49,10 @@ describe GradebookHistoryApiController do
@submission3 = @assignment1.submit_homework(student3)
@submission4 = @assignment2.submit_homework(student)
@submission1.update_attributes!(:graded_at => Time.now, :grader_id => @grader.id, :score => 100)
@submission2.update_attributes!(:graded_at => Time.now, :grader_id => @super_grader.id, :score => 90)
@submission3.update_attributes!(:graded_at => (Time.now - 24.hours), :grader_id => @other_grader.id, :score => 80)
@submission4.update_attributes!(:graded_at => (Time.now - 24.hours), :grader_id => @other_grader.id, :score => 70)
@submission1.update!(:graded_at => Time.now, :grader_id => @grader.id, :score => 100)
@submission2.update!(:graded_at => Time.now, :grader_id => @super_grader.id, :score => 90)
@submission3.update!(:graded_at => (Time.now - 24.hours), :grader_id => @other_grader.id, :score => 80)
@submission4.update!(:graded_at => (Time.now - 24.hours), :grader_id => @other_grader.id, :score => 70)
end
before :each do

View File

@ -753,7 +753,7 @@ describe GroupsController do
@group.add_user(@student2)
@group.add_user(@student3)
@student2.enrollments.first.deactivate
@student3.enrollments.first.update_attributes(:start_at => 1.day.from_now, :end_at => 2.days.from_now) # technically "inactive" but not really
@student3.enrollments.first.update(:start_at => 1.day.from_now, :end_at => 2.days.from_now) # technically "inactive" but not really
end
it "include active status if requested" do

View File

@ -116,7 +116,7 @@ module Lti
end
it 'responds with 404 if course is concluded' do
course.update_attributes!(workflow_state: 'completed')
course.update!(workflow_state: 'completed')
send_request
expect(response).to be_not_found
end
@ -321,7 +321,7 @@ module Lti
context do
let(:line_item_two) do
li = line_item_model(resource_link: resource_link, assignment: assignment)
li.update_attributes!(created_at: line_item.created_at + 5.seconds)
li.update!(created_at: line_item.created_at + 5.seconds)
li
end
let(:line_item_id) { line_item_two.id }
@ -341,7 +341,7 @@ module Lti
let(:line_item) { assignment.line_items.first }
it 'updates the assignment name if ResourceLink is absent' do
line_item.update_attributes!(resource_link: nil)
line_item.update!(resource_link: nil)
send_request
expect(line_item.reload.assignment.name).to eq new_label
end

Some files were not shown because too many files have changed in this diff Show More