bump rubocop gems and apply changes
[skip-stages=Flakey] Change-Id: I5f080be6efb64351b4a89e6bd6040bc6f0432e82 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/323854 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
8d4eff6e5b
commit
8f8f6f7313
|
@ -79,6 +79,7 @@ Naming/FileName:
|
|||
- "**/Gemfile.d/~after.rb"
|
||||
- "**/urn_*.rb"
|
||||
- "**/fixtures/**/*.rb"
|
||||
- "config/environments/*-*.rb"
|
||||
- "config/locales/*.rb" # names must match locale names
|
||||
- "spec/selenium/a11y_and_i18n/localized-timezone-lists_spec.rb" # matches JS file it tests
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ GEM
|
|||
rainbow (3.1.1)
|
||||
rake (13.0.6)
|
||||
regexp_parser (2.7.0)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.54.0)
|
||||
rexml (3.2.6)
|
||||
rubocop (1.55.1)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
|
@ -106,7 +106,7 @@ GEM
|
|||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.28.0, < 2.0)
|
||||
rubocop-ast (>= 1.28.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.29.0)
|
||||
|
@ -129,7 +129,7 @@ GEM
|
|||
rubocop (>= 1.33.0, < 2.0)
|
||||
rubocop-rake (0.6.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-rspec (2.22.0)
|
||||
rubocop-rspec (2.23.1)
|
||||
rubocop (~> 1.33)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-factory_bot (~> 2.22)
|
||||
|
|
|
@ -918,7 +918,7 @@ GEM
|
|||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
retriable (1.4.1)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
ritex (1.0.1)
|
||||
rotp (6.2.0)
|
||||
rqrcode (1.2.0)
|
||||
|
@ -956,7 +956,7 @@ GEM
|
|||
rspec-core (>= 2, < 4, != 2.12.0)
|
||||
rss (0.2.9)
|
||||
rexml
|
||||
rubocop (1.54.0)
|
||||
rubocop (1.55.1)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
|
@ -964,7 +964,7 @@ GEM
|
|||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.28.0, < 2.0)
|
||||
rubocop-ast (>= 1.28.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.29.0)
|
||||
|
@ -987,7 +987,7 @@ GEM
|
|||
rubocop (>= 1.33.0, < 2.0)
|
||||
rubocop-rake (0.6.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-rspec (2.22.0)
|
||||
rubocop-rspec (2.23.1)
|
||||
rubocop (~> 1.33)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-factory_bot (~> 2.22)
|
||||
|
|
|
@ -294,7 +294,7 @@ class SectionsController < ApplicationController
|
|||
integration_id = params[:course_section].delete(:integration_id)
|
||||
if sis_id || integration_id
|
||||
if @section.root_account.grants_right?(@current_user, :manage_sis)
|
||||
@section.sis_source_id = (sis_id == "") ? nil : sis_id if sis_id
|
||||
@section.sis_source_id = (sis_id == "") ? nil : sis_id if sis_id
|
||||
@section.integration_id = (integration_id == "") ? nil : integration_id if integration_id
|
||||
elsif api_request?
|
||||
return render json: { message: "You must have manage_sis permission to update sis attributes" }, status: :unauthorized
|
||||
|
|
|
@ -246,7 +246,7 @@ class Loaders::OutcomeAlignmentLoader < GraphQL::Batch::Loader
|
|||
next unless a[:associated_asset_type] == "canvas.assignment.quizzes" && a[:associated_asset_id] == alignment[:content_id].to_s
|
||||
|
||||
items << { _id: a[:artifact_id], title: a[:title] } if a[:artifact_type] == "quizzes.item"
|
||||
count += 1 if SUPPORTED_OS_ALIGNMENTS.include?(a[:artifact_type])
|
||||
count += 1 if SUPPORTED_OS_ALIGNMENTS.include?(a[:artifact_type])
|
||||
end
|
||||
[items, count]
|
||||
end
|
||||
|
|
|
@ -358,7 +358,7 @@ module Importers
|
|||
end
|
||||
|
||||
if hash["similarity_detection_tool"].present?
|
||||
settings = item.turnitin_settings
|
||||
settings = item.turnitin_settings
|
||||
settings[:originality_report_visibility] = hash["similarity_detection_tool"]["visibility"]
|
||||
item.turnitin_settings = settings
|
||||
end
|
||||
|
|
|
@ -1255,7 +1255,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def used_feature?(feature)
|
||||
features_used&.split(/,/)&.include?(feature.to_s)
|
||||
features_used&.split(",")&.include?(feature.to_s)
|
||||
end
|
||||
|
||||
def available_courses
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
if $0 == "irb"
|
||||
TeeLogger = Struct.new(:loggers) do
|
||||
def method_missing(method, *args, &)
|
||||
def method_missing(...)
|
||||
loggers.each do |logger|
|
||||
logger.send(method, *args, &)
|
||||
logger.send(...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,9 +40,8 @@ RSpec.shared_context "caching_helpers", shared_context: :metadata do
|
|||
yield
|
||||
ensure
|
||||
allow(Rails).to receive(:cache).and_return(previous_cache)
|
||||
allow(ActionController::Base).to receive(:cache_store).and_return(previous_cache)
|
||||
allow(ActionController::Base).to receive_messages(cache_store: previous_cache, perform_caching: previous_perform_caching)
|
||||
allow_any_instance_of(ActionController::Base).to receive(:cache_store).and_return(previous_cache)
|
||||
allow(ActionController::Base).to receive(:perform_caching).and_return(previous_perform_caching)
|
||||
allow_any_instance_of(ActionController::Base).to receive(:perform_caching).and_return(previous_perform_caching)
|
||||
end
|
||||
end
|
||||
|
@ -60,9 +59,8 @@ RSpec.shared_context "caching_helpers", shared_context: :metadata do
|
|||
new_cache ||= :null_store
|
||||
new_cache = ActiveSupport::Cache.lookup_store(new_cache, cache_opts)
|
||||
allow(Rails).to receive(:cache).and_return(new_cache)
|
||||
allow(ActionController::Base).to receive(:cache_store).and_return(new_cache)
|
||||
allow(ActionController::Base).to receive_messages(cache_store: new_cache, perform_caching: true)
|
||||
allow_any_instance_of(ActionController::Base).to receive(:cache_store).and_return(new_cache)
|
||||
allow(ActionController::Base).to receive(:perform_caching).and_return(true)
|
||||
allow_any_instance_of(ActionController::Base).to receive(:perform_caching).and_return(true)
|
||||
# TODO: re-enable this once multi_cache is pulled over to gem.
|
||||
# MultiCache.reset
|
||||
|
|
|
@ -33,9 +33,8 @@ describe CanvasCassandra do
|
|||
|
||||
describe "#tables" do
|
||||
before do
|
||||
allow(conn).to receive(:use_cql3?).and_return(true)
|
||||
allow(conn).to receive_messages(use_cql3?: true, connection: double(describe_version: "19"))
|
||||
allow(db).to receive(:keyspace).and_return("page_views")
|
||||
allow(conn).to receive(:connection).and_return(double(describe_version: "19"))
|
||||
end
|
||||
|
||||
it "queries for all column family names in the keyspace" do
|
||||
|
|
|
@ -31,7 +31,7 @@ GEM
|
|||
mime-types-data (3.2023.0218.1)
|
||||
public_suffix (5.0.1)
|
||||
rake (13.0.6)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
|
|
@ -54,28 +54,28 @@ module CanvasHttp
|
|||
|
||||
class ResponseTooLargeError < CanvasHttp::Error; end
|
||||
|
||||
def self.put(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Put, *args, **kwargs, &)
|
||||
def self.put(...)
|
||||
CanvasHttp.request(Net::HTTP::Put, ...)
|
||||
end
|
||||
|
||||
def self.delete(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Delete, *args, **kwargs, &)
|
||||
def self.delete(...)
|
||||
CanvasHttp.request(Net::HTTP::Delete, ...)
|
||||
end
|
||||
|
||||
def self.head(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Head, *args, **kwargs, &)
|
||||
def self.head(...)
|
||||
CanvasHttp.request(Net::HTTP::Head, ...)
|
||||
end
|
||||
|
||||
def self.get(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Get, *args, **kwargs, &)
|
||||
def self.get(...)
|
||||
CanvasHttp.request(Net::HTTP::Get, ...)
|
||||
end
|
||||
|
||||
def self.post(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Post, *args, **kwargs, &)
|
||||
def self.post(...)
|
||||
CanvasHttp.request(Net::HTTP::Post, ...)
|
||||
end
|
||||
|
||||
def self.patch(*args, **kwargs, &)
|
||||
CanvasHttp.request(Net::HTTP::Patch, *args, **kwargs, &)
|
||||
def self.patch(...)
|
||||
CanvasHttp.request(Net::HTTP::Patch, ...)
|
||||
end
|
||||
|
||||
# Use this helper method to do HTTP GET requests. It knows how to handle
|
||||
|
|
|
@ -59,7 +59,7 @@ GEM
|
|||
public_suffix (5.0.1)
|
||||
racc (1.7.1)
|
||||
rake (13.0.6)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
|
|
@ -55,7 +55,7 @@ GEM
|
|||
minitest (5.18.1)
|
||||
public_suffix (5.0.1)
|
||||
rake (13.0.6)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
|
|
@ -197,8 +197,7 @@ describe CanvasSecurity do
|
|||
end
|
||||
|
||||
it "internally manages signing-secret rotation" do
|
||||
allow(CanvasSecurity).to receive(:services_signing_secret).and_return("current_secret")
|
||||
allow(CanvasSecurity).to receive(:services_previous_signing_secret).and_return("previous_secret")
|
||||
allow(CanvasSecurity).to receive_messages(services_signing_secret: "current_secret", services_previous_signing_secret: "previous_secret")
|
||||
signature = CanvasSecurity.sign_hmac_sha512(message, "previous_secret")
|
||||
verification = CanvasSecurity.verify_hmac_sha512(message, signature, "current_secret")
|
||||
expect(verification).to be_truthy
|
||||
|
|
|
@ -115,8 +115,7 @@ module DynamicSettings
|
|||
|
||||
context "with retries" do
|
||||
before do
|
||||
allow(proxy).to receive(:retry_limit).and_return(2)
|
||||
allow(proxy).to receive(:retry_base).and_return(1.4)
|
||||
allow(proxy).to receive_messages(retry_limit: 2, retry_base: 1.4)
|
||||
end
|
||||
|
||||
it "retries if there is an initial error" do
|
||||
|
|
|
@ -36,8 +36,7 @@ describe EventStream::Failure do
|
|||
allow(@stream).to receive(:operation_payload).with(:update, @record).and_return(@record.changes)
|
||||
|
||||
@exception = StandardError.new
|
||||
allow(@exception).to receive(:message).and_return(double("exception_message", to_s: "exception_message_string"))
|
||||
allow(@exception).to receive(:backtrace).and_return([42])
|
||||
allow(@exception).to receive_messages(message: double("exception_message", to_s: "exception_message_string"), backtrace: [42])
|
||||
end
|
||||
|
||||
it "creates a new db record" do
|
||||
|
|
|
@ -181,7 +181,7 @@ GEM
|
|||
zeitwerk (~> 2.5)
|
||||
rake (13.0.6)
|
||||
retriable (1.4.1)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
|
|
@ -51,9 +51,8 @@ describe LiveEvents::Client do
|
|||
|
||||
def prep_client_and_worker
|
||||
stub_config
|
||||
allow(LiveEvents).to receive(:logger).and_return(double(info: nil, error: nil, warn: nil))
|
||||
allow(LiveEvents).to receive_messages(logger: double(info: nil, error: nil, warn: nil), stream_client: fclient)
|
||||
LiveEvents.max_queue_size = -> { 100 }
|
||||
allow(LiveEvents).to receive(:stream_client).and_return(fclient)
|
||||
LiveEvents.clear_context!
|
||||
|
||||
@client = LiveEvents::Client.new nil, fclient, test_stream_name
|
||||
|
|
|
@ -93,7 +93,7 @@ module LtiAdvantage::Messages
|
|||
end
|
||||
|
||||
it "is not valid if required claims are missing" do
|
||||
expect(message).to be_invalid
|
||||
expect(message).not_to be_valid
|
||||
end
|
||||
|
||||
it "is valid if all required claims are present" do
|
||||
|
|
|
@ -91,7 +91,7 @@ module LtiAdvantage::Messages
|
|||
it_behaves_like "validations for optional claims"
|
||||
|
||||
it "is not valid if required claims are missing" do
|
||||
expect(message).to be_invalid
|
||||
expect(message).not_to be_valid
|
||||
end
|
||||
|
||||
it "is valid if all required claims are present" do
|
||||
|
|
|
@ -49,7 +49,7 @@ module LtiAdvantage::Models
|
|||
accept_types: [],
|
||||
accept_presentation_document_targets: ["bar"]
|
||||
)
|
||||
).to be_invalid
|
||||
).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid if "accept_presentation_document_targets" is blank' do
|
||||
|
@ -58,7 +58,7 @@ module LtiAdvantage::Models
|
|||
accept_types: ["foo"],
|
||||
accept_presentation_document_targets: []
|
||||
)
|
||||
).to be_invalid
|
||||
).not_to be_valid
|
||||
end
|
||||
|
||||
it 'verifies "accept_types" is an array' do
|
||||
|
|
|
@ -42,9 +42,7 @@ describe "Account Reports" do
|
|||
end
|
||||
|
||||
it "uses instfs if instfs is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: "1234-abcd")
|
||||
|
||||
report1 = run_report("unpublished_courses_csv")
|
||||
report2 = run_report("unpublished_courses_csv")
|
||||
|
|
|
@ -2449,8 +2449,7 @@ describe "Default Account Reports" do
|
|||
username: "other_shard@example.com",
|
||||
sis_user_id: "other_shard")
|
||||
end
|
||||
allow(@account).to receive(:trusted_account_ids).and_return([@account.id, @root.id])
|
||||
allow(@account).to receive(:trust_exists?).and_return(true)
|
||||
allow(@account).to receive_messages(trusted_account_ids: [@account.id, @root.id], trust_exists?: true)
|
||||
@admin4 = @account.account_users.create(user: @user)
|
||||
@admin4.sis_batch_id = @sis.id
|
||||
@admin4.save!
|
||||
|
|
|
@ -94,7 +94,7 @@ GEM
|
|||
rainbow (3.1.1)
|
||||
rake (13.0.6)
|
||||
regexp_parser (2.7.0)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
@ -108,7 +108,7 @@ GEM
|
|||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.0)
|
||||
rubocop (1.54.0)
|
||||
rubocop (1.55.1)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
|
@ -116,7 +116,7 @@ GEM
|
|||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.28.0, < 2.0)
|
||||
rubocop-ast (>= 1.28.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.29.0)
|
||||
|
|
|
@ -171,7 +171,7 @@ GEM
|
|||
thor (~> 1.0)
|
||||
zeitwerk (~> 2.5)
|
||||
rake (13.0.6)
|
||||
rexml (3.2.5)
|
||||
rexml (3.2.6)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
|
|
|
@ -115,7 +115,7 @@ module Canvas
|
|||
end
|
||||
|
||||
def self.semver_revision
|
||||
revision&.gsub(/-/, "")
|
||||
revision&.gsub("-", "")
|
||||
end
|
||||
|
||||
DEFAULT_RETRY_CALLBACK = lambda do |ex, tries|
|
||||
|
|
|
@ -36,8 +36,8 @@ module Canvas
|
|||
# lib/canvas/errors/*.rb that need the existing module structure,
|
||||
# so method_missing works better at the moment.
|
||||
class << self
|
||||
def method_missing(m, *args, &)
|
||||
CanvasErrors.send(m, *args, &)
|
||||
def method_missing(...)
|
||||
CanvasErrors.send(...)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ module CC
|
|||
end
|
||||
|
||||
def epub_export?
|
||||
@content_export ? @content_export.epub_export.present? : nil
|
||||
@content_export ? @content_export.epub_export.present? : false
|
||||
end
|
||||
|
||||
def for_external_migration?
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace :db do
|
|||
|
||||
while true do
|
||||
email = ask("What email address will the site administrator account use? > ") { |q| q.echo = obfuscate_input_or_echo }
|
||||
email_confirm = ask("Please confirm > ") { |q| q.echo = obfuscate_input_or_echo }
|
||||
email_confirm = ask("Please confirm > ") { |q| q.echo = obfuscate_input_or_echo }
|
||||
break if email == email_confirm
|
||||
end
|
||||
|
||||
|
|
|
@ -337,8 +337,7 @@ describe ExternalToolsController, type: :request do
|
|||
end
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
allow(Setting).to receive(:set).with("allow_tc_access_").and_return("true")
|
||||
end
|
||||
|
||||
|
|
|
@ -81,8 +81,7 @@ describe "Files API", type: :request do
|
|||
|
||||
it "includes include capture param in inst_fs token" do
|
||||
secret = "secret"
|
||||
allow(InstFS).to receive(:enabled?).and_return true
|
||||
allow(InstFS).to receive(:jwt_secrets).and_return([secret])
|
||||
allow(InstFS).to receive_messages(enabled?: true, jwt_secrets: [secret])
|
||||
json = call_course_create_file
|
||||
query = Rack::Utils.parse_nested_query(URI(json["upload_url"]).query)
|
||||
payload = Canvas::Security.decode_jwt(query["token"], [secret])
|
||||
|
@ -418,8 +417,7 @@ describe "Files API", type: :request do
|
|||
end
|
||||
|
||||
before do
|
||||
allow(InstFS).to receive(:enabled?).and_return true
|
||||
allow(InstFS).to receive(:jwt_secrets).and_return([secret])
|
||||
allow(InstFS).to receive_messages(enabled?: true, jwt_secrets: [secret])
|
||||
end
|
||||
|
||||
it "is not available without the InstFS feature" do
|
||||
|
|
|
@ -735,8 +735,7 @@ describe Quizzes::QuizSubmissionQuestionsController, type: :request do
|
|||
allow(Quizzes::Quiz).to receive(:lockdown_browser_plugin_enabled?).and_return true
|
||||
|
||||
fake_plugin = Object.new
|
||||
allow(fake_plugin).to receive(:authorized?).and_return false
|
||||
allow(fake_plugin).to receive(:base).and_return fake_plugin
|
||||
allow(fake_plugin).to receive_messages(authorized?: false, base: fake_plugin)
|
||||
|
||||
allow(subject).to receive(:ldb_plugin).and_return fake_plugin
|
||||
allow(Canvas::LockdownBrowser).to receive(:plugin).and_return fake_plugin
|
||||
|
|
|
@ -28,8 +28,7 @@ shared_examples_for "Quiz Submissions API Restricted Endpoints" do
|
|||
allow(Quizzes::Quiz).to receive(:lockdown_browser_plugin_enabled?).and_return true
|
||||
|
||||
fake_plugin = Object.new
|
||||
allow(fake_plugin).to receive(:authorized?).and_return false
|
||||
allow(fake_plugin).to receive(:base).and_return fake_plugin
|
||||
allow(fake_plugin).to receive_messages(authorized?: false, base: fake_plugin)
|
||||
|
||||
allow(subject).to receive(:ldb_plugin).and_return fake_plugin
|
||||
allow(Canvas::LockdownBrowser).to receive(:plugin).and_return fake_plugin
|
||||
|
|
|
@ -1238,8 +1238,7 @@ describe "Users API", type: :request do
|
|||
end
|
||||
@shard2.activate do
|
||||
account = Account.create!
|
||||
allow(account).to receive(:trust_exists?).and_return(true)
|
||||
allow(account).to receive(:trusted_account_ids).and_return([@account.id])
|
||||
allow(account).to receive_messages(trust_exists?: true, trusted_account_ids: [@account.id])
|
||||
course = account.courses.create!
|
||||
course.enroll_student(@u)
|
||||
p2 = @u.pseudonyms.create!(account:, unique_id: "p2")
|
||||
|
|
|
@ -670,8 +670,7 @@ RSpec.describe ApplicationController do
|
|||
@pseudonym.update_attribute(:sis_user_id, "test1")
|
||||
controller.instance_variable_set(:@domain_root_account, Account.default)
|
||||
allow(controller).to receive(:named_context_url).with(@user, :context_url).and_return("")
|
||||
allow(controller).to receive(:params).and_return({ user_id: "sis_user_id:test1" })
|
||||
allow(controller).to receive(:api_request?).and_return(true)
|
||||
allow(controller).to receive_messages(params: { user_id: "sis_user_id:test1" }, api_request?: true)
|
||||
controller.send(:get_context)
|
||||
expect(controller.instance_variable_get(:@context)).to eq @user
|
||||
end
|
||||
|
@ -682,8 +681,7 @@ RSpec.describe ApplicationController do
|
|||
@section.update_attribute(:sis_source_id, "test1")
|
||||
controller.instance_variable_set(:@domain_root_account, Account.default)
|
||||
allow(controller).to receive(:named_context_url).with(@section, :context_url).and_return("")
|
||||
allow(controller).to receive(:params).and_return({ course_section_id: "sis_section_id:test1" })
|
||||
allow(controller).to receive(:api_request?).and_return(true)
|
||||
allow(controller).to receive_messages(params: { course_section_id: "sis_section_id:test1" }, api_request?: true)
|
||||
controller.send(:get_context)
|
||||
expect(controller.instance_variable_get(:@context)).to eq @section
|
||||
end
|
||||
|
@ -702,10 +700,7 @@ RSpec.describe ApplicationController do
|
|||
expect(I18n.locale.to_s).to eq "es"
|
||||
course_model(locale: "ru")
|
||||
allow(controller).to receive(:named_context_url).with(@course, :context_url).and_return("")
|
||||
allow(controller).to receive(:params).and_return({ course_id: @course.id })
|
||||
allow(controller).to receive(:api_request?).and_return(false)
|
||||
allow(controller).to receive(:session).and_return({})
|
||||
allow(controller).to receive(:js_env).and_return({})
|
||||
allow(controller).to receive_messages(params: { course_id: @course.id }, api_request?: false, session: {}, js_env: {})
|
||||
controller.send(:get_context)
|
||||
expect(controller.instance_variable_get(:@context)).to eq @course
|
||||
I18n.set_locale_with_localizer # this is what t() triggers
|
||||
|
@ -825,8 +820,7 @@ RSpec.describe ApplicationController do
|
|||
end
|
||||
|
||||
it "updates for HTTP PUT requests that are not generated by hand" do
|
||||
allow(controller.request).to receive(:xhr?).and_return(0)
|
||||
allow(controller.request).to receive(:put?).and_return(true)
|
||||
allow(controller.request).to receive_messages(xhr?: 0, put?: true)
|
||||
allow(RequestContextGenerator).to receive(:store_interaction_seconds_update).and_return(true)
|
||||
allow(CanvasSecurity::PageViewJwt).to receive(:decode).and_return(page_view_info)
|
||||
allow(PageView).to receive(:find_for_update).and_return(page_view)
|
||||
|
@ -848,14 +842,13 @@ RSpec.describe ApplicationController do
|
|||
allow(Canvas::Errors::Info).to receive(:useful_http_env_stuff_from_request).and_return({})
|
||||
|
||||
req = double
|
||||
allow(req).to receive(:url).and_return("url")
|
||||
allow(req).to receive(:headers).and_return({})
|
||||
allow(req).to receive(:authorization).and_return(nil)
|
||||
allow(req).to receive(:request_method_symbol).and_return(:get)
|
||||
allow(req).to receive(:format).and_return("format")
|
||||
allow(req).to receive_messages(url: "url",
|
||||
headers: {},
|
||||
authorization: nil,
|
||||
request_method_symbol: :get,
|
||||
format: "format")
|
||||
|
||||
allow(controller).to receive(:request).and_return(req)
|
||||
allow(controller).to receive(:api_request?).and_return(false)
|
||||
allow(controller).to receive_messages(request: req, api_request?: false)
|
||||
allow(controller).to receive(:render_rescue_action)
|
||||
|
||||
controller.instance_variable_set(:@domain_root_account, @account)
|
||||
|
@ -1097,10 +1090,10 @@ RSpec.describe ApplicationController do
|
|||
let_once(:user) { user_model }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:named_context_url).and_return("wrong_url")
|
||||
allow(controller).to receive(:lti_grade_passback_api_url).and_return("wrong_url")
|
||||
allow(controller).to receive(:blti_legacy_grade_passback_api_url).and_return("wrong_url")
|
||||
allow(controller).to receive(:lti_turnitin_outcomes_placement_url).and_return("wrong_url")
|
||||
allow(controller).to receive_messages(named_context_url: "wrong_url",
|
||||
lti_grade_passback_api_url: "wrong_url",
|
||||
blti_legacy_grade_passback_api_url: "wrong_url",
|
||||
lti_turnitin_outcomes_placement_url: "wrong_url")
|
||||
|
||||
allow(controller).to receive(:render)
|
||||
allow(controller).to receive_messages(js_env: [])
|
||||
|
@ -1266,9 +1259,9 @@ RSpec.describe ApplicationController do
|
|||
allow(content_tag.context).to receive(:quiz_lti?).and_return(true)
|
||||
allow(controller).to receive(:render)
|
||||
allow(controller).to receive(:lti_launch_params)
|
||||
allow(controller).to receive(:require_user).and_return(true)
|
||||
allow(controller).to receive(:named_context_url).and_return("named_context_url")
|
||||
allow(controller).to receive(:polymorphic_url).and_return("host/quizzes")
|
||||
allow(controller).to receive_messages(require_user: true,
|
||||
named_context_url: "named_context_url",
|
||||
polymorphic_url: "host/quizzes")
|
||||
end
|
||||
|
||||
context "is set to homepage page when launched from homepage" do
|
||||
|
@ -1443,8 +1436,7 @@ RSpec.describe ApplicationController do
|
|||
controller.instance_variable_set(:@context, course)
|
||||
allow(content_tag).to receive(:id).and_return(42)
|
||||
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
tool.settings[:environments] = {
|
||||
|
@ -1801,10 +1793,7 @@ RSpec.describe ApplicationController do
|
|||
# default setup is a protected non-GET non-API session-authenticated request with bogus tokens
|
||||
cookies = ActionDispatch::Cookies::CookieJar.new(controller.request)
|
||||
controller.allow_forgery_protection = true
|
||||
allow(controller.request).to receive(:cookie_jar).and_return(cookies)
|
||||
allow(controller.request).to receive(:get?).and_return(false)
|
||||
allow(controller.request).to receive(:head?).and_return(false)
|
||||
allow(controller.request).to receive(:path).and_return("/non-api/endpoint")
|
||||
allow(controller.request).to receive_messages(cookie_jar: cookies, get?: false, head?: false, path: "/non-api/endpoint")
|
||||
controller.instance_variable_set(:@current_user, User.new)
|
||||
controller.instance_variable_set(:@pseudonym_session, "session-authenticated")
|
||||
controller.params[controller.request_forgery_protection_token] = "bogus"
|
||||
|
@ -2797,12 +2786,12 @@ describe CoursesController do
|
|||
user = user_model
|
||||
token = AccessToken.create!(user:, developer_key:, scopes: ["url:GET|/api/v1/accounts"])
|
||||
controller.instance_variable_set(:@access_token, token)
|
||||
allow(controller).to receive(:request).and_return(double({
|
||||
method: "GET",
|
||||
path: "/api/v1/accounts"
|
||||
}))
|
||||
params = { include: ["a"], includes: ["uuid", "b"] }
|
||||
allow(controller).to receive(:params).and_return(params)
|
||||
allow(controller).to receive_messages(request: double({
|
||||
method: "GET",
|
||||
path: "/api/v1/accounts"
|
||||
}),
|
||||
params:)
|
||||
controller.send(:validate_scopes)
|
||||
expect(params).to eq(include: [], includes: ["uuid"])
|
||||
end
|
||||
|
@ -2815,12 +2804,12 @@ describe CoursesController do
|
|||
user = user_model
|
||||
token = AccessToken.create!(user:, developer_key:, scopes: ["url:GET|/api/v1/accounts"])
|
||||
controller.instance_variable_set(:@access_token, token)
|
||||
allow(controller).to receive(:request).and_return(double({
|
||||
method: "GET",
|
||||
path: "/api/v1/accounts"
|
||||
}))
|
||||
params = { include: ["a"], includes: ["uuid", "b"] }
|
||||
allow(controller).to receive(:params).and_return(params)
|
||||
allow(controller).to receive_messages(request: double({
|
||||
method: "GET",
|
||||
path: "/api/v1/accounts"
|
||||
}),
|
||||
params:)
|
||||
controller.send(:validate_scopes)
|
||||
expect(params).to eq(include: ["a"], includes: ["uuid", "b"])
|
||||
end
|
||||
|
|
|
@ -29,8 +29,7 @@ describe ConferencesController do
|
|||
end
|
||||
|
||||
before do
|
||||
allow(BigBlueButtonConference).to receive(:send_request).and_return({ running: false })
|
||||
allow(BigBlueButtonConference).to receive(:get_auth_token).and_return("abc123")
|
||||
allow(BigBlueButtonConference).to receive_messages(send_request: { running: false }, get_auth_token: "abc123")
|
||||
end
|
||||
|
||||
describe "GET 'recording'" do
|
||||
|
|
|
@ -110,9 +110,7 @@ describe CrocodocSessionsController do
|
|||
context "Migrate to Canvadocs" do
|
||||
before do
|
||||
@attachment.submit_to_crocodoc
|
||||
allow(Canvadocs).to receive(:enabled?).and_return true
|
||||
allow(Canvadocs).to receive(:annotations_supported?).and_return true
|
||||
allow(Canvadocs).to receive(:hijack_crocodoc_sessions?).and_return false
|
||||
allow(Canvadocs).to receive_messages(enabled?: true, annotations_supported?: true, hijack_crocodoc_sessions?: false)
|
||||
|
||||
allow_any_instance_of(Canvadocs::API).to receive(:session).and_return "id" => "SESSION"
|
||||
PluginSetting.create! name: "canvadocs",
|
||||
|
|
|
@ -417,9 +417,7 @@ describe DiscussionEntriesController do
|
|||
it "does not error if data is missing and kaltura is unresponsive" do
|
||||
mock_client = double
|
||||
allow(mock_client).to receive(:startSession)
|
||||
allow(mock_client).to receive(:mediaGet).and_return(nil)
|
||||
allow(mock_client).to receive(:flavorAssetGetByEntryId).and_return(nil)
|
||||
allow(mock_client).to receive(:media_sources).and_return(nil)
|
||||
allow(mock_client).to receive_messages(mediaGet: nil, flavorAssetGetByEntryId: nil, media_sources: nil)
|
||||
allow(CanvasKaltura::ClientV3).to receive(:new).and_return(mock_client)
|
||||
|
||||
topic_with_media_reply
|
||||
|
|
|
@ -116,9 +116,8 @@ describe DiscussionTopicsApiController do
|
|||
end
|
||||
|
||||
it "uses instfs to store attachment if instfs is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: uuid)
|
||||
post "add_entry",
|
||||
params: { topic_id: @topic.id,
|
||||
course_id: @course.id,
|
||||
|
|
|
@ -187,8 +187,7 @@ describe DiscussionTopicsController do
|
|||
|
||||
it "redirects to correct mastery paths edit page" do
|
||||
user_session(@teacher)
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(true)
|
||||
allow(ConditionalRelease::Service).to receive(:env_for).and_return({ dummy: "value" })
|
||||
allow(ConditionalRelease::Service).to receive_messages(enabled_in_context?: true, env_for: { dummy: "value" })
|
||||
get :edit, params: { group_id: @group.id, id: @child_topic.id }
|
||||
redirect_path = "/courses/#{@course.id}/discussion_topics/#{@topic.id}/edit"
|
||||
expect(response).to redirect_to(redirect_path)
|
||||
|
@ -1389,16 +1388,14 @@ describe DiscussionTopicsController do
|
|||
end
|
||||
|
||||
it "includes environment variables if enabled" do
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(true)
|
||||
allow(ConditionalRelease::Service).to receive(:env_for).and_return({ dummy: "value" })
|
||||
allow(ConditionalRelease::Service).to receive_messages(enabled_in_context?: true, env_for: { dummy: "value" })
|
||||
get :edit, params: { course_id: @course.id, id: @topic.id }
|
||||
expect(response).to be_successful
|
||||
expect(controller.js_env[:dummy]).to eq "value"
|
||||
end
|
||||
|
||||
it "does not include environment variables when disabled" do
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(false)
|
||||
allow(ConditionalRelease::Service).to receive(:env_for).and_return({ dummy: "value" })
|
||||
allow(ConditionalRelease::Service).to receive_messages(enabled_in_context?: false, env_for: { dummy: "value" })
|
||||
get :edit, params: { course_id: @course.id, id: @topic.id }
|
||||
expect(response).to be_successful
|
||||
expect(controller.js_env).not_to have_key :dummy
|
||||
|
@ -2262,9 +2259,8 @@ describe DiscussionTopicsController do
|
|||
end
|
||||
|
||||
it "uses inst-fs if it is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: uuid)
|
||||
|
||||
data = fixture_file_upload("docs/txt.txt", "text/plain", true)
|
||||
attachment_model context: @course, uploaded_data: data, folder: Folder.unfiled_folder(@course)
|
||||
|
|
|
@ -287,8 +287,7 @@ describe ExternalToolsController do
|
|||
let(:domain) { "www.example-beta.com" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
tool.course_navigation = { enabled: true }
|
||||
|
@ -539,8 +538,7 @@ describe ExternalToolsController do
|
|||
let(:domain) { "www.example-beta.com" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
@tool.settings[:environments] = {
|
||||
|
@ -801,8 +799,7 @@ describe ExternalToolsController do
|
|||
let(:domain) { "www.example-beta.com" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
@tool.settings[:environments] = {
|
||||
|
@ -2512,8 +2509,7 @@ describe ExternalToolsController do
|
|||
let(:domain) { "www.example-beta.com" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
user_session(account_admin_user)
|
||||
|
||||
|
|
|
@ -1494,8 +1494,7 @@ describe FilesController do
|
|||
|
||||
describe "POST api_capture" do
|
||||
before do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
allow(InstFS).to receive(:jwt_secrets).and_return(["jwt signing key"])
|
||||
allow(InstFS).to receive_messages(enabled?: true, jwt_secrets: ["jwt signing key"])
|
||||
@token = Canvas::Security.create_jwt({}, nil, InstFS.jwt_secret)
|
||||
end
|
||||
|
||||
|
|
|
@ -46,15 +46,14 @@ describe GradebooksController do
|
|||
@media_object = factory_with_protected_attributes(MediaObject, media_id: "m-someid", media_type: "video", title: "Example Media Object", context: @course)
|
||||
@mock_kaltura = double("CanvasKaltura::ClientV3")
|
||||
allow(CanvasKaltura::ClientV3).to receive(:new).and_return(@mock_kaltura)
|
||||
allow(@mock_kaltura).to receive(:startSession).and_return(nil)
|
||||
@media_sources = [{
|
||||
height: "240",
|
||||
width: "336",
|
||||
content_type: "video/mp4",
|
||||
url: "https://kaltura.example.com/some/url",
|
||||
}]
|
||||
allow(@mock_kaltura).to receive_messages(startSession: nil, media_sources: @media_sources)
|
||||
@media_track = @media_object.media_tracks.create!(kind: "subtitles", locale: "en", content: "English").as_json["media_track"]
|
||||
allow(@mock_kaltura).to receive(:media_sources).and_return(@media_sources)
|
||||
end
|
||||
|
||||
it "includes muted assignments" do
|
||||
|
@ -2679,9 +2678,8 @@ describe GradebooksController do
|
|||
end
|
||||
|
||||
it "stores attached files in instfs if instfs is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: uuid)
|
||||
user_session(@teacher)
|
||||
@assignment = @course.assignments.create!(title: "some assignment")
|
||||
@student = @course.enroll_user(User.create!(name: "some user"))
|
||||
|
|
|
@ -165,10 +165,8 @@ describe InfoController do
|
|||
allow(MultiCache.cache).to receive(:fetch).with("readiness").and_return(nil)
|
||||
allow(Delayed::Job.connection).to receive(:active?).and_return(true)
|
||||
allow(Shard.connection).to receive(:active?).and_return(true)
|
||||
allow(Canvadocs).to receive(:enabled?).and_return(true)
|
||||
allow(Canvadocs).to receive_messages(enabled?: true, config: { "base_url" => "https://canvadocs.instructure.com/" })
|
||||
allow(PageView).to receive(:pv4?).and_return(true)
|
||||
allow(Canvadocs).to receive(:config)
|
||||
.and_return({ "base_url" => "https://canvadocs.instructure.com/" })
|
||||
allow(ConfigFile).to receive(:load).and_call_original
|
||||
allow(ConfigFile).to receive(:load)
|
||||
.with("pv4").and_return({ "uri" => "https://pv4.instructure.com/api/123/" })
|
||||
|
@ -177,8 +175,7 @@ describe InfoController do
|
|||
.with("rich-content-service")
|
||||
.and_return(DynamicSettings::FallbackProxy.new("app-host" => "rce.instructure.com"))
|
||||
allow(CanvasHttp).to receive(:get).with(any_args).and_return(success_response)
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive(:run_periodically).and_return(true)
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive(:healthy?).and_return(true)
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive_messages(run_periodically: true, healthy?: true)
|
||||
end
|
||||
|
||||
it "renders readiness check within json response" do
|
||||
|
|
|
@ -32,8 +32,7 @@ describe Login::ExternalAuthObserversController do
|
|||
end
|
||||
|
||||
it "redirects to login path" do
|
||||
allow(controller).to receive(:valid_user_unique_id?).and_return(true)
|
||||
allow(controller).to receive(:valid_observee_unique_id?).and_return(true)
|
||||
allow(controller).to receive_messages(valid_user_unique_id?: true, valid_observee_unique_id?: true)
|
||||
subject = post(:redirect_login, params:)
|
||||
expect(subject).to be_successful
|
||||
end
|
||||
|
|
|
@ -186,8 +186,7 @@ describe Login::SamlController do
|
|||
@pseudonym.save!
|
||||
|
||||
saml_response = SAML2::Response.new
|
||||
allow(saml_response).to receive(:errors).and_return([])
|
||||
allow(saml_response).to receive(:issuer).and_return(double(id: "such a lie"))
|
||||
allow(saml_response).to receive_messages(errors: [], issuer: double(id: "such a lie"))
|
||||
allow(SAML2::Bindings::HTTP_POST).to receive(:decode).and_return(
|
||||
[saml_response, nil]
|
||||
)
|
||||
|
@ -235,9 +234,7 @@ describe Login::SamlController do
|
|||
@pseudonym.save!
|
||||
|
||||
saml_response = SAML2::Response.new
|
||||
allow(saml_response).to receive(:errors).and_return([])
|
||||
allow(saml_response).to receive(:issuer).and_return(nil)
|
||||
allow(saml_response).to receive(:assertions).and_return([double(issuer: double(id: "such a lie"))])
|
||||
allow(saml_response).to receive_messages(errors: [], issuer: nil, assertions: [double(issuer: double(id: "such a lie"))])
|
||||
allow(SAML2::Bindings::HTTP_POST).to receive(:decode).and_return(
|
||||
[saml_response, nil]
|
||||
)
|
||||
|
@ -586,8 +583,7 @@ describe Login::SamlController do
|
|||
|
||||
it "redirects to login screen with message if no AAC found" do
|
||||
saml_response = SAML2::Response.new
|
||||
allow(saml_response).to receive(:errors).and_return([])
|
||||
allow(saml_response).to receive(:issuer).and_return(double(id: "hahahahahahaha"))
|
||||
allow(saml_response).to receive_messages(errors: [], issuer: double(id: "hahahahahahaha"))
|
||||
allow(SAML2::Bindings::HTTP_POST).to receive(:decode).and_return(
|
||||
[saml_response, nil]
|
||||
)
|
||||
|
|
|
@ -43,8 +43,7 @@ describe Lti::Concerns::ParentFrame do
|
|||
before do
|
||||
controller.instance_variable_set(:@current_user, current_pseudonym.user)
|
||||
controller.instance_variable_set(:@current_pseudonym, current_pseudonym)
|
||||
allow(controller).to receive(:parent_frame_context).and_return tool.id.to_s
|
||||
allow(controller).to receive(:session).and_return nil
|
||||
allow(controller).to receive_messages(parent_frame_context: tool.id.to_s, session: nil)
|
||||
allow(ContextExternalTool).to receive(:find_by).with(id: tool.id.to_s).and_return(tool)
|
||||
end
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ describe Lti::DataServicesController do
|
|||
end
|
||||
|
||||
before do
|
||||
allow(CanvasSecurity::ServicesJwt).to receive(:encryption_secret).and_return("setecastronomy92" * 2)
|
||||
allow(CanvasSecurity::ServicesJwt).to receive(:signing_secret).and_return("donttell" * 10)
|
||||
allow(CanvasSecurity::ServicesJwt).to receive_messages(encryption_secret: "setecastronomy92" * 2, signing_secret: "donttell" * 10)
|
||||
allow(HTTParty).to receive(:send).and_return(double(body: subscription, code: 200))
|
||||
allow(DynamicSettings).to receive(:find).and_call_original
|
||||
allow(DynamicSettings).to receive(:find)
|
||||
|
|
|
@ -672,8 +672,7 @@ module Lti::IMS
|
|||
|
||||
context "with InstFS enabled" do
|
||||
before do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
allow(InstFS).to receive(:jwt_secrets).and_return(["jwt signing key"])
|
||||
allow(InstFS).to receive_messages(enabled?: true, jwt_secrets: ["jwt signing key"])
|
||||
@token = Canvas::Security.create_jwt({}, nil, InstFS.jwt_secret)
|
||||
allow(CanvasHttp).to receive(:post).and_return(
|
||||
double(class: Net::HTTPCreated, code: 201, body: {})
|
||||
|
|
|
@ -192,8 +192,7 @@ RSpec.describe Lti::ToolConfigurationsApiController do
|
|||
|
||||
context 'when the response is "not found"' do
|
||||
before do
|
||||
allow(stubbed_response).to receive(:message).and_return("Not found")
|
||||
allow(stubbed_response).to receive(:code).and_return("404")
|
||||
allow(stubbed_response).to receive_messages(message: "Not found", code: "404")
|
||||
make_request
|
||||
end
|
||||
|
||||
|
@ -202,8 +201,7 @@ RSpec.describe Lti::ToolConfigurationsApiController do
|
|||
|
||||
context 'when the response is "unauthorized"' do
|
||||
before do
|
||||
allow(stubbed_response).to receive(:message).and_return("Unauthorized")
|
||||
allow(stubbed_response).to receive(:code).and_return("401")
|
||||
allow(stubbed_response).to receive_messages(message: "Unauthorized", code: "401")
|
||||
make_request
|
||||
end
|
||||
|
||||
|
@ -212,8 +210,7 @@ RSpec.describe Lti::ToolConfigurationsApiController do
|
|||
|
||||
context 'when the response is "internal server error"' do
|
||||
before do
|
||||
allow(stubbed_response).to receive(:message).and_return("Internal server error")
|
||||
allow(stubbed_response).to receive(:code).and_return("500")
|
||||
allow(stubbed_response).to receive_messages(message: "Internal server error", code: "500")
|
||||
make_request
|
||||
end
|
||||
|
||||
|
|
|
@ -2872,8 +2872,7 @@ describe Quizzes::QuizzesController do
|
|||
false
|
||||
end
|
||||
subject.instance_variable_set(:@quiz, @quiz)
|
||||
allow(@quiz).to receive(:require_lockdown_browser?).and_return(false)
|
||||
allow(@quiz).to receive(:ip_filter).and_return(false)
|
||||
allow(@quiz).to receive_messages(require_lockdown_browser?: false, ip_filter: false)
|
||||
subject.instance_variable_set(:@course, @course)
|
||||
subject.instance_variable_set(:@current_user, @student)
|
||||
end
|
||||
|
@ -2900,8 +2899,7 @@ describe Quizzes::QuizzesController do
|
|||
end
|
||||
|
||||
it "false with wrong IP address" do
|
||||
allow(@quiz).to receive(:ip_filter).and_return(true)
|
||||
allow(@quiz).to receive(:valid_ip?).and_return(false)
|
||||
allow(@quiz).to receive_messages(ip_filter: true, valid_ip?: false)
|
||||
allow(subject).to receive(:params).and_return({ take: 1 })
|
||||
expect(return_value).to be false
|
||||
end
|
||||
|
|
|
@ -639,9 +639,8 @@ describe SubmissionsController do
|
|||
end
|
||||
|
||||
it "uses instfs to save google doc if instfs is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: uuid)
|
||||
|
||||
attachment = @assignment.submissions.first.attachments.new
|
||||
SubmissionsController.new.store_google_doc_attachment(attachment, File.open("public/images/a.png"))
|
||||
|
|
|
@ -92,8 +92,7 @@ describe UsersController do
|
|||
let(:override_url) { "http://www.example-beta.com/basic_lti" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
tool.settings[:environments] = {
|
||||
|
@ -170,8 +169,7 @@ describe UsersController do
|
|||
it "sets up oauth for google_drive" do
|
||||
state = nil
|
||||
settings_mock = double
|
||||
allow(settings_mock).to receive(:settings).and_return({})
|
||||
allow(settings_mock).to receive(:enabled?).and_return(true)
|
||||
allow(settings_mock).to receive_messages(settings: {}, enabled?: true)
|
||||
|
||||
user_factory(active_all: true)
|
||||
user_session(@user)
|
||||
|
|
|
@ -76,8 +76,7 @@ module Factories
|
|||
$stub_file_counter ||= 0
|
||||
data ||= "ohai#{$stub_file_counter += 1}"
|
||||
sio = StringIO.new(data)
|
||||
allow(sio).to receive(:original_filename).and_return(filename)
|
||||
allow(sio).to receive(:content_type).and_return(content_type)
|
||||
allow(sio).to receive_messages(original_filename: filename, content_type:)
|
||||
sio
|
||||
end
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ module Factories
|
|||
# at least one thing cares about the id of the pseudonym... using the
|
||||
# object_id should make it unique (but obviously things will fail if
|
||||
# it tries to load it from the db.)
|
||||
allow(pseudonym).to receive(:id).and_return(pseudonym.object_id)
|
||||
allow(pseudonym).to receive(:unique_id).and_return("unique_id")
|
||||
allow(pseudonym).to receive(:global_id).and_return(10_000_000_000_001)
|
||||
allow(pseudonym).to receive_messages(id: pseudonym.object_id,
|
||||
unique_id: "unique_id",
|
||||
global_id: 10_000_000_000_001)
|
||||
end
|
||||
|
||||
session = double("PseudonymSession",
|
||||
|
|
|
@ -1230,8 +1230,10 @@ describe ApplicationHelper do
|
|||
it "includes canvadocs domain if enabled" do
|
||||
account.enable_csp!
|
||||
|
||||
allow(Canvadocs).to receive(:enabled?).and_return(true)
|
||||
allow(Canvadocs).to receive(:config).and_return("base_url" => "https://canvadocs.instructure.com/1")
|
||||
allow(Canvadocs).to receive_messages(
|
||||
enabled?: true,
|
||||
config: { "base_url" => "https://canvadocs.instructure.com/1" }
|
||||
)
|
||||
helper.add_csp_for_root
|
||||
expect(headers["Content-Security-Policy"]).to eq "frame-src 'self' blob: canvadocs.instructure.com localhost root_account.test root_account2.test; "
|
||||
end
|
||||
|
@ -1239,8 +1241,10 @@ describe ApplicationHelper do
|
|||
it "includes inst_fs domain if enabled" do
|
||||
account.enable_csp!
|
||||
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
allow(InstFS).to receive(:app_host).and_return("https://inst_fs.instructure.com")
|
||||
allow(InstFS).to receive_messages(
|
||||
enabled?: true,
|
||||
app_host: "https://inst_fs.instructure.com"
|
||||
)
|
||||
helper.add_csp_for_root
|
||||
expect(headers["Content-Security-Policy"]).to eq "frame-src 'self' blob: inst_fs.instructure.com localhost root_account.test root_account2.test; "
|
||||
end
|
||||
|
|
|
@ -188,8 +188,7 @@ describe AssignmentsHelper do
|
|||
assignment.assign_peer_review(reviewer, reviewee)
|
||||
|
||||
# Avoid having to go down a rabbit hole of imports
|
||||
allow(self).to receive(:submission_author_name_for).and_return("Nobody")
|
||||
allow(self).to receive(:link_to).and_return("")
|
||||
allow(self).to receive_messages(submission_author_name_for: "Nobody", link_to: "")
|
||||
end
|
||||
|
||||
it "creates a URL containing the peer reviewee's user ID when peer reviewing is not anonymous" do
|
||||
|
|
|
@ -44,44 +44,38 @@ describe BrokenLinkHelper, type: :controller do
|
|||
end
|
||||
|
||||
it "returns false if the location is not found in the referrer body" do
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
allow(request).to receive(:path).and_return "/bad_link"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/assignments/#{@assignment.id}", path: "/bad_link")
|
||||
@assignment.update(description: "stuff")
|
||||
expect(send_broken_content!).to be false
|
||||
end
|
||||
|
||||
it "returns true for bad links in assignments with local 404 errors" do
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/assignments/#{@assignment.id}", path: "/test_error")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
it "returns true for bad links in quizzes" do
|
||||
quiz_model(course: @course, description: "<a href='/test_error'>bad link</a>")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/quizzes/#{@quiz.id}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/quizzes/#{@quiz.id}", path: "/test_error")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
it "returns true for bad links in discussion topics" do
|
||||
discussion_topic_model(context: @course, message: "<a href='/test_error'>bad link</a>")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/discussion_topics/#{@topic.id}", path: "/test_error")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
it "returns false for bad links in discussion topic entries" do
|
||||
discussion_topic_model(context: @course, message: "<a href='/good_page'>bad link</a>")
|
||||
@topic.reply_from(user: @student, html: "<a href='/test_error'>bad link</a>")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/discussion_topics/#{@topic.id}", path: "/test_error")
|
||||
expect(send_broken_content!).to be false
|
||||
end
|
||||
|
||||
it "returns true for bad links in wiki pages" do
|
||||
wiki_page_model(context: @course, body: "<a href='/test_error'>bad link</a>")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/pages/#{@page.url}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/pages/#{@page.url}", path: "/test_error")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
|
@ -89,8 +83,7 @@ describe BrokenLinkHelper, type: :controller do
|
|||
wiki_page_model(context: @course, body: "<a href='/test_error'>bad link</a>")
|
||||
@page.set_as_front_page!
|
||||
@course.update_attribute(:default_view, "wiki")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}"
|
||||
allow(request).to receive(:path).and_return "/test_error"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}", path: "/test_error")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
|
@ -98,8 +91,7 @@ describe BrokenLinkHelper, type: :controller do
|
|||
linked_assignment = @assignment
|
||||
assignment_model(course: @course).update(workflow_state: "unpublished")
|
||||
linked_assignment.update(description: "<a href='/courses/#{@course.id}/assignments/#{@assignment.id}'>Unpublished Assignment</a>")
|
||||
allow(request).to receive(:referer).and_return "/courses/#{@course.id}/assignments/#{linked_assignment.id}"
|
||||
allow(request).to receive(:path).and_return "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
allow(request).to receive_messages(referer: "/courses/#{@course.id}/assignments/#{linked_assignment.id}", path: "/courses/#{@course.id}/assignments/#{@assignment.id}")
|
||||
expect(send_broken_content!).to be true
|
||||
end
|
||||
|
||||
|
|
|
@ -45,9 +45,8 @@ describe CollaborationsHelper do
|
|||
it "has the data-update-launch-url attribute if it is a ExternalToolCollaboration" do
|
||||
assign(:context, course)
|
||||
launch_url = "http://example.com/test"
|
||||
allow(collab).to receive(:is_a?).and_return false
|
||||
allow(collab).to receive_messages(is_a?: false, update_url: launch_url)
|
||||
allow(collab).to receive(:is_a?).with(ExternalToolCollaboration).and_return true
|
||||
allow(collab).to receive(:update_url).and_return(launch_url)
|
||||
expect(helper).to receive(:render).with("collaborations/collaboration",
|
||||
include(
|
||||
data_attributes: include(
|
||||
|
@ -68,8 +67,7 @@ describe CollaborationsHelper do
|
|||
|
||||
it "doesn't return the edit button for an ExternalToolCollaboration that don't have an edit url" do
|
||||
allow(collab).to receive(:is_a?).with(ExternalToolCollaboration).and_return(true)
|
||||
allow(collab).to receive(:update_url).and_return(nil)
|
||||
allow(collab).to receive(:grants_any_right?).and_return(true)
|
||||
allow(collab).to receive_messages(update_url: nil, grants_any_right?: true)
|
||||
expect(helper).not_to receive(:render)
|
||||
helper.edit_button(collab, user)
|
||||
end
|
||||
|
|
|
@ -261,9 +261,7 @@ describe ContextModulesHelper do
|
|||
{ id: 27, assignment_sets: [{ id: 45 }, { id: 36 }] },
|
||||
{ id: 28, assignment_sets: [] }
|
||||
]
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(true)
|
||||
allow(ConditionalRelease::Service).to receive(:rules_for).and_return(@rules)
|
||||
allow(ConditionalRelease::Service).to receive(:active_rules).and_return([1, 2, 3])
|
||||
allow(ConditionalRelease::Service).to receive_messages(enabled_in_context?: true, rules_for: @rules, active_rules: [1, 2, 3])
|
||||
end
|
||||
|
||||
it "does not affect cache keys unless mastery paths enabled" do
|
||||
|
|
|
@ -51,8 +51,7 @@ describe "ruby_version_compat" do
|
|||
testfile = fixture_file_upload("docs/txt.txt", "text/plain", true)
|
||||
testfile.instance_variable_set(:@original_filename, nil)
|
||||
controller = ApplicationController.new
|
||||
allow(controller).to receive(:params).and_return({ upload: { file1: testfile } })
|
||||
allow(controller).to receive(:request).and_return(double(path: "/upload"))
|
||||
allow(controller).to receive_messages(params: { upload: { file1: testfile } }, request: double(path: "/upload"))
|
||||
expect { controller.force_utf8_params }.to_not raise_error
|
||||
expect(testfile.original_filename).to be_nil
|
||||
end
|
||||
|
|
|
@ -102,8 +102,7 @@ module Lti::IMS
|
|||
let(:submitted_at) { 5.minutes.ago.iso8601(3) }
|
||||
|
||||
before do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
allow(InstFS).to receive(:jwt_secrets).and_return(["jwt signing key"])
|
||||
allow(InstFS).to receive_messages(enabled?: true, jwt_secrets: ["jwt signing key"])
|
||||
@token = Canvas::Security.create_jwt({}, nil, InstFS.jwt_secret)
|
||||
Account.root_accounts.first.enable_feature! :ags_scores_multiple_files
|
||||
end
|
||||
|
|
|
@ -38,8 +38,7 @@ describe "User Content" do
|
|||
end
|
||||
|
||||
it "allows object_snippet if there is no safefiles domain configured" do
|
||||
allow(HostUrl).to receive(:default_host).and_return("canvas.example.com")
|
||||
allow(HostUrl).to receive(:file_host).and_return("canvas.example.com")
|
||||
allow(HostUrl).to receive_messages(default_host: "canvas.example.com", file_host: "canvas.example.com")
|
||||
|
||||
obj_data = "<div>test</div>"
|
||||
snippet = Base64.encode64 obj_data
|
||||
|
|
|
@ -39,11 +39,9 @@ describe Api::V1::SisAssignment do
|
|||
end
|
||||
|
||||
let(:assignment_overrides) do
|
||||
allow(assignment_override_1).to receive(:set_type).and_return("CourseSection")
|
||||
allow(assignment_override_1).to receive(:set_id).and_return(1)
|
||||
allow(assignment_override_1).to receive_messages(set_type: "CourseSection", set_id: 1)
|
||||
|
||||
allow(assignment_override_2).to receive(:set_type).and_return("CourseSection")
|
||||
allow(assignment_override_2).to receive(:set_id).and_return(2)
|
||||
allow(assignment_override_2).to receive_messages(set_type: "CourseSection", set_id: 2)
|
||||
|
||||
[
|
||||
assignment_override_1,
|
||||
|
@ -66,22 +64,26 @@ describe Api::V1::SisAssignment do
|
|||
before do
|
||||
allow(assignment_1).to receive(:locked_for?).and_return(false)
|
||||
|
||||
allow(assignment_overrides).to receive(:loaded?).and_return(true)
|
||||
allow(assignment_overrides).to receive(:unlock_at).and_return(15.days.ago)
|
||||
allow(assignment_overrides).to receive(:lock_at).and_return(2.days.from_now)
|
||||
allow(assignment_overrides).to receive_messages(
|
||||
loaded?: true,
|
||||
unlock_at: 15.days.ago,
|
||||
lock_at: 2.days.from_now
|
||||
)
|
||||
|
||||
allow(course_section_1).to receive(:id).and_return(1)
|
||||
allow(course_section_2).to receive(:id).and_return(2)
|
||||
allow(course_section_3).to receive(:id).and_return(3)
|
||||
|
||||
course_sections.each do |course_section|
|
||||
allow(course_section).to receive(:nonxlist_course).and_return(course_1)
|
||||
allow(course_section).to receive(:crosslisted?).and_return(false)
|
||||
allow(course_section).to receive_messages(nonxlist_course: course_1,
|
||||
crosslisted?: false)
|
||||
end
|
||||
|
||||
allow(course_sections).to receive(:loaded?).and_return(true)
|
||||
allow(course_sections).to receive(:active_course_sections).and_return(course_sections)
|
||||
allow(course_sections).to receive(:association).and_return(OpenStruct.new(loaded?: true))
|
||||
allow(course_sections).to receive_messages(
|
||||
loaded?: true,
|
||||
active_course_sections: course_sections,
|
||||
association: OpenStruct.new(loaded?: true)
|
||||
)
|
||||
end
|
||||
|
||||
it "creates assignment groups that have name and integration_data with proper data" do
|
||||
|
|
|
@ -440,8 +440,7 @@ describe Api::V1::Submission do
|
|||
let(:json) { fake_controller.submission_json(submission, assignment, teacher, session) }
|
||||
|
||||
before do
|
||||
allow(Canvadocs).to receive(:annotations_supported?).and_return(true)
|
||||
allow(Canvadocs).to receive(:enabled?).and_return(true)
|
||||
allow(Canvadocs).to receive_messages(annotations_supported?: true, enabled?: true)
|
||||
Canvadoc.create!(document_id: "abc123#{attachment.id}", attachment_id: attachment.id)
|
||||
end
|
||||
|
||||
|
|
|
@ -860,8 +860,7 @@ describe Api do
|
|||
end
|
||||
|
||||
it "does not prepend mobile css when coming from a web browser, even if it is a mobile browser" do
|
||||
allow(@k).to receive(:in_app?).and_return(true)
|
||||
allow(@k).to receive(:mobile_device?).and_return(true)
|
||||
allow(@k).to receive_messages(in_app?: true, mobile_device?: true)
|
||||
res = @k.api_user_content(@html, @course, @student)
|
||||
expect(res).to eq "<p>a</p><p>b</p>"
|
||||
end
|
||||
|
@ -878,9 +877,11 @@ describe Api do
|
|||
proxy_instance.extend Rails.application.routes.url_helpers
|
||||
proxy_instance.extend ActionDispatch::Routing::UrlFor
|
||||
|
||||
allow(proxy_instance).to receive(:request).and_return(nil)
|
||||
allow(proxy_instance).to receive(:get_host_and_protocol_from_request).and_return(["school.instructure.com", "https"])
|
||||
allow(proxy_instance).to receive(:url_options).and_return({})
|
||||
allow(proxy_instance).to receive_messages(
|
||||
request: nil,
|
||||
get_host_and_protocol_from_request: ["school.instructure.com", "https"],
|
||||
url_options: {}
|
||||
)
|
||||
end
|
||||
|
||||
it "transposes ids in urls, leaving equation images alone" do
|
||||
|
|
|
@ -30,8 +30,10 @@ describe AssignmentUtil do
|
|||
let(:assignment_name_length_value) { 15 }
|
||||
|
||||
def account_stub_helper(assignment, require_due_date, sis_syncing, new_sis_integrations)
|
||||
allow(assignment.context.account).to receive(:sis_require_assignment_due_date).and_return({ value: require_due_date })
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: sis_syncing })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_require_assignment_due_date: { value: require_due_date },
|
||||
sis_syncing: { value: sis_syncing }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(new_sis_integrations)
|
||||
end
|
||||
|
||||
|
@ -155,40 +157,50 @@ describe AssignmentUtil do
|
|||
describe "assignment_name_length_required?" do
|
||||
it "returns true when all 4 are set to true" do
|
||||
assignment.post_to_sis = true
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive(:sis_assignment_name_length).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_syncing: { value: true },
|
||||
sis_assignment_name_length: { value: true }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(true)
|
||||
expect(described_class.assignment_name_length_required?(assignment)).to be(true)
|
||||
end
|
||||
|
||||
it "returns false when sis_sycning is set to false" do
|
||||
assignment.post_to_sis = true
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: false })
|
||||
allow(assignment.context.account).to receive(:sis_assignment_name_length).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_syncing: { value: false },
|
||||
sis_assignment_name_length: { value: true }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(true)
|
||||
expect(described_class.assignment_name_length_required?(assignment)).to be(false)
|
||||
end
|
||||
|
||||
it "returns false when post_to_sis is false" do
|
||||
assignment.post_to_sis = false
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive(:sis_assignment_name_length).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_syncing: { value: true },
|
||||
sis_assignment_name_length: { value: true }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(true)
|
||||
expect(described_class.assignment_name_length_required?(assignment)).to be(false)
|
||||
end
|
||||
|
||||
it "returns false when sis_assignment_name_length is false" do
|
||||
assignment.post_to_sis = true
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: false })
|
||||
allow(assignment.context.account).to receive(:sis_assignment_name_length).and_return({ value: false })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_syncing: { value: false },
|
||||
sis_assignment_name_length: { value: false }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(true)
|
||||
expect(described_class.assignment_name_length_required?(assignment)).to be(false)
|
||||
end
|
||||
|
||||
it "returns false when new_sis_integrations is false" do
|
||||
assignment.post_to_sis = true
|
||||
allow(assignment.context.account).to receive(:sis_syncing).and_return({ value: false })
|
||||
allow(assignment.context.account).to receive(:sis_assignment_name_length).and_return({ value: true })
|
||||
allow(assignment.context.account).to receive_messages(
|
||||
sis_syncing: { value: false },
|
||||
sis_assignment_name_length: { value: true }
|
||||
)
|
||||
allow(assignment.context.account).to receive(:feature_enabled?).with("new_sis_integrations").and_return(false)
|
||||
expect(described_class.assignment_name_length_required?(assignment)).to be(false)
|
||||
end
|
||||
|
|
|
@ -122,8 +122,13 @@ describe BrandableCSS do
|
|||
end
|
||||
|
||||
it "uploads json file to s3 if cdn is enabled" do
|
||||
allow(Canvas::Cdn).to receive(:enabled?).and_return(true)
|
||||
allow(Canvas::Cdn).to receive(:config).and_return(ActiveSupport::OrderedOptions.new.merge(region: "us-east-1", aws_access_key_id: "id", aws_secret_access_key: "secret", bucket: "cdn"))
|
||||
allow(Canvas::Cdn).to receive_messages(
|
||||
enabled?: true,
|
||||
config: ActiveSupport::OrderedOptions.new.merge(region: "us-east-1",
|
||||
aws_access_key_id: "id",
|
||||
aws_secret_access_key: "secret",
|
||||
bucket: "cdn")
|
||||
)
|
||||
|
||||
file = StringIO.new
|
||||
allow(BrandableCSS).to receive(:default_brand_file).with(type, high_contrast).and_return(file)
|
||||
|
@ -133,8 +138,13 @@ describe BrandableCSS do
|
|||
end
|
||||
|
||||
it "deletes the local json file if cdn is enabled" do
|
||||
allow(Canvas::Cdn).to receive(:enabled?).and_return(true)
|
||||
allow(Canvas::Cdn).to receive(:config).and_return(ActiveSupport::OrderedOptions.new.merge(region: "us-east-1", aws_access_key_id: "id", aws_secret_access_key: "secret", bucket: "cdn"))
|
||||
allow(Canvas::Cdn).to receive_messages(
|
||||
enabled?: true,
|
||||
config: ActiveSupport::OrderedOptions.new.merge(region: "us-east-1",
|
||||
aws_access_key_id: "id",
|
||||
aws_secret_access_key: "secret",
|
||||
bucket: "cdn")
|
||||
)
|
||||
file = StringIO.new
|
||||
allow(BrandableCSS).to receive(:default_brand_file).with(type, high_contrast).and_return(file)
|
||||
expect(File).to receive(:delete).with(BrandableCSS.default_brand_file(type, high_contrast))
|
||||
|
|
|
@ -2716,8 +2716,7 @@ describe Canvas::LiveEvents do
|
|||
let(:region_code) { "prod-iad" }
|
||||
|
||||
before do
|
||||
allow(Canvas).to receive(:region).and_return(region)
|
||||
allow(Canvas).to receive(:region_code).and_return(region_code)
|
||||
allow(Canvas).to receive_messages(region:, region_code:)
|
||||
end
|
||||
|
||||
it "sets region to Canvas.region" do
|
||||
|
@ -2744,8 +2743,7 @@ describe Canvas::LiveEvents do
|
|||
let(:environment) { "beta" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return true
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return environment
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: environment)
|
||||
end
|
||||
|
||||
it "sets environment to beta" do
|
||||
|
|
|
@ -31,7 +31,8 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
|
|||
"tool_profiles" => [{ "title" => "a1", "migration_id" => "a1" }],
|
||||
"outcomes" => [{ "title" => "a1", "migration_id" => "a1" }],
|
||||
"file_map" => { "oi" => { "title" => "a1", "migration_id" => "a1" } },
|
||||
"assignments" => [{ "title" => "a1", "migration_id" => "a1" }, { "title" => "a2", "migration_id" => "a2", "assignment_group_migration_id" => "a1" }],
|
||||
"assignments" => [{ "title" => "a1", "migration_id" => "a1" },
|
||||
{ "title" => "a2", "migration_id" => "a2", "assignment_group_migration_id" => "a1" }],
|
||||
"assignment_groups" => [{ "title" => "a1", "migration_id" => "a1" }],
|
||||
"calendar_events" => [],
|
||||
"course" => {
|
||||
|
@ -41,14 +42,16 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
|
|||
}
|
||||
}
|
||||
@migration = double
|
||||
allow(@migration).to receive(:migration_type).and_return("common_cartridge_importer")
|
||||
allow(@migration).to receive(:overview_attachment).and_return(@migration)
|
||||
allow(@migration).to receive(:open).and_return(@migration)
|
||||
allow(@migration).to receive(:shard).and_return("1")
|
||||
allow(@migration).to receive(:cache_key).and_return("1")
|
||||
allow(@migration).to receive_messages(
|
||||
migration_type: "common_cartridge_importer",
|
||||
overview_attachment: @migration,
|
||||
open: @migration,
|
||||
shard: "1",
|
||||
cache_key: "1",
|
||||
read: @overview.to_json,
|
||||
context: course_model
|
||||
)
|
||||
allow(@migration).to receive(:close)
|
||||
allow(@migration).to receive(:read).and_return(@overview.to_json)
|
||||
allow(@migration).to receive(:context).and_return(course_model)
|
||||
@formatter = Canvas::Migration::Helpers::SelectiveContentFormatter.new(@migration, "https://example.com", global_identifiers: true)
|
||||
end
|
||||
|
||||
|
@ -246,10 +249,10 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
|
|||
@group = Group.create!(name: "group1", group_category: @category, context: @course)
|
||||
@announcement = announcement_model
|
||||
@migration = double
|
||||
allow(@migration).to receive(:migration_type).and_return("course_copy_importer")
|
||||
allow(@migration).to receive(:source_course).and_return(@course)
|
||||
export = @course.content_exports.create!(export_type: ContentExport::COURSE_COPY)
|
||||
allow(@migration).to receive(:content_export).and_return(export)
|
||||
allow(@migration).to receive_messages(migration_type: "course_copy_importer",
|
||||
source_course: @course,
|
||||
content_export: export)
|
||||
@course_outcome = outcome_model(title: "zebra")
|
||||
@account_outcome = outcome_model(outcome_context: @course.account, title: "alpaca")
|
||||
@out_group1 = outcome_group_model(title: "striker")
|
||||
|
|
|
@ -78,14 +78,12 @@ describe Canvas::RequestForgeryProtection do
|
|||
end
|
||||
|
||||
it "does not verify token if api_request? is true and in_app? is false" do
|
||||
allow(@controller).to receive(:api_request?).and_return(true)
|
||||
allow(@controller).to receive(:in_app?).and_return(false)
|
||||
allow(@controller).to receive_messages(api_request?: true, in_app?: false)
|
||||
expect(@controller.verified_request?).to be_truthy
|
||||
end
|
||||
|
||||
it "verifies token if api_request? is true but in_app? is also true" do
|
||||
allow(@controller).to receive(:api_request?).and_return(true)
|
||||
allow(@controller).to receive(:in_app?).and_return(true)
|
||||
allow(@controller).to receive_messages(api_request?: true, in_app?: true)
|
||||
expect(@controller.verified_request?).to be_falsey
|
||||
end
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ describe RequestThrottle do
|
|||
end
|
||||
|
||||
it "passes on other requests" do
|
||||
allow(throttler).to receive(:approved?).and_return(false)
|
||||
allow(throttler).to receive(:blocked?).and_return(false)
|
||||
allow(throttler).to receive_messages(approved?: false, blocked?: false)
|
||||
expect(strip_variable_headers(throttler.call(request_user_1))).to eq response
|
||||
end
|
||||
|
||||
|
@ -260,8 +259,7 @@ describe RequestThrottle do
|
|||
end
|
||||
|
||||
before do
|
||||
allow(throttler).to receive(:approved?).and_return(false)
|
||||
allow(throttler).to receive(:blocked?).and_return(false)
|
||||
allow(throttler).to receive_messages(approved?: false, blocked?: false)
|
||||
end
|
||||
|
||||
it "skips without redis enabled" do
|
||||
|
@ -502,8 +500,7 @@ describe RequestThrottle do
|
|||
it "will always be allowed when disabled, even with full bucket" do
|
||||
allow(RequestThrottle).to receive(:enabled?).and_return(false)
|
||||
req = request_logged_out
|
||||
allow(req).to receive(:fullpath).and_return("/")
|
||||
allow(req).to receive(:env).and_return({ "canvas.request_throttle.user_id" => ["123"] })
|
||||
allow(req).to receive_messages(fullpath: "/", env: { "canvas.request_throttle.user_id" => ["123"] })
|
||||
allow(@bucket).to receive(:full?).and_return(true)
|
||||
expect(throttler.allowed?(request_logged_out, @bucket)).to be_truthy
|
||||
end
|
||||
|
|
|
@ -45,17 +45,12 @@ describe "Canvas::Twilio" do
|
|||
end
|
||||
|
||||
account = double("Canvas::Twilio.client.account")
|
||||
allow(account).to receive(:incoming_phone_numbers).and_return(
|
||||
double("Canvas::Twilio.client.api.account.client.incoming_phone_numbers",
|
||||
stream: phone_number_objects)
|
||||
)
|
||||
allow(account).to receive(:messages).and_return(double)
|
||||
allow(account).to receive_messages(incoming_phone_numbers: double("Canvas::Twilio.client.api.account.client.incoming_phone_numbers",
|
||||
stream: phone_number_objects),
|
||||
messages: double)
|
||||
|
||||
client = double("Canvas::Twilio.client")
|
||||
allow(client).to receive(:lookups).and_return(lookups)
|
||||
allow(client).to receive(:api).and_return(
|
||||
double("Canvas::Twilio.client.api", account:)
|
||||
)
|
||||
allow(client).to receive_messages(lookups:, api: double("Canvas::Twilio.client.api", account:))
|
||||
allow(Canvas::Twilio).to receive(:client).and_return(client)
|
||||
end
|
||||
|
||||
|
|
|
@ -97,8 +97,7 @@ describe CC::BasicLTILinks do
|
|||
|
||||
context "with environment-specific overrides" do
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
tool.settings[:environments] = {
|
||||
domain: "example-beta.com"
|
||||
}
|
||||
|
|
|
@ -220,9 +220,8 @@ describe "Common Cartridge exporting" do
|
|||
end
|
||||
|
||||
it "uses instfs to host export files if it is enabled" do
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
uuid = "1234-abcd"
|
||||
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||
allow(InstFS).to receive_messages(enabled?: true, direct_upload: uuid)
|
||||
@ce.export(synchronous: true)
|
||||
expect(@ce.attachments.first.instfs_uuid).to eq(uuid)
|
||||
end
|
||||
|
@ -409,9 +408,8 @@ describe "Common Cartridge exporting" do
|
|||
asset: { id: "some-kaltura-id", size: 1234, status: "2" },
|
||||
path: "media_objects/some-kaltura-id"
|
||||
})
|
||||
allow(CanvasKaltura::ClientV3).to receive(:config).and_return({})
|
||||
allow(CanvasKaltura::ClientV3).to receive_messages(config: {}, flavorAssetGetPlaylistUrl: "some-url")
|
||||
allow(CanvasKaltura::ClientV3).to receive(:startSession)
|
||||
allow(CanvasKaltura::ClientV3).to receive(:flavorAssetGetPlaylistUrl).and_return("some-url")
|
||||
mock_http_response = Struct.new(:code) do
|
||||
def read_body(stream)
|
||||
stream.puts("lalala")
|
||||
|
@ -652,9 +650,11 @@ describe "Common Cartridge exporting" do
|
|||
stub_kaltura
|
||||
kaltura_session = double("kaltura_session")
|
||||
allow(CC::CCHelper).to receive(:kaltura_admin_session).and_return(kaltura_session)
|
||||
allow(kaltura_session).to receive(:flavorAssetGetPlaylistUrl).and_return("http://www.example.com/blah.flv")
|
||||
allow(kaltura_session).to receive_messages(
|
||||
flavorAssetGetPlaylistUrl: "http://www.example.com/blah.flv",
|
||||
flavorAssetGetOriginalAsset: { id: 1, status: "2", fileExt: "flv" }
|
||||
)
|
||||
stub_request(:get, "http://www.example.com/blah.flv").to_return(body: "", status: 200)
|
||||
allow(kaltura_session).to receive(:flavorAssetGetOriginalAsset).and_return({ id: 1, status: "2", fileExt: "flv" })
|
||||
stub_request(:get, "http://www.example.com/blah.flv").to_return(body: "", status: 200)
|
||||
expect_any_instance_of(MediaObject).to receive(:create_attachment).and_call_original
|
||||
obj = @course.media_objects.create! media_id: "0_deadbeef", user_entered_title: "blah.flv"
|
||||
|
|
|
@ -284,8 +284,7 @@ describe CC::CCHelper do
|
|||
end
|
||||
|
||||
it "prepends the domain to links outside the course" do
|
||||
allow(HostUrl).to receive(:protocol).and_return("http")
|
||||
allow(HostUrl).to receive(:context_host).and_return("www.example.com:8080")
|
||||
allow(HostUrl).to receive_messages(protocol: "http", context_host: "www.example.com:8080")
|
||||
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, for_course_copy: false)
|
||||
@othercourse = Course.create!
|
||||
html = <<~HTML
|
||||
|
@ -299,8 +298,7 @@ describe CC::CCHelper do
|
|||
end
|
||||
|
||||
it "copies pages correctly when the title starts with a number" do
|
||||
allow(HostUrl).to receive(:protocol).and_return("http")
|
||||
allow(HostUrl).to receive(:context_host).and_return("www.example.com:8080")
|
||||
allow(HostUrl).to receive_messages(protocol: "http", context_host: "www.example.com:8080")
|
||||
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, for_course_copy: false)
|
||||
page = @course.wiki_pages.create(title: "9000, the level is over")
|
||||
html = <<~HTML
|
||||
|
@ -312,8 +310,7 @@ describe CC::CCHelper do
|
|||
end
|
||||
|
||||
it "copies pages correctly when the title consists only of a number" do
|
||||
allow(HostUrl).to receive(:protocol).and_return("http")
|
||||
allow(HostUrl).to receive(:context_host).and_return("www.example.com:8080")
|
||||
allow(HostUrl).to receive_messages(protocol: "http", context_host: "www.example.com:8080")
|
||||
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, for_course_copy: false)
|
||||
page = @course.wiki_pages.create(title: "9000")
|
||||
html = <<~HTML
|
||||
|
@ -326,8 +323,7 @@ describe CC::CCHelper do
|
|||
|
||||
it "copies pages correctly when the url is an old slug" do
|
||||
Account.site_admin.enable_feature! :permanent_page_links
|
||||
allow(HostUrl).to receive(:protocol).and_return("http")
|
||||
allow(HostUrl).to receive(:context_host).and_return("www.example.com:8080")
|
||||
allow(HostUrl).to receive_messages(protocol: "http", context_host: "www.example.com:8080")
|
||||
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, for_course_copy: false)
|
||||
page = @course.wiki_pages.create(title: "9000, the level is over")
|
||||
page.wiki_page_lookups.create!(slug: "old-url")
|
||||
|
@ -340,8 +336,7 @@ describe CC::CCHelper do
|
|||
end
|
||||
|
||||
it "uses the key_generator to translate links" do
|
||||
allow(HostUrl).to receive(:protocol).and_return("http")
|
||||
allow(HostUrl).to receive(:context_host).and_return("www.example.com:8080")
|
||||
allow(HostUrl).to receive_messages(protocol: "http", context_host: "www.example.com:8080")
|
||||
@assignment = @course.assignments.create!(name: "Thing")
|
||||
html = <<~HTML
|
||||
<a href="/courses/#{@course.id}/assignments/#{@assignment.id}">Thing</a>
|
||||
|
|
|
@ -449,9 +449,7 @@ describe "More Standard Common Cartridge importing" do
|
|||
@copy_to.course_code = "alt name"
|
||||
|
||||
@migration = ContentMigration.new
|
||||
allow(@migration).to receive(:to_import).and_return(nil)
|
||||
allow(@migration).to receive(:context).and_return(@copy_to)
|
||||
allow(@migration).to receive(:import_object?).and_return(true)
|
||||
allow(@migration).to receive_messages(to_import: nil, context: @copy_to, import_object?: true)
|
||||
allow(@migration).to receive(:add_imported_item)
|
||||
end
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@ describe "QTI Generator" do
|
|||
def qti_generator
|
||||
quiz_with_question_group_pointing_to_question_bank
|
||||
@rn = Object.new
|
||||
allow(@rn).to receive(:user).and_return({})
|
||||
allow(@rn).to receive(:course).and_return(@course)
|
||||
allow(@rn).to receive(:export_dir).and_return({})
|
||||
allow(@rn).to receive_messages(user: {}, course: @course, export_dir: {})
|
||||
allow(@rn).to receive(:export_object?).with(anything).and_return(true)
|
||||
@qg = CC::Qti::QtiGenerator.new @rn, nil, nil
|
||||
end
|
||||
|
|
|
@ -28,9 +28,7 @@ describe CC::WebResources do
|
|||
mo = MediaObject.create!(user_id: user, context: user, media_id: "test", media_type: "video", title: "Mo")
|
||||
|
||||
allow(CanvasKaltura::ClientV3).to receive(:new).and_return(double("Kaltura", startSession: true))
|
||||
allow(self).to receive(:for_course_copy).and_return(false)
|
||||
allow(self).to receive(:export_media_objects?).and_return(true)
|
||||
allow(self).to receive(:add_error).and_return(true)
|
||||
allow(self).to receive_messages(for_course_copy: false, export_media_objects?: true, add_error: true)
|
||||
|
||||
add_media_objects(double("Html_Exporter", used_media_objects: [mo], media_object_infos: {}))
|
||||
expect(mo.attachment).to be_truthy
|
||||
|
|
|
@ -269,23 +269,20 @@ describe "Feature.register" do
|
|||
end
|
||||
|
||||
it "registers in a dev environment" do
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow(Rails.env).to receive(:development?).and_return(true)
|
||||
allow(Rails.env).to receive_messages(test?: false, development?: true)
|
||||
Feature.register({ dev_feature: t_dev_feature_hash })
|
||||
expect(Feature.definitions["dev_feature"]).not_to be_nil
|
||||
end
|
||||
|
||||
it "registers in a production test cluster" do
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow(Rails.env).to receive(:production?).and_return(true)
|
||||
allow(Rails.env).to receive_messages(test?: false, production?: true)
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
Feature.register({ dev_feature: t_dev_feature_hash })
|
||||
expect(Feature.definitions["dev_feature"]).not_to be_nil
|
||||
end
|
||||
|
||||
it "does not register in production" do
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow(Rails.env).to receive(:production?).and_return(true)
|
||||
allow(Rails.env).to receive_messages(test?: false, production?: true)
|
||||
Feature.register({ dev_feature: t_dev_feature_hash })
|
||||
expect(Feature.definitions["dev_feature"]).to eq Feature::DISABLED_FEATURE
|
||||
end
|
||||
|
@ -298,8 +295,7 @@ describe "Feature.register" do
|
|||
end
|
||||
|
||||
it "registers as 'hidden' in production" do
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
allow(Rails.env).to receive(:production?).and_return(true)
|
||||
allow(Rails.env).to receive_messages(test?: false, production?: true)
|
||||
Feature.register({ dev_feature: t_hidden_in_prod_feature_hash })
|
||||
expect(Feature.definitions["dev_feature"]).to be_hidden
|
||||
end
|
||||
|
|
|
@ -42,8 +42,7 @@ describe HealthChecks do
|
|||
|
||||
it "passes the InstFS check" do
|
||||
allow(CanvasHttp).to receive(:get).with(any_args).and_return(success_response)
|
||||
allow(InstFS).to receive(:app_host).and_return("https://www.example.com")
|
||||
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||
allow(InstFS).to receive_messages(app_host: "https://www.example.com", enabled?: true)
|
||||
|
||||
expect(described_class.process_deep_checks[:critical][:inst_fs][:status]).to be true
|
||||
end
|
||||
|
@ -61,8 +60,7 @@ describe HealthChecks do
|
|||
|
||||
it "passes the mathman check" do
|
||||
allow(CanvasHttp).to receive(:get).with(any_args).and_return(success_response)
|
||||
allow(MathMan).to receive(:url_for).and_return("www.example.com")
|
||||
allow(MathMan).to receive(:use_for_svg?).and_return(true)
|
||||
allow(MathMan).to receive_messages(url_for: "www.example.com", use_for_svg?: true)
|
||||
|
||||
expect(described_class.process_deep_checks[:critical][:mathman][:status]).to be true
|
||||
end
|
||||
|
@ -98,16 +96,13 @@ describe HealthChecks do
|
|||
|
||||
it "passes the canvadocs checks" do
|
||||
allow(CanvasHttp).to receive(:get).with(any_args).and_return(success_response)
|
||||
allow(Canvadocs).to receive(:enabled?).and_return(true)
|
||||
allow(Canvadocs).to receive(:config)
|
||||
.and_return({ "base_url" => "https://canvadocs.instructure.com/" })
|
||||
allow(Canvadocs).to receive_messages(enabled?: true, config: { "base_url" => "https://canvadocs.instructure.com/" })
|
||||
|
||||
expect(described_class.process_deep_checks[:secondary][:canvadocs][:status]).to be true
|
||||
end
|
||||
|
||||
it "passes the screencap check" do
|
||||
allow(CutyCapt).to receive(:enabled?).and_return(true)
|
||||
allow(CutyCapt).to receive(:screencap_service).and_return(Class.new do
|
||||
allow(CutyCapt).to receive_messages(enabled?: true, screencap_service: Class.new do
|
||||
def snapshot_url_to_file(...)
|
||||
true
|
||||
end
|
||||
|
@ -131,8 +126,7 @@ describe HealthChecks do
|
|||
end
|
||||
|
||||
it "passes the incoming_mail check" do
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive(:run_periodically?).and_return(true)
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive(:healthy?).and_return(true)
|
||||
allow(IncomingMailProcessor::IncomingMessageProcessor).to receive_messages(run_periodically?: true, healthy?: true)
|
||||
|
||||
expect(described_class.process_deep_checks[:secondary][:incoming_mail][:status]).to be true
|
||||
end
|
||||
|
@ -142,15 +136,12 @@ describe HealthChecks do
|
|||
allow(InstStatsd::Statsd).to receive(:gauge)
|
||||
allow(InstStatsd::Statsd).to receive(:timing)
|
||||
|
||||
allow(HealthChecks).to receive(:process_readiness_checks).and_return(
|
||||
{
|
||||
allow(HealthChecks).to receive_messages(
|
||||
process_readiness_checks: {
|
||||
readiness_check_name_error: { time: 1, status: false },
|
||||
readiness_check_name_success: { time: 2, status: true },
|
||||
}
|
||||
)
|
||||
|
||||
allow(HealthChecks).to receive(:process_deep_checks).and_return(
|
||||
{
|
||||
},
|
||||
process_deep_checks: {
|
||||
deep: {
|
||||
deep_check_name_error: { time: 3, status: false },
|
||||
deep_check_name_success: { time: 4, status: true },
|
||||
|
|
|
@ -40,30 +40,28 @@ module Lti
|
|||
let(:substitution_helper) { double.as_null_object }
|
||||
let(:right_now) { DateTime.now }
|
||||
let(:tool) do
|
||||
m = double("tool")
|
||||
allow(m).to receive(:id).and_return(1)
|
||||
allow(m).to receive(:context).and_return(root_account)
|
||||
shard_mock = double("shard")
|
||||
allow(shard_mock).to receive(:settings).and_return({ encription_key: "abc" })
|
||||
allow(m).to receive(:shard).and_return(shard_mock)
|
||||
allow(m).to receive(:opaque_identifier_for).and_return("6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f")
|
||||
m = double("tool")
|
||||
allow(m).to receive_messages(id: 1,
|
||||
context: root_account,
|
||||
shard: shard_mock,
|
||||
opaque_identifier_for: "6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f")
|
||||
m
|
||||
end
|
||||
let(:controller) do
|
||||
request_mock = double("request")
|
||||
allow(request_mock).to receive(:url).and_return("https://localhost")
|
||||
allow(request_mock).to receive(:host).and_return("/my/url")
|
||||
allow(request_mock).to receive(:scheme).and_return("https")
|
||||
allow(request_mock).to receive_messages(url: "https://localhost", host: "/my/url", scheme: "https")
|
||||
m = double("controller")
|
||||
allow(m).to receive(:css_url_for).with(:common).and_return("/path/to/common.scss")
|
||||
allow(m).to receive(:request).and_return(request_mock)
|
||||
allow(m).to receive(:logged_in_user).and_return(user)
|
||||
allow(m).to receive(:named_context_url).and_return("url")
|
||||
allow(m).to receive(:polymorphic_url).and_return("url")
|
||||
view_context_mock = double("view_context")
|
||||
allow(view_context_mock).to receive(:stylesheet_path)
|
||||
.and_return(URI.parse(request_mock.url).merge(m.css_url_for(:common)).to_s)
|
||||
allow(m).to receive(:view_context).and_return(view_context_mock)
|
||||
allow(m).to receive_messages(request: request_mock,
|
||||
logged_in_user: user,
|
||||
named_context_url: "url",
|
||||
polymorphic_url: "url",
|
||||
view_context: view_context_mock)
|
||||
m
|
||||
end
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ describe Lti::ContentItemResponse do
|
|||
let_once(:assign2) { context.assignments.create!(name: "A2") }
|
||||
let(:controller) do
|
||||
controller_mock = double("controller")
|
||||
allow(controller_mock).to receive(:api_v1_course_content_exports_url).and_return("api_export_url")
|
||||
allow(controller_mock).to receive(:file_download_url).and_return("file_download_url")
|
||||
allow(controller_mock).to receive_messages(api_v1_course_content_exports_url: "api_export_url", file_download_url: "file_download_url")
|
||||
controller_mock
|
||||
end
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ describe Lti::ContentItemSelectionRequest do
|
|||
let(:domain) { "www.example-beta.com" }
|
||||
|
||||
before do
|
||||
allow(ApplicationController).to receive(:test_cluster?).and_return(true)
|
||||
allow(ApplicationController).to receive(:test_cluster_name).and_return("beta")
|
||||
allow(ApplicationController).to receive_messages(test_cluster?: true, test_cluster_name: "beta")
|
||||
Account.site_admin.enable_feature! :dynamic_lti_environment_overrides
|
||||
|
||||
tool.settings[:environments] = {
|
||||
|
|
|
@ -25,17 +25,16 @@ describe Lti::Helpers::JwtMessageHelper do
|
|||
|
||||
let(:associated_1_1_tool) do
|
||||
t = double("associated_1_1_tool")
|
||||
allow(t).to receive(:consumer_key).and_return("179248902")
|
||||
allow(t).to receive(:shared_secret).and_return("my-lti11-secret")
|
||||
allow(t).to receive_messages(consumer_key: "179248902", shared_secret: "my-lti11-secret")
|
||||
t
|
||||
end
|
||||
let(:message) do
|
||||
m = double("message")
|
||||
allow(m).to receive(:deployment_id).and_return("689302")
|
||||
allow(m).to receive(:iss).and_return("https://lmsvendor.com")
|
||||
allow(m).to receive(:aud).and_return("PM48OJSfGDTAzAo")
|
||||
allow(m).to receive(:exp).and_return(1_551_290_856)
|
||||
allow(m).to receive(:nonce).and_return("172we8671fd8z")
|
||||
allow(m).to receive_messages(deployment_id: "689302",
|
||||
iss: "https://lmsvendor.com",
|
||||
aud: "PM48OJSfGDTAzAo",
|
||||
exp: 1_551_290_856,
|
||||
nonce: "172we8671fd8z")
|
||||
m
|
||||
end
|
||||
|
||||
|
|
|
@ -555,16 +555,13 @@ describe Lti::Messages::JwtMessage do
|
|||
end
|
||||
let(:controller) do
|
||||
controller = double("controller")
|
||||
allow(controller).to receive(:polymorphic_url).and_return("polymorphic_url")
|
||||
allow(controller).to receive(:request).and_return(request)
|
||||
allow(controller).to receive_messages(polymorphic_url: "polymorphic_url", request:)
|
||||
controller
|
||||
end
|
||||
# All this setup just so we can stub out controller.polymorphic_url
|
||||
let(:request) do
|
||||
request = double("request")
|
||||
allow(request).to receive(:url).and_return("https://localhost")
|
||||
allow(request).to receive(:host).and_return("/my/url")
|
||||
allow(request).to receive(:scheme).and_return("https")
|
||||
allow(request).to receive_messages(url: "https://localhost", host: "/my/url", scheme: "https")
|
||||
request
|
||||
end
|
||||
# override b/c all the rest of the tests fail if a Controller is injected into the 'top-level' expander def
|
||||
|
|
|
@ -28,17 +28,14 @@ RSpec.shared_context "lti_advantage_shared_examples" do
|
|||
let(:deep_linking_return_url) { "http://www.test.cop/success" }
|
||||
let(:controller) do
|
||||
controller = double("controller")
|
||||
allow(controller).to receive(:request).and_return(request)
|
||||
allow(controller).to receive(:polymorphic_url).and_return(deep_linking_return_url)
|
||||
allow(controller).to receive_messages(request:, polymorphic_url: deep_linking_return_url)
|
||||
allow(controller).to receive(:params)
|
||||
controller
|
||||
end
|
||||
# All this setup just so we can stub out controller.*_url methods
|
||||
let(:request) do
|
||||
request = double("request")
|
||||
allow(request).to receive(:url).and_return("https://localhost")
|
||||
allow(request).to receive(:host).and_return("/my/url")
|
||||
allow(request).to receive(:scheme).and_return("https")
|
||||
allow(request).to receive_messages(url: "https://localhost", host: "/my/url", scheme: "https")
|
||||
request
|
||||
end
|
||||
let(:expander) do
|
||||
|
|
|
@ -30,11 +30,11 @@ module Lti
|
|||
|
||||
let(:tool_proxy) do
|
||||
tool_proxy_mock = double("tool_proxy")
|
||||
allow(tool_proxy_mock).to receive(:guid).and_return("3b7f3b02-b481-4f63-a6b0-129dee85abee")
|
||||
allow(tool_proxy_mock).to receive(:shared_secret).and_return("42")
|
||||
allow(tool_proxy_mock).to receive(:raw_data).and_return({ "enabled_capability" => ["Security.splitSecret"] })
|
||||
allow(tool_proxy_mock).to receive(:workflow_state).and_return("active")
|
||||
allow(tool_proxy_mock).to receive(:product_family).and_return(product_family)
|
||||
allow(tool_proxy_mock).to receive_messages(guid: "3b7f3b02-b481-4f63-a6b0-129dee85abee",
|
||||
shared_secret: "42",
|
||||
raw_data: { "enabled_capability" => ["Security.splitSecret"] },
|
||||
workflow_state: "active",
|
||||
product_family:)
|
||||
tool_proxy_mock
|
||||
end
|
||||
|
||||
|
|
|
@ -22,15 +22,19 @@ describe Lti::ReRegConstraint do
|
|||
describe "#matches?" do
|
||||
it "returns true if the header VND-IMS-CONFIRM-URL is present" do
|
||||
mock_request = double("mock_request")
|
||||
allow(mock_request).to receive(:headers).and_return({ "VND-IMS-CONFIRM-URL" => "http://i-am-a-place-on-the-internet.dev/" })
|
||||
allow(mock_request).to receive(:format).and_return("json")
|
||||
allow(mock_request).to receive_messages(
|
||||
headers: { "VND-IMS-CONFIRM-URL" => "http://i-am-a-place-on-the-internet.dev/" },
|
||||
format: "json"
|
||||
)
|
||||
expect(subject.matches?(mock_request)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns failse if the format is not json" do
|
||||
mock_request = double("mock_request")
|
||||
allow(mock_request).to receive(:headers).and_return({ "VND-IMS-CONFIRM-URL" => "http://i-am-a-place-on-the-internet.dev/" })
|
||||
allow(mock_request).to receive(:format).and_return("xml")
|
||||
allow(mock_request).to receive_messages(
|
||||
headers: { "VND-IMS-CONFIRM-URL" => "http://i-am-a-place-on-the-internet.dev/" },
|
||||
format: "xml"
|
||||
)
|
||||
expect(subject.matches?(mock_request)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,8 +25,7 @@ module Lti
|
|||
let(:tp_validator) { double("tp_validator") }
|
||||
let(:tool_proxy) do
|
||||
tp = double("tool_proxy")
|
||||
allow(tp).to receive(:tool_profile).and_return(tool_profile)
|
||||
allow(tp).to receive(:enabled_capabilities).and_return(enabled_capabilities)
|
||||
allow(tp).to receive_messages(tool_profile:, enabled_capabilities:)
|
||||
tp
|
||||
end
|
||||
let(:tool_profile) do
|
||||
|
|
|
@ -37,20 +37,20 @@ module Lti
|
|||
let(:substitution_helper) { double.as_null_object }
|
||||
let(:right_now) { DateTime.now }
|
||||
let(:tool) do
|
||||
m = double("tool")
|
||||
allow(m).to receive(:id).and_return(1)
|
||||
allow(m).to receive(:context).and_return(root_account)
|
||||
allow(m).to receive(:extension_setting).with(nil, :prefer_sis_email).and_return(nil)
|
||||
allow(m).to receive(:extension_setting).with(:tool_configuration, :prefer_sis_email).and_return(nil)
|
||||
allow(m).to receive(:include_email?).and_return(true)
|
||||
allow(m).to receive(:include_name?).and_return(true)
|
||||
allow(m).to receive(:public?).and_return(true)
|
||||
shard_mock = double("shard")
|
||||
allow(shard_mock).to receive(:settings).and_return({ encription_key: "abc" })
|
||||
allow(m).to receive(:shard).and_return(shard_mock)
|
||||
allow(m).to receive(:opaque_identifier_for).and_return("6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f")
|
||||
allow(m).to receive(:use_1_3?).and_return(false)
|
||||
allow(m).to receive(:launch_url).and_return("http://example.com/launch")
|
||||
m = double("tool")
|
||||
allow(m).to receive_messages(id: 1,
|
||||
context: root_account,
|
||||
include_email?: true,
|
||||
include_name?: true,
|
||||
public?: true,
|
||||
shard: shard_mock,
|
||||
opaque_identifier_for: "6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f",
|
||||
use_1_3?: false,
|
||||
launch_url: "http://example.com/launch")
|
||||
allow(m).to receive(:extension_setting).with(nil, :prefer_sis_email).and_return(nil)
|
||||
allow(m).to receive(:extension_setting).with(:tool_configuration, :prefer_sis_email).and_return(nil)
|
||||
m
|
||||
end
|
||||
let(:available_canvas_resources) do
|
||||
|
@ -62,31 +62,25 @@ module Lti
|
|||
|
||||
let(:controller) do
|
||||
request_mock = double("request")
|
||||
allow(request_mock).to receive(:url).and_return("https://localhost")
|
||||
allow(request_mock).to receive(:host_with_port).and_return("https://localhost")
|
||||
allow(request_mock).to receive(:host).and_return("/my/url")
|
||||
allow(request_mock).to receive(:scheme).and_return("https")
|
||||
allow(request_mock).to receive(:parameters).and_return(
|
||||
{
|
||||
com_instructure_course_accept_canvas_resource_types: ["page", "module"],
|
||||
com_instructure_course_canvas_resource_type: "page",
|
||||
com_instructure_course_allow_canvas_resource_selection: "true",
|
||||
com_instructure_course_available_canvas_resources: available_canvas_resources
|
||||
}.with_indifferent_access
|
||||
)
|
||||
allow(request_mock).to receive_messages(url: "https://localhost", host_with_port: "https://localhost", host: "/my/url", scheme: "https", parameters: {
|
||||
com_instructure_course_accept_canvas_resource_types: ["page", "module"],
|
||||
com_instructure_course_canvas_resource_type: "page",
|
||||
com_instructure_course_allow_canvas_resource_selection: "true",
|
||||
com_instructure_course_available_canvas_resources: available_canvas_resources
|
||||
}.with_indifferent_access)
|
||||
view_context_mock = double("view_context")
|
||||
m = double("controller")
|
||||
allow(m).to receive(:css_url_for).with(:common).and_return("/path/to/common.scss")
|
||||
allow(m).to receive(:request).and_return(request_mock)
|
||||
allow(m).to receive(:logged_in_user).and_return(user)
|
||||
allow(m).to receive(:named_context_url).and_return("url")
|
||||
allow(m).to receive(:active_brand_config_url).with("json").and_return("http://example.com/brand_config.json")
|
||||
allow(m).to receive(:active_brand_config_url).with("js").and_return("http://example.com/brand_config.js")
|
||||
allow(m).to receive(:active_brand_config).and_return(double(to_json: '{"ic-brand-primary-darkened-5":"#0087D7"}'))
|
||||
allow(m).to receive(:polymorphic_url).and_return("url")
|
||||
view_context_mock = double("view_context")
|
||||
allow(view_context_mock).to receive(:stylesheet_path)
|
||||
.and_return(URI.parse(request_mock.url).merge(m.css_url_for(:common)).to_s)
|
||||
allow(m).to receive(:view_context).and_return(view_context_mock)
|
||||
allow(m).to receive_messages(request: request_mock,
|
||||
logged_in_user: user,
|
||||
named_context_url: "url",
|
||||
active_brand_config: double(to_json: '{"ic-brand-primary-darkened-5":"#0087D7"}'),
|
||||
polymorphic_url: "url",
|
||||
view_context: view_context_mock)
|
||||
allow(m).to receive(:active_brand_config_url).with("json").and_return("http://example.com/brand_config.json")
|
||||
allow(m).to receive(:active_brand_config_url).with("js").and_return("http://example.com/brand_config.js")
|
||||
m
|
||||
end
|
||||
let(:attachment) { attachment_model }
|
||||
|
|
|
@ -26,8 +26,7 @@ module Services
|
|||
@config = {
|
||||
"queue_url" => "http://queue.url"
|
||||
}
|
||||
allow(FeatureAnalyticsService).to receive(:client).and_return(@client)
|
||||
allow(FeatureAnalyticsService).to receive(:config).and_return(@config)
|
||||
allow(FeatureAnalyticsService).to receive_messages(client: @client, config: @config)
|
||||
end
|
||||
|
||||
it "sends messages to the queue_url specified in the config" do
|
||||
|
|
|
@ -67,8 +67,7 @@ module Services
|
|||
|
||||
let(:root_account_context) do
|
||||
root_account = double
|
||||
allow(root_account).to receive(:global_root_account_id).and_return(nil)
|
||||
allow(root_account).to receive(:global_id).and_return(10_000_000_000_004)
|
||||
allow(root_account).to receive_messages(global_root_account_id: nil, global_id: 10_000_000_000_004)
|
||||
root_account
|
||||
end
|
||||
|
||||
|
@ -86,9 +85,7 @@ module Services
|
|||
|
||||
let(:tool_proxy) do
|
||||
tool_proxy = double
|
||||
allow(tool_proxy).to receive(:id).and_return("1")
|
||||
allow(tool_proxy).to receive(:guid).and_return("151b52cd-d670-49fb-bf65-6a327e3aaca0")
|
||||
allow(tool_proxy).to receive(:product_family).and_return(product_family)
|
||||
allow(tool_proxy).to receive_messages(id: "1", guid: "151b52cd-d670-49fb-bf65-6a327e3aaca0", product_family:)
|
||||
tool_proxy
|
||||
end
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ module Services
|
|||
|
||||
before do
|
||||
@queue = double("notification queue")
|
||||
allow(NotificationService).to receive(:notification_sqs).and_return(@queue)
|
||||
allow(NotificationService).to receive(:choose_queue_url).and_return("default")
|
||||
allow(NotificationService).to receive_messages(notification_sqs: @queue, choose_queue_url: "default")
|
||||
end
|
||||
|
||||
it "processes email message type" do
|
||||
|
|
|
@ -81,8 +81,7 @@ module Services
|
|||
end
|
||||
|
||||
before do
|
||||
allow(worker).to receive(:homework_service).and_return(service)
|
||||
allow(worker).to receive(:attachment).and_return(attachment)
|
||||
allow(worker).to receive_messages(homework_service: service, attachment:)
|
||||
end
|
||||
|
||||
it "clones and submit the url when submit_assignment is true" do
|
||||
|
@ -95,8 +94,7 @@ module Services
|
|||
|
||||
it "clones and not submit the url when submit_assignment is false" do
|
||||
worker = described_class.submit_job(attachment, progress, eula_agreement_timestamp, comment, executor, false)
|
||||
allow(worker).to receive(:homework_service).and_return(service)
|
||||
allow(worker).to receive(:attachment).and_return(attachment)
|
||||
allow(worker).to receive_messages(homework_service: service, attachment:)
|
||||
expect(attachment).to receive(:clone_url).with(url, dup_handling, check_quota, opts)
|
||||
expect(service).not_to receive(:submit)
|
||||
worker.perform
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
describe SIS::CSV::CSVBaseImporter do
|
||||
it "reads file from index" do
|
||||
sis = double
|
||||
allow(sis).to receive(:batch).and_return nil
|
||||
allow(sis).to receive(:root_account).and_return nil
|
||||
allow(sis).to receive_messages(batch: nil, root_account: nil)
|
||||
# we also add row numbers on a 1 based index including header row.
|
||||
path = generate_csv_file(["h,h,h", # 1
|
||||
"0,0,0", # 2
|
||||
|
|
|
@ -46,9 +46,7 @@ module Turnitin
|
|||
context "when the TII response is an error" do
|
||||
let(:response_mock) do
|
||||
r_mock = double("response")
|
||||
allow(r_mock).to receive(:headers).and_return({})
|
||||
allow(r_mock).to receive(:body).and_return("abcdef")
|
||||
allow(r_mock).to receive(:status).and_return(401)
|
||||
allow(r_mock).to receive_messages(headers: {}, body: "abcdef", status: 401)
|
||||
r_mock
|
||||
end
|
||||
|
||||
|
|
|
@ -35,10 +35,7 @@ module Turnitin
|
|||
|
||||
before do
|
||||
original_submission_response = double("original_submission_mock")
|
||||
allow(original_submission_response).to receive(:headers).and_return(
|
||||
{ "content-disposition" => "attachment; filename=#{filename}", "content-type" => "plain/text" }
|
||||
)
|
||||
allow(original_submission_response).to receive(:body).and_return("1234")
|
||||
allow(original_submission_response).to receive_messages(headers: { "content-disposition" => "attachment; filename=#{filename}", "content-type" => "plain/text" }, body: "1234")
|
||||
expect_any_instance_of(TurnitinApi::OutcomesResponseTransformer).to receive(:original_submission).and_yield(original_submission_response)
|
||||
|
||||
response_response = double("response_mock")
|
||||
|
@ -101,8 +98,7 @@ module Turnitin
|
|||
time = Time.now.utc
|
||||
attempt_number = subject.class.max_attempts - 1
|
||||
original_submission_response = double("original_submission_mock")
|
||||
allow(original_submission_response).to receive(:headers).and_return({})
|
||||
allow(original_submission_response).to receive(:status).and_return(403)
|
||||
allow(original_submission_response).to receive_messages(headers: {}, status: 403)
|
||||
expect_any_instance_of(TurnitinApi::OutcomesResponseTransformer).to receive(:original_submission).and_yield(original_submission_response)
|
||||
allow_any_instance_of(subject.class).to receive(:attempt_number).and_return(attempt_number)
|
||||
mock = double
|
||||
|
@ -169,8 +165,7 @@ module Turnitin
|
|||
|
||||
before do
|
||||
original_submission_response = double("original_submission_mock")
|
||||
allow(original_submission_response).to receive(:headers).and_return({})
|
||||
allow(original_submission_response).to receive(:status).and_return(403)
|
||||
allow(original_submission_response).to receive_messages(headers: {}, status: 403)
|
||||
allow(subject.turnitin_client).to receive(:original_submission).and_yield(original_submission_response)
|
||||
end
|
||||
|
||||
|
|
|
@ -59,8 +59,7 @@ module Turnitin
|
|||
let(:originality_report_url) { "http://example.com/report" }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:originality_data).and_return(originality_data)
|
||||
allow(subject).to receive(:originality_report_url).and_return(originality_report_url)
|
||||
allow(subject).to receive_messages(originality_data:, originality_report_url:)
|
||||
end
|
||||
|
||||
it "sets the similarity_score" do
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue