bump rubocop-performance
and apply new fixes [skip-stages=Flakey] Change-Id: Ie2f9057a435076c4b872175651cedf737b2c5696 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315800 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> Build-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
4d96f5ed1e
commit
480e29c4d5
|
@ -32,7 +32,7 @@ group :test do
|
|||
|
||||
gem "rubocop", "1.49.0", require: false
|
||||
gem "rubocop-canvas", require: false, path: "gems/rubocop-canvas"
|
||||
gem "rubocop-performance", "1.12.0", require: false
|
||||
gem "rubocop-performance", "1.17.1", require: false
|
||||
gem "rubocop-rails", "2.12.4", require: false
|
||||
gem "rubocop-rake", "0.6.0", require: false
|
||||
gem "rubocop-rspec", "2.6.0", require: false
|
||||
|
|
|
@ -974,7 +974,7 @@ GEM
|
|||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.28.0)
|
||||
parser (>= 3.2.1.0)
|
||||
rubocop-performance (1.12.0)
|
||||
rubocop-performance (1.17.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.12.4)
|
||||
|
@ -1356,7 +1356,7 @@ DEPENDENCIES
|
|||
rss (= 0.2.9)
|
||||
rubocop (= 1.49.0)
|
||||
rubocop-canvas!
|
||||
rubocop-performance (= 1.12.0)
|
||||
rubocop-performance (= 1.17.1)
|
||||
rubocop-rails (= 2.12.4)
|
||||
rubocop-rake (= 0.6.0)
|
||||
rubocop-rspec (= 2.6.0)
|
||||
|
|
|
@ -57,7 +57,7 @@ class AnnouncementsController < ApplicationController
|
|||
|
||||
def index
|
||||
return unless authorized_action(@context, @current_user, :read)
|
||||
return if @context.class.const_defined?("TAB_ANNOUNCEMENTS") && !tab_enabled?(@context.class::TAB_ANNOUNCEMENTS)
|
||||
return if @context.class.const_defined?(:TAB_ANNOUNCEMENTS) && !tab_enabled?(@context.class::TAB_ANNOUNCEMENTS)
|
||||
|
||||
redirect_to named_context_url(@context, :context_url) if @context.is_a?(Course) && @context.elementary_homeroom_course?
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class AssignmentsController < ApplicationController
|
|||
add_crumb(
|
||||
proc { t "#crumbs.assignments", "Assignments" },
|
||||
except: %i[destroy syllabus index new edit]
|
||||
) { |c| c.send :course_assignments_path, c.instance_variable_get("@context") }
|
||||
) { |c| c.send :course_assignments_path, c.instance_variable_get(:@context) }
|
||||
before_action(except: [:new, :edit]) { |c| c.active_tab = "assignments" }
|
||||
before_action(only: [:new, :edit]) { |c| setup_active_tab(c) }
|
||||
before_action :normalize_title_param, only: [:new, :edit]
|
||||
|
|
|
@ -1117,7 +1117,7 @@ class CalendarEventsApiController < ApplicationController
|
|||
get_all_pertinent_contexts
|
||||
GuardRail.activate(:secondary) do
|
||||
@contexts.each do |context|
|
||||
@assignments = context.assignments.active.to_a if context.respond_to?("assignments")
|
||||
@assignments = context.assignments.active.to_a if context.respond_to?(:assignments)
|
||||
# no overrides to apply without a current user
|
||||
@events.concat context.calendar_events.active.to_a
|
||||
@events.concat @assignments || []
|
||||
|
|
|
@ -24,7 +24,7 @@ class CalendarEventsController < ApplicationController
|
|||
before_action :require_context
|
||||
before_action :rce_js_env, only: [:new, :edit]
|
||||
|
||||
add_crumb(proc { t(:"#crumbs.calendar_events", "Calendar Events") }, only: %i[show new edit]) { |c| c.send :calendar_url_for, c.instance_variable_get("@context") }
|
||||
add_crumb(proc { t(:"#crumbs.calendar_events", "Calendar Events") }, only: %i[show new edit]) { |c| c.send :calendar_url_for, c.instance_variable_get(:@context) }
|
||||
|
||||
def show
|
||||
@event = @context.calendar_events.find(params[:id])
|
||||
|
|
|
@ -63,18 +63,18 @@ class CalendarsController < ApplicationController
|
|||
id: context.id,
|
||||
type: context.class.to_s.downcase,
|
||||
url: named_context_url(context, :context_url),
|
||||
create_calendar_event_url: context.respond_to?("calendar_events") ? named_context_url(context, :context_calendar_events_url) : "",
|
||||
create_assignment_url: context.respond_to?("assignments") ? named_context_url(context, :api_v1_context_assignments_url) : "",
|
||||
create_appointment_group_url: context.respond_to?("appointment_groups") ? api_v1_appointment_groups_url : "",
|
||||
new_calendar_event_url: context.respond_to?("calendar_events") ? named_context_url(context, :new_context_calendar_event_url) : "",
|
||||
new_assignment_url: context.respond_to?("assignments") ? named_context_url(context, :new_context_assignment_url) : "",
|
||||
calendar_event_url: context.respond_to?("calendar_events") ? named_context_url(context, :context_calendar_event_url, "{{ id }}") : "",
|
||||
assignment_url: context.respond_to?("assignments") ? named_context_url(context, :api_v1_context_assignment_url, "{{ id }}") : "",
|
||||
create_calendar_event_url: context.respond_to?(:calendar_events) ? named_context_url(context, :context_calendar_events_url) : "",
|
||||
create_assignment_url: context.respond_to?(:assignments) ? named_context_url(context, :api_v1_context_assignments_url) : "",
|
||||
create_appointment_group_url: context.respond_to?(:appointment_groups) ? api_v1_appointment_groups_url : "",
|
||||
new_calendar_event_url: context.respond_to?(:calendar_events) ? named_context_url(context, :new_context_calendar_event_url) : "",
|
||||
new_assignment_url: context.respond_to?(:assignments) ? named_context_url(context, :new_context_assignment_url) : "",
|
||||
calendar_event_url: context.respond_to?(:calendar_events) ? named_context_url(context, :context_calendar_event_url, "{{ id }}") : "",
|
||||
assignment_url: context.respond_to?(:assignments) ? named_context_url(context, :api_v1_context_assignment_url, "{{ id }}") : "",
|
||||
assignment_override_url: context.respond_to?(:assignments) ? api_v1_assignment_override_url(course_id: context.id, assignment_id: "{{ assignment_id }}", id: "{{ id }}") : "",
|
||||
appointment_group_url: context.respond_to?("appointment_groups") ? api_v1_appointment_groups_url(id: "{{ id }}") : "",
|
||||
can_create_calendar_events: context.respond_to?("calendar_events") && CalendarEvent.new.tap { |e| e.context = context }.grants_right?(@current_user, session, :create),
|
||||
can_create_assignments: context.respond_to?("assignments") && Assignment.new.tap { |a| a.context = context }.grants_right?(@current_user, session, :create),
|
||||
assignment_groups: context.respond_to?("assignments") ? context.assignment_groups.active.pluck(:id, :name).map { |id, name| { id: id, name: name } } : [],
|
||||
appointment_group_url: context.respond_to?(:appointment_groups) ? api_v1_appointment_groups_url(id: "{{ id }}") : "",
|
||||
can_create_calendar_events: context.respond_to?(:calendar_events) && CalendarEvent.new.tap { |e| e.context = context }.grants_right?(@current_user, session, :create),
|
||||
can_create_assignments: context.respond_to?(:assignments) && Assignment.new.tap { |a| a.context = context }.grants_right?(@current_user, session, :create),
|
||||
assignment_groups: context.respond_to?(:assignments) ? context.assignment_groups.active.pluck(:id, :name).map { |id, name| { id: id, name: name } } : [],
|
||||
can_create_appointment_groups: ag_permission,
|
||||
can_make_reservation: context.grants_right?(@current_user, :participate_as_student),
|
||||
can_update_todo_date: context.grants_any_right?(@current_user, session, :manage_content, :manage_course_content_edit),
|
||||
|
@ -87,7 +87,7 @@ class CalendarsController < ApplicationController
|
|||
default_due_time: context.is_a?(Course) && context.default_due_time,
|
||||
can_view_context: context.grants_right?(@current_user, session, :read)
|
||||
}
|
||||
if context.respond_to?("course_sections")
|
||||
if context.respond_to?(:course_sections)
|
||||
info[:course_sections] = context.course_sections.active.pluck(:id, :name).map do |id, name|
|
||||
hash = { id: id, asset_string: "course_section_#{id}", name: name }
|
||||
if ag_permission
|
||||
|
@ -111,7 +111,7 @@ class CalendarsController < ApplicationController
|
|||
DUE_DATE_REQUIRED_FOR_ACCOUNT: due_date_required_for_account
|
||||
}
|
||||
end
|
||||
if ag_permission && ag_permission[:all_sections] && context.respond_to?("group_categories")
|
||||
if ag_permission && ag_permission[:all_sections] && context.respond_to?(:group_categories)
|
||||
info[:group_categories] = context.group_categories.active.pluck(:id, :name).map { |id, name| { id: id, asset_string: "group_category_#{id}", name: name } }
|
||||
end
|
||||
info
|
||||
|
|
|
@ -23,7 +23,7 @@ class ContextModulesController < ApplicationController
|
|||
include WebZipExportHelper
|
||||
|
||||
before_action :require_context
|
||||
add_crumb(proc { t("#crumbs.modules", "Modules") }) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_context_modules_url }
|
||||
add_crumb(proc { t("#crumbs.modules", "Modules") }) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_context_modules_url }
|
||||
before_action { |c| c.active_tab = "modules" }
|
||||
|
||||
include K5Mode
|
||||
|
|
|
@ -39,7 +39,7 @@ class GradebooksController < ApplicationController
|
|||
|
||||
batch_jobs_in_actions only: :update_submission, batch: { priority: Delayed::LOW_PRIORITY }
|
||||
|
||||
add_crumb(proc { t "#crumbs.grades", "Grades" }) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_grades_url }
|
||||
add_crumb(proc { t "#crumbs.grades", "Grades" }) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_grades_url }
|
||||
before_action { |c| c.active_tab = "grades" }
|
||||
|
||||
MAX_POST_GRADES_TOOLS = 10
|
||||
|
|
|
@ -23,7 +23,7 @@ class GradingStandardsController < ApplicationController
|
|||
%i[display_name context_code assessed_assignment? context_name].freeze
|
||||
|
||||
before_action :require_context
|
||||
add_crumb(proc { t "#crumbs.grading_standards", "Grading" }) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_grading_standards_url }
|
||||
add_crumb(proc { t "#crumbs.grading_standards", "Grading" }) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_grading_standards_url }
|
||||
before_action { |c| c.active_tab = "grading_standards" }
|
||||
|
||||
def index
|
||||
|
|
|
@ -23,7 +23,7 @@ class OutcomesController < ApplicationController
|
|||
include Api::V1::Role
|
||||
|
||||
before_action :require_context, except: [:build_outcomes]
|
||||
add_crumb(proc { t "#crumbs.outcomes", "Outcomes" }, except: [:destroy, :build_outcomes]) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_outcomes_path }
|
||||
add_crumb(proc { t "#crumbs.outcomes", "Outcomes" }, except: [:destroy, :build_outcomes]) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_outcomes_path }
|
||||
before_action { |c| c.active_tab = "outcomes" }
|
||||
before_action :rce_js_env, only: [:show, :index]
|
||||
|
||||
|
|
|
@ -525,6 +525,6 @@ class ProfileController < ApplicationController
|
|||
end
|
||||
|
||||
def instructure_misc_plugin_available?
|
||||
Object.const_defined?("InstructureMiscPlugin")
|
||||
Object.const_defined?(:InstructureMiscPlugin)
|
||||
end
|
||||
private :instructure_misc_plugin_available?
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
class QuestionBanksController < ApplicationController
|
||||
before_action :require_context, except: :bookmark
|
||||
add_crumb(proc { t("#crumbs.question_banks", "Question Banks") }, except: :bookmark) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_question_banks_url }
|
||||
add_crumb(proc { t("#crumbs.question_banks", "Question Banks") }, except: :bookmark) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_question_banks_url }
|
||||
|
||||
include Api::V1::Outcome
|
||||
include QuizMathDataFixup
|
||||
|
|
|
@ -37,7 +37,7 @@ class Quizzes::QuizzesController < ApplicationController
|
|||
|
||||
include K5Mode
|
||||
|
||||
add_crumb(proc { t("#crumbs.quizzes", "Quizzes") }) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_quizzes_url }
|
||||
add_crumb(proc { t("#crumbs.quizzes", "Quizzes") }) { |c| c.send :named_context_url, c.instance_variable_get(:@context), :context_quizzes_url }
|
||||
before_action { |c| c.active_tab = "quizzes" }
|
||||
before_action :require_quiz, only: %i[
|
||||
statistics
|
||||
|
|
|
@ -33,8 +33,8 @@ class WikiPagesController < ApplicationController
|
|||
include K5Mode
|
||||
|
||||
add_crumb(proc { t "#crumbs.wiki_pages", "Pages" }) do |c|
|
||||
context = c.instance_variable_get("@context")
|
||||
current_user = c.instance_variable_get("@current_user")
|
||||
context = c.instance_variable_get(:@context)
|
||||
current_user = c.instance_variable_get(:@current_user)
|
||||
if context.grants_right?(current_user, :read)
|
||||
c.send :polymorphic_path, [context, :wiki_pages]
|
||||
end
|
||||
|
|
|
@ -1520,7 +1520,7 @@ class Assignment < ActiveRecord::Base
|
|||
case grade.to_s
|
||||
when /^[+-]?\d*\.?\d+%$/
|
||||
# interpret as a percentage
|
||||
percentage = grade.to_f / 100.0.to_d
|
||||
percentage = grade.to_f / BigDecimal("100.0")
|
||||
points_possible.to_f * percentage
|
||||
when /^[+-]?\d*\.?\d+$/
|
||||
if !prefer_points_over_scheme && uses_grading_standard && (standard_based_score = grading_standard_or_default.grade_to_score(grade))
|
||||
|
@ -1535,7 +1535,7 @@ class Assignment < ActiveRecord::Base
|
|||
else
|
||||
# try to treat it as a letter grade
|
||||
if uses_grading_standard && (standard_based_score = grading_standard_or_default.grade_to_score(grade))
|
||||
((points_possible || 0.0).to_d * standard_based_score.to_d / 100.0.to_d).to_f
|
||||
((points_possible || 0.0).to_d * standard_based_score.to_d / BigDecimal("100.0")).to_f
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -748,7 +748,7 @@ class Attachment < ActiveRecord::Base
|
|||
GuardRail.activate(:secondary) do
|
||||
context.shard.activate do
|
||||
quota = Setting.get("context_default_quota", 50.megabytes.to_s).to_i
|
||||
quota = context.quota if context.respond_to?("quota") && context.quota
|
||||
quota = context.quota if context.respond_to?(:quota) && context.quota
|
||||
|
||||
attachment_scope = context.attachments.active.where(root_attachment_id: nil)
|
||||
|
||||
|
|
|
@ -329,11 +329,11 @@ class ContentTag < ActiveRecord::Base
|
|||
return unless asset_context_matches?
|
||||
|
||||
# Assignment proxies name= and name to title= and title, which breaks the asset_safe_title logic
|
||||
if content.respond_to?("name=") && content.respond_to?("name") && !content.is_a?(Assignment)
|
||||
if content.respond_to?(:name=) && content.respond_to?(:name) && !content.is_a?(Assignment)
|
||||
content.name = asset_safe_title("name")
|
||||
elsif content.respond_to?("title=")
|
||||
elsif content.respond_to?(:title=)
|
||||
content.title = asset_safe_title("title")
|
||||
elsif content.respond_to?("display_name=")
|
||||
elsif content.respond_to?(:display_name=)
|
||||
content.display_name = asset_safe_title("display_name")
|
||||
end
|
||||
if content.changed?
|
||||
|
|
|
@ -112,10 +112,10 @@ class GradingStandard < ActiveRecord::Base
|
|||
# grade cutoffs.
|
||||
# otherwise, we step down just 1/10th of a point, which is the
|
||||
# granularity we support right now
|
||||
elsif idx && (ordered_scheme[idx].last - ordered_scheme[idx - 1].last).abs >= 0.01.to_d
|
||||
(ordered_scheme[idx - 1].last * 100.0.to_d) - 1.0.to_d
|
||||
elsif idx && (ordered_scheme[idx].last - ordered_scheme[idx - 1].last).abs >= BigDecimal("0.01")
|
||||
(ordered_scheme[idx - 1].last * BigDecimal("100.0")) - BigDecimal("1.0")
|
||||
elsif idx
|
||||
(ordered_scheme[idx - 1].last * 100.0.to_d) - 0.1.to_d
|
||||
(ordered_scheme[idx - 1].last * BigDecimal("100.0")) - BigDecimal("0.1")
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
@ -127,7 +127,7 @@ class GradingStandard < ActiveRecord::Base
|
|||
# assign the highest grade whose min cutoff is less than the score
|
||||
# if score is less than all scheme cutoffs, assign the lowest grade
|
||||
score = BigDecimal(score.to_s) # Cast this to a BigDecimal too or comparisons get wonky
|
||||
ordered_scheme.max_by { |_, lower_bound| (score >= lower_bound * 100.0.to_d) ? lower_bound : -lower_bound }[0]
|
||||
ordered_scheme.max_by { |_, lower_bound| (score >= lower_bound * BigDecimal("100.0")) ? lower_bound : -lower_bound }[0]
|
||||
end
|
||||
|
||||
def data=(new_val)
|
||||
|
|
|
@ -136,13 +136,13 @@ class Group < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def all_real_students
|
||||
return context.all_real_students.where(users: { id: group_memberships.select(:user_id) }) if context.respond_to? "all_real_students"
|
||||
return context.all_real_students.where(users: { id: group_memberships.select(:user_id) }) if context.respond_to? :all_real_students
|
||||
|
||||
users
|
||||
end
|
||||
|
||||
def all_real_student_enrollments
|
||||
return context.all_real_student_enrollments.where(user_id: group_memberships.select(:user_id)) if context.respond_to? "all_real_student_enrollments"
|
||||
return context.all_real_student_enrollments.where(user_id: group_memberships.select(:user_id)) if context.respond_to? :all_real_student_enrollments
|
||||
|
||||
group_memberships
|
||||
end
|
||||
|
|
|
@ -255,7 +255,7 @@ class Message < ActiveRecord::Base
|
|||
tap do
|
||||
@table = klass.arel_table_from_key_values(attrs)
|
||||
@predicate_builder = predicate_builder.dup
|
||||
@predicate_builder.instance_variable_set("@table", ActiveRecord::TableMetadata.new(klass, @table))
|
||||
@predicate_builder.instance_variable_set(:@table, ActiveRecord::TableMetadata.new(klass, @table))
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class Pseudonym < ActiveRecord::Base
|
|||
if: :require_password?
|
||||
|
||||
validates_each :password, if: :require_password?,
|
||||
&Canvas::PasswordPolicy.method("validate")
|
||||
&Canvas::PasswordPolicy.method(:validate)
|
||||
validates :password_confirmation,
|
||||
presence: true,
|
||||
if: :require_password?
|
||||
|
|
|
@ -72,7 +72,7 @@ class Setting < Switchman::UnshardedRecord
|
|||
@all_settings = nil
|
||||
MultiCache.delete("all_settings")
|
||||
|
||||
if Rails.const_defined? "Console"
|
||||
if Rails.const_defined? :Console
|
||||
message = Setting.get("setting_set_sighup_required_message", "** NOTE: After calling `Setting.set`, SIGHUP must be sent to all Canvas processes **")
|
||||
Rails.logger.info(message)
|
||||
end
|
||||
|
|
|
@ -321,11 +321,11 @@ class Submission < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def submitted_changed?
|
||||
submitted? != %w[submitted pending_review graded].include?(send("workflow_state_before_last_save"))
|
||||
submitted? != %w[submitted pending_review graded].include?(send(:workflow_state_before_last_save))
|
||||
end
|
||||
|
||||
def graded_changed?
|
||||
graded? != (send("workflow_state_before_last_save") == "graded")
|
||||
graded? != (send(:workflow_state_before_last_save) == "graded")
|
||||
end
|
||||
|
||||
scope :needs_grading, lambda {
|
||||
|
|
|
@ -44,7 +44,7 @@ class SubmissionDraft < ActiveRecord::Base
|
|||
# also updates the url with a scheme if missing and is a valid url
|
||||
# otherwise leaves the url as whatever the user submitted as thier draft
|
||||
value, = CanvasHttp.validate_url(url)
|
||||
send("url=", value)
|
||||
send(:url=, value)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ class SubmissionDraft < ActiveRecord::Base
|
|||
return if lti_launch_url.blank?
|
||||
|
||||
value, = CanvasHttp.validate_url(lti_launch_url)
|
||||
send("lti_launch_url=", value) if value
|
||||
send(:lti_launch_url=, value) if value
|
||||
rescue
|
||||
# we couldn't validate, just leave it
|
||||
end
|
||||
|
|
|
@ -197,6 +197,6 @@ class UserProfile < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def instructure_misc_plugin_available?
|
||||
Object.const_defined?("InstructureMiscPlugin")
|
||||
Object.const_defined?(:InstructureMiscPlugin)
|
||||
end
|
||||
private :instructure_misc_plugin_available?
|
||||
|
|
|
@ -167,7 +167,7 @@ module Canvas
|
|||
options = { controller: @controller, scope: scope }
|
||||
association.build_serializer(object, options).tap do |serializer|
|
||||
if association.options.key?(:wrap_in_array)
|
||||
serializer.instance_variable_set("@wrap_in_array",
|
||||
serializer.instance_variable_set(:@wrap_in_array,
|
||||
association.options[:wrap_in_array])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -145,7 +145,7 @@ describe AcademicBenchmark do
|
|||
end
|
||||
|
||||
def check_for_parent_num_duplication(outcome)
|
||||
parent = outcome.instance_variable_get("@parent")
|
||||
parent = outcome.instance_variable_get(:@parent)
|
||||
if outcome.resolve_number && parent && parent.build_title && outcome.resolve_number.include?(parent.build_title)
|
||||
outcome.title == "#{parent.title}.#{outcome.resolve_number}"
|
||||
else
|
||||
|
@ -155,7 +155,7 @@ describe AcademicBenchmark do
|
|||
|
||||
def check_built_outcome(outcome)
|
||||
expect(check_for_parent_num_duplication(outcome)).to be_falsey
|
||||
outcome.instance_variable_get("@children").each { |o| check_built_outcome(o) }
|
||||
outcome.instance_variable_get(:@children).each { |o| check_built_outcome(o) }
|
||||
end
|
||||
|
||||
it "imports the standards successfully" do
|
||||
|
|
|
@ -166,7 +166,7 @@ module AccountReports
|
|||
end
|
||||
filetype = "application/zip"
|
||||
elsif csv
|
||||
ext = csv !~ /\n/ && File.extname(csv)
|
||||
ext = !csv.include?("\n") && File.extname(csv)
|
||||
case ext
|
||||
when ".csv"
|
||||
filename = File.basename(csv)
|
||||
|
|
|
@ -79,7 +79,7 @@ describe "Outcome Reports" do
|
|||
learning_outcome_id: @outcome.id
|
||||
}
|
||||
]
|
||||
@rubric.instance_variable_set("@alignments_changed", true)
|
||||
@rubric.instance_variable_set(:@alignments_changed, true)
|
||||
@rubric.save!
|
||||
@a = @rubric.associate_with(@assignment, @course1, purpose: "grading")
|
||||
@assignment.reload
|
||||
|
|
|
@ -56,7 +56,7 @@ module SimplyVersioned
|
|||
# INSTRUCTURE: Added to allow model instances pulled out
|
||||
# of versions to still know their version number
|
||||
obj.simply_versioned_version_model = true
|
||||
obj.send("force_version_number", number)
|
||||
obj.send(:force_version_number, number)
|
||||
obj
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,10 +33,10 @@ module Api::V1::AccountCalendar
|
|||
json["asset_string"] = account.asset_string
|
||||
json["type"] = account.class.to_s.downcase
|
||||
json["sub_account_count"] = account.sub_accounts.count if include.include? "sub_account_count"
|
||||
json["calendar_event_url"] = account.respond_to?("calendar_events") ? named_context_url(account, :context_calendar_event_url, "{{ id }}") : ""
|
||||
json["can_create_calendar_events"] = account.respond_to?("calendar_events") && CalendarEvent.new.tap { |e| e.context = account }.grants_right?(user, session, :create)
|
||||
json["create_calendar_event_url"] = account.respond_to?("calendar_events") ? named_context_url(account, :context_calendar_events_url) : ""
|
||||
json["new_calendar_event_url"] = account.respond_to?("calendar_events") ? named_context_url(account, :new_context_calendar_event_url) : ""
|
||||
json["calendar_event_url"] = account.respond_to?(:calendar_events) ? named_context_url(account, :context_calendar_event_url, "{{ id }}") : ""
|
||||
json["can_create_calendar_events"] = account.respond_to?(:calendar_events) && CalendarEvent.new.tap { |e| e.context = account }.grants_right?(user, session, :create)
|
||||
json["create_calendar_event_url"] = account.respond_to?(:calendar_events) ? named_context_url(account, :context_calendar_events_url) : ""
|
||||
json["new_calendar_event_url"] = account.respond_to?(:calendar_events) ? named_context_url(account, :new_context_calendar_event_url) : ""
|
||||
json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -169,7 +169,7 @@ module Canvas::Migration
|
|||
end
|
||||
end
|
||||
|
||||
doc.remove_namespaces! if doc.respond_to?("remove_namespaces!")
|
||||
doc.remove_namespaces! if doc.respond_to?(:remove_namespaces!)
|
||||
doc
|
||||
end
|
||||
end
|
||||
|
|
|
@ -380,7 +380,7 @@ class GradebookImporter
|
|||
|
||||
update_column_count row
|
||||
|
||||
return false unless /Section/.match?(last_student_info_column(row))
|
||||
return false unless last_student_info_column(row).include?("Section")
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Lti
|
|||
end
|
||||
|
||||
def self.set_asset_context_id(asset, lti_context_id, context: nil)
|
||||
if asset.respond_to?("lti_context_id")
|
||||
if asset.respond_to?(:lti_context_id)
|
||||
global_context_id = global_context_id_for(asset)
|
||||
if asset.new_record?
|
||||
asset.lti_context_id = global_context_id
|
||||
|
|
|
@ -463,7 +463,7 @@ class MessageableUser
|
|||
# Discussion Topics could be assigned to multiple sections so this allows
|
||||
# supporting multiple sections through this method.
|
||||
sections = nil
|
||||
if section_or_id.respond_to?("count") && section_or_id.count > 0
|
||||
if section_or_id.respond_to?(:count) && section_or_id.count > 0
|
||||
sections = section_or_id
|
||||
section_or_id = sections.first
|
||||
end
|
||||
|
|
|
@ -252,7 +252,7 @@ module Outcomes
|
|||
|
||||
def lang
|
||||
# lang can be nil, so we check with instance_variable_defined? method
|
||||
unless instance_variable_defined?("@lang")
|
||||
unless instance_variable_defined?(:@lang)
|
||||
account = context&.root_account || LoadAccount.default_domain_root_account
|
||||
@lang = MAP_CANVAS_POSTGRES_LOCALES[account.default_locale || "en"]
|
||||
end
|
||||
|
|
|
@ -156,7 +156,7 @@ class ScoreStatisticsGenerator
|
|||
|
||||
# This is a safeguard to avoid blowing up due to database storage which is set to be a decimal with a precision of 8
|
||||
# and a scale of 2. And really, what are you even doing awarding 1,000,000% or over in a course?
|
||||
return if average > 999_999.99.to_d || average < -999_999.99.to_d
|
||||
return if average > BigDecimal("999_999.99") || average < BigDecimal("-999_999.99")
|
||||
|
||||
connection = CourseScoreStatistic.connection
|
||||
now = connection.quote(Time.now.utc)
|
||||
|
|
|
@ -32,7 +32,7 @@ unless Rails.env.production? || ARGV.any? { |a| a.start_with?("gems") }
|
|||
end
|
||||
end
|
||||
|
||||
Rake.application.instance_variable_get("@tasks").delete("default")
|
||||
Rake.application.instance_variable_get(:@tasks).delete("default")
|
||||
|
||||
task default: :spec
|
||||
task stats: "spec:statsetup"
|
||||
|
|
|
@ -1904,7 +1904,7 @@ RSpec.describe ApplicationController do
|
|||
|
||||
describe "#discard_flash_if_xhr" do
|
||||
subject(:discard) do
|
||||
flash.instance_variable_get("@discard")
|
||||
flash.instance_variable_get(:@discard)
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -2635,7 +2635,7 @@ describe ExternalToolsController do
|
|||
end
|
||||
|
||||
def opaque_id(asset)
|
||||
if asset.respond_to?("lti_context_id")
|
||||
if asset.respond_to?(:lti_context_id)
|
||||
Lti::Asset.global_context_id_for(asset)
|
||||
else
|
||||
Lti::Asset.context_id_for(asset)
|
||||
|
|
|
@ -59,7 +59,7 @@ describe "discussion_topics" do
|
|||
@topic = DiscussionTopic.new(context: @course, title: "will this work?", user: @user)
|
||||
@topic.save!
|
||||
expect(@topic.grants_right?(@user, :update)).to be
|
||||
student_enrollment.send("conclude")
|
||||
student_enrollment.send(:conclude)
|
||||
AdheresToPolicy::Cache.clear
|
||||
expect(@topic.grants_right?(@user, :update)).not_to be
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ describe "discussion_topics" do
|
|||
@topic = DiscussionTopic.new(context: @course, title: "will this work?", user: @student)
|
||||
@topic.save!
|
||||
expect(@topic.grants_right?(@teacher, :update)).to be
|
||||
student_enrollment.send("conclude")
|
||||
student_enrollment.send(:conclude)
|
||||
AdheresToPolicy::Cache.clear
|
||||
expect(@topic.grants_right?(@teacher, :update)).to be
|
||||
end
|
||||
|
|
|
@ -384,7 +384,7 @@ describe BasicLTI::BasicOutcomes do
|
|||
expect(request.body).to eq "<replaceResultResponse />"
|
||||
expect(request.handle_request(tool)).to be_truthy
|
||||
submission = assignment.submissions.where(user_id: @user.id).first
|
||||
expected_value = assignment.points_possible * 0.92.to_d
|
||||
expected_value = assignment.points_possible * BigDecimal("0.92")
|
||||
expect(submission.grade).to eq expected_value.to_s
|
||||
end
|
||||
|
||||
|
@ -798,7 +798,7 @@ describe BasicLTI::BasicOutcomes do
|
|||
expect(request.body).to eq "<replaceResultResponse />"
|
||||
expect(request.handle_request(tool)).to be_truthy
|
||||
submission = assignment.submissions.where(user_id: @user1.id).first
|
||||
expected_value = assignment.points_possible * 0.92.to_d
|
||||
expected_value = assignment.points_possible * BigDecimal("0.92")
|
||||
expect(submission.grade).to eq expected_value.to_s
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2251,7 +2251,7 @@ module Lti
|
|||
masquerading_user = User.new
|
||||
allow(masquerading_user).to receive(:id).and_return(7878)
|
||||
allow(user).to receive(:id).and_return(42)
|
||||
variable_expander.instance_variable_set("@current_user", masquerading_user)
|
||||
variable_expander.instance_variable_set(:@current_user, masquerading_user)
|
||||
exp_hash = { test: "$Canvas.masqueradingUser.id" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq 42
|
||||
|
@ -2268,7 +2268,7 @@ module Lti
|
|||
it "has substitution for $Canvas.masqueradingUser.userId" do
|
||||
masquerading_user = User.new
|
||||
allow(masquerading_user).to receive(:id).and_return(7878)
|
||||
variable_expander.instance_variable_set("@current_user", masquerading_user)
|
||||
variable_expander.instance_variable_set(:@current_user, masquerading_user)
|
||||
exp_hash = { test: "$Canvas.masqueradingUser.userId" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f"
|
||||
|
@ -2277,7 +2277,7 @@ module Lti
|
|||
it "has substitution for Canvas.module.id" do
|
||||
content_tag = double("content_tag")
|
||||
allow(content_tag).to receive(:context_module_id).and_return("foo")
|
||||
variable_expander.instance_variable_set("@content_tag", content_tag)
|
||||
variable_expander.instance_variable_set(:@content_tag, content_tag)
|
||||
exp_hash = { test: "$Canvas.module.id" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "foo"
|
||||
|
@ -2286,7 +2286,7 @@ module Lti
|
|||
it "has substitution for Canvas.moduleItem.id" do
|
||||
content_tag = double("content_tag")
|
||||
allow(content_tag).to receive(:id).and_return(7878)
|
||||
variable_expander.instance_variable_set("@content_tag", content_tag)
|
||||
variable_expander.instance_variable_set(:@content_tag, content_tag)
|
||||
exp_hash = { test: "$Canvas.moduleItem.id" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq 7878
|
||||
|
@ -2627,7 +2627,7 @@ module Lti
|
|||
masquerading_user = User.new
|
||||
allow(masquerading_user).to receive(:id).and_return(7878)
|
||||
allow(user).to receive(:id).and_return(42)
|
||||
variable_expander.instance_variable_set("@current_user", masquerading_user)
|
||||
variable_expander.instance_variable_set(:@current_user, masquerading_user)
|
||||
exp_hash = { test: "$Canvas.masqueradingUser.id" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "42"
|
||||
|
@ -2636,7 +2636,7 @@ module Lti
|
|||
it "has substitution for Canvas.moduleItem.id" do
|
||||
content_tag = double("content_tag")
|
||||
allow(content_tag).to receive(:id).and_return(7878)
|
||||
variable_expander.instance_variable_set("@content_tag", content_tag)
|
||||
variable_expander.instance_variable_set(:@content_tag, content_tag)
|
||||
exp_hash = { test: "$Canvas.moduleItem.id" }
|
||||
variable_expander.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "7878"
|
||||
|
|
|
@ -31,14 +31,14 @@ describe ScopeFilter do
|
|||
describe "#concat_scope" do
|
||||
it "sets @relation as value returned from provided block" do
|
||||
scope_filter.send(:concat_scope) { Course.all }
|
||||
expect(scope_filter.instance_variable_get("@relation")).to eq(Course.all)
|
||||
expect(scope_filter.instance_variable_get(:@relation)).to eq(Course.all)
|
||||
end
|
||||
|
||||
it "maintains @relation when block returns a falsey value" do
|
||||
scope_filter.send(:concat_scope) { Course.all }
|
||||
expect(scope_filter.instance_variable_get("@relation")).to eq(Course.all), "precondition"
|
||||
expect(scope_filter.instance_variable_get(:@relation)).to eq(Course.all), "precondition"
|
||||
scope_filter.send(:concat_scope) { nil }
|
||||
expect(scope_filter.instance_variable_get("@relation")).to eq(Course.all)
|
||||
expect(scope_filter.instance_variable_get(:@relation)).to eq(Course.all)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,10 +32,10 @@ RSpec.describe CourseScoreStatistic, type: :model do
|
|||
end
|
||||
|
||||
describe "#grades_presenter_hash" do
|
||||
let(:course_score_statistic) { CourseScoreStatistic.new(course_id: 123, average: 12.23.to_d, score_count: 2) }
|
||||
let(:course_score_statistic) { CourseScoreStatistic.new(course_id: 123, average: BigDecimal("12.23"), score_count: 2) }
|
||||
|
||||
it "returns the data in the grades presenter expected shape and keys" do
|
||||
expect(course_score_statistic.grades_presenter_hash).to eq({ score: 12.23.to_d, students: 2 })
|
||||
expect(course_score_statistic.grades_presenter_hash).to eq({ score: BigDecimal("12.23"), students: 2 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,7 +91,7 @@ RSpec.describe Lti::ContentMigrationService::Importer do
|
|||
end
|
||||
|
||||
it "must retain the import status url" do
|
||||
status_url = importer.instance_variable_get("@status_url")
|
||||
status_url = importer.instance_variable_get(:@status_url)
|
||||
expect(status_url).to eq "https://lti.example.com/imports/42/status"
|
||||
end
|
||||
|
||||
|
@ -235,8 +235,8 @@ RSpec.describe Lti::ContentMigrationService::Importer do
|
|||
}
|
||||
})
|
||||
tool.save!
|
||||
importer.instance_variable_set("@tool", tool)
|
||||
importer.instance_variable_set("@status_url", "https://lti.example.com/imports/42/status")
|
||||
importer.instance_variable_set(:@tool, tool)
|
||||
importer.instance_variable_set(:@status_url, "https://lti.example.com/imports/42/status")
|
||||
end
|
||||
|
||||
it 'must return false when the remote end returns a status other than "completed"' do
|
||||
|
|
|
@ -111,7 +111,7 @@ describe "threaded discussions" do
|
|||
)
|
||||
user_session(@student)
|
||||
Discussion.visit(@course, @topic)
|
||||
student_enrollment.send("conclude")
|
||||
student_enrollment.send(:conclude)
|
||||
Discussion.visit(@course, @topic)
|
||||
wait_for_ajaximations
|
||||
|
||||
|
@ -131,7 +131,7 @@ describe "threaded discussions" do
|
|||
)
|
||||
user_session(@student)
|
||||
Discussion.visit(@course, @topic)
|
||||
student_enrollment.send("conclude")
|
||||
student_enrollment.send(:conclude)
|
||||
Discussion.visit(@course, @topic)
|
||||
wait_for_ajaximations
|
||||
|
||||
|
@ -940,7 +940,7 @@ describe "threaded discussions" do
|
|||
user: @student,
|
||||
message: "new threaded reply from student"
|
||||
)
|
||||
student_enrollment.send("conclude")
|
||||
student_enrollment.send(:conclude)
|
||||
user_session(@student)
|
||||
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue