RuboCop: RSpec/ReceiveNever

[skip-stages=Flakey]

auto-corrected

Change-Id: Ida701604e0c4eba27772af489ed0b690a47ddfd6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277765
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2021-11-09 16:53:04 -07:00
parent 2d84666968
commit b5ae57558c
117 changed files with 304 additions and 302 deletions

View File

@ -106,6 +106,8 @@ RSpec/MultipleMemoizedHelpers:
Enabled: false # complicated setup is sometimes necessary Enabled: false # complicated setup is sometimes necessary
RSpec/NestedGroups: RSpec/NestedGroups:
Enabled: false # legacy code Enabled: false # legacy code
RSpec/ReceiveNever:
Severity: error
RSpec/RepeatedDescription: RSpec/RepeatedDescription:
Severity: error Severity: error
RSpec/SubjectStub: RSpec/SubjectStub:

View File

@ -50,8 +50,8 @@ describe ActiveSupport::Callbacks::Suspension do
describe "suspend_callbacks" do describe "suspend_callbacks" do
it "suspends all callbacks by default" do it "suspends all callbacks by default" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).never expect(@instance).not_to receive(:publish)
@instance.suspend_callbacks { @instance.save } @instance.suspend_callbacks { @instance.save }
end end
@ -61,7 +61,7 @@ describe ActiveSupport::Callbacks::Suspension do
end end
it "only suspends given callbacks" do it "only suspends given callbacks" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).once expect(@instance).to receive(:publish).once
@instance.suspend_callbacks(:validate) { @instance.save } @instance.suspend_callbacks(:validate) { @instance.save }
end end
@ -72,7 +72,7 @@ describe ActiveSupport::Callbacks::Suspension do
end end
it "only suspends callbacks of the given type" do it "only suspends callbacks of the given type" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).once expect(@instance).to receive(:publish).once
@instance.suspend_callbacks(type: :before) { @instance.save } @instance.suspend_callbacks(type: :before) { @instance.save }
end end
@ -80,8 +80,8 @@ describe ActiveSupport::Callbacks::Suspension do
describe "nesting" do describe "nesting" do
it "combines suspensions from various levels" do it "combines suspensions from various levels" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).never expect(@instance).not_to receive(:publish)
@instance.suspend_callbacks(:validate) do @instance.suspend_callbacks(:validate) do
@instance.suspend_callbacks(:publish) do @instance.suspend_callbacks(:publish) do
@instance.save @instance.save
@ -90,7 +90,7 @@ describe ActiveSupport::Callbacks::Suspension do
end end
it "restores correct subset of suspensions after leaving block" do it "restores correct subset of suspensions after leaving block" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).once expect(@instance).to receive(:publish).once
@instance.suspend_callbacks(:validate) do @instance.suspend_callbacks(:validate) do
@instance.suspend_callbacks(:publish) do @instance.suspend_callbacks(:publish) do
@ -103,24 +103,24 @@ describe ActiveSupport::Callbacks::Suspension do
describe "inheritance" do describe "inheritance" do
it "applies suspensions from the class to instances" do it "applies suspensions from the class to instances" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).never expect(@instance).not_to receive(:publish)
@class.suspend_callbacks { @instance.save } @class.suspend_callbacks { @instance.save }
end end
it "applies suspensions from a superclass to instances of a subclass" do it "applies suspensions from a superclass to instances of a subclass" do
subclass = Class.new(@class) subclass = Class.new(@class)
instance = subclass.new instance = subclass.new
expect(instance).to receive(:validate).never expect(instance).not_to receive(:validate)
expect(instance).to receive(:publish).never expect(instance).not_to receive(:publish)
@class.suspend_callbacks { instance.save } @class.suspend_callbacks { instance.save }
end end
it "combines suspensions from various levels" do it "combines suspensions from various levels" do
subclass = Class.new(@class) subclass = Class.new(@class)
instance = subclass.new instance = subclass.new
expect(instance).to receive(:validate).never expect(instance).not_to receive(:validate)
expect(instance).to receive(:publish).never expect(instance).not_to receive(:publish)
# only suspends :validate from save # only suspends :validate from save
instance.suspend_callbacks(:validate, kind: :save) do instance.suspend_callbacks(:validate, kind: :save) do
# only suspends :publish # only suspends :publish
@ -136,7 +136,7 @@ describe ActiveSupport::Callbacks::Suspension do
end end
it "keeps class suspensions independent per thread" do it "keeps class suspensions independent per thread" do
expect(@instance).to receive(:validate).never expect(@instance).not_to receive(:validate)
expect(@instance).to receive(:publish).once expect(@instance).to receive(:publish).once
@class.suspend_callbacks(:validate) do @class.suspend_callbacks(:validate) do

View File

@ -305,7 +305,7 @@ describe "BookmarkedCollection" do
['deleted', @deleted_collection] ['deleted', @deleted_collection]
) )
expect(@deleted_collection).to receive(:execute_pager).never expect(@deleted_collection).not_to receive(:execute_pager)
expect(@collection.paginate(per_page: 1).next_page).not_to be_nil expect(@collection.paginate(per_page: 1).next_page).not_to be_nil
end end
end end

View File

@ -115,7 +115,7 @@ describe BookmarkedCollection::SimpleBookmarker do
@non_collated_bookmarker = BookmarkedCollection::SimpleBookmarker.new(@example_class, @non_collated_bookmarker = BookmarkedCollection::SimpleBookmarker.new(@example_class,
{ :name => { :skip_collation => true } }, :id) { :name => { :skip_collation => true } }, :id)
pager = double(current_bookmark: nil) pager = double(current_bookmark: nil)
expect(BookmarkedCollection).to receive(:best_unicode_collation_key).never expect(BookmarkedCollection).not_to receive(:best_unicode_collation_key)
expect(@non_collated_bookmarker.restrict_scope(@example_class, pager)).to eq( expect(@non_collated_bookmarker.restrict_scope(@example_class, pager)).to eq(
[@bill, @bob2, @bob, @bobby, @joe] [@bill, @bob2, @bob, @bobby, @joe]
) )

View File

@ -184,7 +184,7 @@ describe CanvasPartman::PartitionManager do
it "detects when enough partitions already exist" do it "detects when enough partitions already exist" do
expect(subject).to receive(:partition_tables).and_return(['partman_trails_0', 'partman_trails_1']) expect(subject).to receive(:partition_tables).and_return(['partman_trails_0', 'partman_trails_1'])
expect(Zoo).to receive(:maximum).and_return(nil) expect(Zoo).to receive(:maximum).and_return(nil)
expect(subject).to receive(:create_partition).never expect(subject).not_to receive(:create_partition)
subject.ensure_partitions(2) subject.ensure_partitions(2)
end end

View File

@ -322,7 +322,7 @@ describe EventStream::IndexStrategy::Cassandra do
it "handles exclusionary newest/oldest parameters" do it "handles exclusionary newest/oldest parameters" do
@pager = @index.for_key('key', oldest: @oldest, newest: @oldest - 1.day) @pager = @index.for_key('key', oldest: @oldest, newest: @oldest - 1.day)
expect(@database).to receive(:execute).never expect(@database).not_to receive(:execute)
@pager.paginate(:per_page => 1) @pager.paginate(:per_page => 1)
end end
end end

View File

@ -283,8 +283,8 @@ describe EventStream::Stream do
spy = double('spy') spy = double('spy')
@stream.on_insert { spy.trigger } @stream.on_insert { spy.trigger }
expect(database).to receive(:batch).once expect(database).to receive(:batch).once
expect(database).to receive(:insert_record).never expect(database).not_to receive(:insert_record)
expect(spy).to receive(:trigger).never expect(spy).not_to receive(:trigger)
@stream.insert(@record) @stream.insert(@record)
end end
end end
@ -355,8 +355,8 @@ describe EventStream::Stream do
spy = double('spy') spy = double('spy')
@stream.on_update { spy.trigger } @stream.on_update { spy.trigger }
expect(database).to receive(:batch).once expect(database).to receive(:batch).once
expect(database).to receive(:update_record).never expect(database).not_to receive(:update_record)
expect(spy).to receive(:trigger).never expect(spy).not_to receive(:trigger)
@stream.update(@record) @stream.update(@record)
end end
end end
@ -404,7 +404,7 @@ describe EventStream::Stream do
end end
it "skips the fetch if no ids were given" do it "skips the fetch if no ids were given" do
expect(database).to receive(:execute).never expect(database).not_to receive(:execute)
@stream.fetch([]) @stream.fetch([])
end end
@ -461,7 +461,7 @@ describe EventStream::Stream do
it "skips insert if entry_proc and_return nil" do it "skips insert if entry_proc and_return nil" do
@index.entry_proc lambda { |_record| nil } @index.entry_proc lambda { |_record| nil }
expect(@index_strategy).to receive(:insert).never expect(@index_strategy).not_to receive(:insert)
@stream.insert(@record) @stream.insert(@record)
end end
@ -544,12 +544,12 @@ describe EventStream::Stream do
end end
it "does not insert a record when insert callback fails" do it "does not insert a record when insert callback fails" do
expect(@database).to receive(:execute).never expect(@database).not_to receive(:execute)
@stream.insert(@record) @stream.insert(@record)
end end
it "does not update a record when update callback fails" do it "does not update a record when update callback fails" do
expect(@database).to receive(:execute).never expect(@database).not_to receive(:execute)
@stream.update(@record) @stream.update(@record)
end end

View File

@ -117,7 +117,7 @@ describe IncomingMailProcessor::DirectoryMailbox do
folder = default_config[:folder] folder = default_config[:folder]
expect(@mailbox).to receive(:move_file).with(folder, "foo", "aside") expect(@mailbox).to receive(:move_file).with(folder, "foo", "aside")
expect(@mailbox).to receive(:folder_exists?).with(folder, "aside").and_return(true) expect(@mailbox).to receive(:folder_exists?).with(folder, "aside").and_return(true)
expect(@mailbox).to receive(:create_folder).never expect(@mailbox).not_to receive(:create_folder)
@mailbox.each_message do |id, _body| @mailbox.each_message do |id, _body|
@mailbox.move_message(id, "aside") @mailbox.move_message(id, "aside")
end end

View File

@ -85,7 +85,7 @@ describe "report helper" do
it 'does one query for pseudonyms' do it 'does one query for pseudonyms' do
report.preload_logins_for_users([@user]) report.preload_logins_for_users([@user])
expect(SisPseudonym).to receive(:for).never expect(SisPseudonym).not_to receive(:for)
report.loaded_pseudonym({ @user.id => [@pseudonym] }, @user, enrollment: @enrollmnent) report.loaded_pseudonym({ @user.id => [@pseudonym] }, @user, enrollment: @enrollmnent)
end end
@ -100,7 +100,7 @@ describe "report helper" do
it 'uses deleted pseudonyms when passed' do it 'uses deleted pseudonyms when passed' do
@pseudonym.destroy @pseudonym.destroy
report.preload_logins_for_users([@user]) report.preload_logins_for_users([@user])
expect(SisPseudonym).to receive(:for).never expect(SisPseudonym).not_to receive(:for)
pseudonym = report.loaded_pseudonym({ @user.id => [@pseudonym] }, @user, include_deleted: true, enrollment: @enrollmnent) pseudonym = report.loaded_pseudonym({ @user.id => [@pseudonym] }, @user, include_deleted: true, enrollment: @enrollmnent)
expect(pseudonym).to eq @pseudonym expect(pseudonym).to eq @pseudonym
end end

View File

@ -86,7 +86,7 @@ describe 'simply_versioned' do
woozel.with_versioning(&:save!) woozel.with_versioning(&:save!)
expect(woozel.versions.loaded?).to eq false expect(woozel.versions.loaded?).to eq false
first = woozel.versions.first first = woozel.versions.first
expect(Woozel.connection).to receive(:select_all).never expect(Woozel.connection).not_to receive(:select_all)
expect(first.versionable).to eq woozel expect(first.versionable).to eq woozel
end end
@ -95,7 +95,7 @@ describe 'simply_versioned' do
woozel.with_versioning(&:save!) woozel.with_versioning(&:save!)
expect(woozel.versions.loaded?).to eq false expect(woozel.versions.loaded?).to eq false
all = woozel.versions.to_a all = woozel.versions.to_a
expect(Woozel.connection).to receive(:select_all).never expect(Woozel.connection).not_to receive(:select_all)
all.each do |version| all.each do |version|
expect(version.versionable).to eq woozel expect(version.versionable).to eq woozel
end end

View File

@ -52,7 +52,7 @@ describe Twitter::Messenger do
let(:messenger) { Twitter::Messenger.new(message, nil, 'host', id) } let(:messenger) { Twitter::Messenger.new(message, nil, 'host', id) }
it 'sends nothing if there is no service' do it 'sends nothing if there is no service' do
expect(connection_mock).to receive(:send_direct_message).never expect(connection_mock).not_to receive(:send_direct_message)
expect(messenger.deliver).to be_nil expect(messenger.deliver).to be_nil
end end
end end

View File

@ -98,8 +98,8 @@ describe "Admins API", type: :request do
end end
it "does not send a notification email if passed a 0 'send_confirmation' value" do it "does not send a notification email if passed a 0 'send_confirmation' value" do
expect_any_instance_of(AccountUser).to receive(:account_user_notification!).never expect_any_instance_of(AccountUser).not_to receive(:account_user_notification!)
expect_any_instance_of(AccountUser).to receive(:account_user_registration!).never expect_any_instance_of(AccountUser).not_to receive(:account_user_registration!)
api_call(:post, "/api/v1/accounts/#{@admin.account.id}/admins", api_call(:post, "/api/v1/accounts/#{@admin.account.id}/admins",
{ :controller => 'admins', :action => 'create', :format => 'json', { :controller => 'admins', :action => 'create', :format => 'json',
@ -110,8 +110,8 @@ describe "Admins API", type: :request do
end end
it "does not send a notification email if passed a false 'send_confirmation' value" do it "does not send a notification email if passed a false 'send_confirmation' value" do
expect_any_instance_of(AccountUser).to receive(:account_user_notification!).never expect_any_instance_of(AccountUser).not_to receive(:account_user_notification!)
expect_any_instance_of(AccountUser).to receive(:account_user_registration!).never expect_any_instance_of(AccountUser).not_to receive(:account_user_registration!)
api_call(:post, "/api/v1/accounts/#{@admin.account.id}/admins", api_call(:post, "/api/v1/accounts/#{@admin.account.id}/admins",
{ :controller => 'admins', :action => 'create', :format => 'json', { :controller => 'admins', :action => 'create', :format => 'json',

View File

@ -781,7 +781,7 @@ describe AssignmentOverridesController, type: :request do
expect(new_prog).to be_completed # since they can't see the assignment yet expect(new_prog).to be_completed # since they can't see the assignment yet
other_prog = mod.evaluate_for(@other_student) other_prog = mod.evaluate_for(@other_student)
expect_any_instantiation_of(other_prog).to receive(:evaluate!).never expect_any_instantiation_of(other_prog).not_to receive(:evaluate!)
api_update_override(@course, @assignment, @override, :assignment_override => { :student_ids => [@new_student.id] }) api_update_override(@course, @assignment, @override, :assignment_override => { :student_ids => [@new_student.id] })

View File

@ -3989,7 +3989,7 @@ describe AssignmentsApiController, type: :request do
due_date_cacher = instance_double(DueDateCacher) due_date_cacher = instance_double(DueDateCacher)
allow(DueDateCacher).to receive(:new).and_return(due_date_cacher) allow(DueDateCacher).to receive(:new).and_return(due_date_cacher)
expect(due_date_cacher).to receive(:recompute).never expect(due_date_cacher).not_to receive(:recompute)
update_assignment update_assignment
end end
@ -6253,7 +6253,7 @@ describe AssignmentsApiController, type: :request do
end end
it "preloads student_ids when including adhoc overrides" do it "preloads student_ids when including adhoc overrides" do
expect_any_instantiation_of(@override).to receive(:assignment_override_students).never expect_any_instantiation_of(@override).not_to receive(:assignment_override_students)
json = api_call_as_user(@teacher, :get, json = api_call_as_user(@teacher, :get,
"/api/v1/courses/#{@course.id}/assignments?include[]=overrides", "/api/v1/courses/#{@course.id}/assignments?include[]=overrides",
{ :controller => 'assignments_api', { :controller => 'assignments_api',
@ -6266,7 +6266,7 @@ describe AssignmentsApiController, type: :request do
it "preloads student_ids when including adhoc overrides on assignment groups api as well" do it "preloads student_ids when including adhoc overrides on assignment groups api as well" do
# yeah i know this is a separate api; sue me # yeah i know this is a separate api; sue me
expect_any_instantiation_of(@override).to receive(:assignment_override_students).never expect_any_instantiation_of(@override).not_to receive(:assignment_override_students)
json = api_call_as_user(@teacher, :get, json = api_call_as_user(@teacher, :get,
"/api/v1/courses/#{@course.id}/assignment_groups?include[]=assignments&include[]=overrides", "/api/v1/courses/#{@course.id}/assignment_groups?include[]=assignments&include[]=overrides",
{ :controller => 'assignment_groups', { :controller => 'assignment_groups',

View File

@ -1393,7 +1393,7 @@ describe "Module Items API", type: :request do
describe "caching CYOE data" do describe "caching CYOE data" do
it "uses the cache when requested again" do it "uses the cache when requested again" do
expect(ConditionalRelease::Service).to receive(:request_rules).never expect(ConditionalRelease::Service).not_to receive(:request_rules)
3.times do 3.times do
api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@cyoe_module3.id}/items?include[]=mastery_paths", api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@cyoe_module3.id}/items?include[]=mastery_paths",
:controller => "context_module_items_api", :action => "index", :format => "json", :controller => "context_module_items_api", :action => "index", :format => "json",

View File

@ -1117,7 +1117,7 @@ describe CoursesController, type: :request do
it "allows setting sis_course_id without offering the course" do it "allows setting sis_course_id without offering the course" do
expect(Auditors::Course).to receive(:record_created).once expect(Auditors::Course).to receive(:record_created).once
expect(Auditors::Course).to receive(:record_published).never expect(Auditors::Course).not_to receive(:record_published)
json = api_call(:post, @resource_path, json = api_call(:post, @resource_path,
@resource_params, @resource_params,
{ :account_id => @account.id, :course => { :name => 'Test Course', :sis_course_id => '9999' } }) { :account_id => @account.id, :course => { :name => 'Test Course', :sis_course_id => '9999' } })

View File

@ -160,7 +160,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
other_course = course_factory other_course = course_factory
@template.add_child_course!(other_course) @template.add_child_course!(other_course)
expect_any_instantiation_of(@template).to receive(:add_child_course!).never expect_any_instantiation_of(@template).not_to receive(:add_child_course!)
api_call(:put, @url, @params, { :course_ids_to_add => [other_course.id] }) api_call(:put, @url, @params, { :course_ids_to_add => [other_course.id] })
end end

View File

@ -168,13 +168,13 @@ describe 'Submissions Comment API', type: :request do
it 'does not send to other teachers for teacher annotation' do it 'does not send to other teachers for teacher annotation' do
second_teacher second_teacher
expect(BroadcastPolicy.notifier).to receive(:send_notification).with(*teacher_args).never expect(BroadcastPolicy.notifier).not_to receive(:send_notification).with(*teacher_args)
annotation_notification_call(author_id: @teacher.to_param) annotation_notification_call(author_id: @teacher.to_param)
expect(response.status).to eq 200 expect(response.status).to eq 200
end end
it 'does not send to students when assignment is post_manually' do it 'does not send to students when assignment is post_manually' do
expect(BroadcastPolicy.notifier).to receive(:send_notification).with(*student_args).never expect(BroadcastPolicy.notifier).not_to receive(:send_notification).with(*student_args)
annotation_notification_call(author_id: @teacher.to_param, assignment_id: manual_post_assignment.to_param) annotation_notification_call(author_id: @teacher.to_param, assignment_id: manual_post_assignment.to_param)
expect(response.status).to eq 200 expect(response.status).to eq 200
end end
@ -187,8 +187,8 @@ describe 'Submissions Comment API', type: :request do
end end
it 'does not send to students when submission is not posted and author is teacher' do it 'does not send to students when submission is not posted and author is teacher' do
expect(BroadcastPolicy.notifier).to receive(:send_notification).with(*student_args).never expect(BroadcastPolicy.notifier).not_to receive(:send_notification).with(*student_args)
expect(BroadcastPolicy.notifier).to receive(:send_notification).with(*teacher_args).never expect(BroadcastPolicy.notifier).not_to receive(:send_notification).with(*teacher_args)
annotation_notification_call(author_id: @teacher.to_param, assignment_id: group_assignment_with_submission.to_param) annotation_notification_call(author_id: @teacher.to_param, assignment_id: group_assignment_with_submission.to_param)
expect(response.status).to eq 200 expect(response.status).to eq 200
end end

View File

@ -1588,7 +1588,7 @@ describe ApplicationController do
user_factory user_factory
controller.instance_variable_set(:@context, @user) controller.instance_variable_set(:@context, @user)
expect(Course).to receive(:where).never expect(Course).not_to receive(:where)
controller.send(:get_all_pertinent_contexts, only_contexts: 'Group_1') controller.send(:get_all_pertinent_contexts, only_contexts: 'Group_1')
end end
@ -1596,7 +1596,7 @@ describe ApplicationController do
user_factory user_factory
controller.instance_variable_set(:@context, @user) controller.instance_variable_set(:@context, @user)
expect(@user).to receive(:current_groups).never expect(@user).not_to receive(:current_groups)
controller.send(:get_all_pertinent_contexts, include_groups: true, only_contexts: 'Course_1') controller.send(:get_all_pertinent_contexts, include_groups: true, only_contexts: 'Course_1')
end end

View File

@ -290,7 +290,7 @@ describe AssignmentGroupsController do
it 'does not check visibilities on individual assignemnts' do it 'does not check visibilities on individual assignemnts' do
# ensures that check is not an N+1 from the gradebook # ensures that check is not an N+1 from the gradebook
expect_any_instance_of(Assignment).to receive(:students_with_visibility).never expect_any_instance_of(Assignment).not_to receive(:students_with_visibility)
get 'index', params: { :course_id => @course.id, :include => ['assignments', 'assignment_visibility'] }, :format => :json get 'index', params: { :course_id => @course.id, :include => ['assignments', 'assignment_visibility'] }, :format => :json
expect(response).to be_successful expect(response).to be_successful
end end

View File

@ -215,7 +215,7 @@ describe CanvadocSessionsController do
it "doesn't upload documents that are already uploaded" do it "doesn't upload documents that are already uploaded" do
@attachment1.submit_to_canvadocs @attachment1.submit_to_canvadocs
expect_any_instance_of(Attachment).to receive(:submit_to_canvadocs).never expect_any_instance_of(Attachment).not_to receive(:submit_to_canvadocs)
get :show, params: { blob: @blob.to_json, hmac: Canvas::Security.hmac_sha1(@blob.to_json) } get :show, params: { blob: @blob.to_json, hmac: Canvas::Security.hmac_sha1(@blob.to_json) }
expect(response).to redirect_to("https://example.com/sessions/SESSION/view?theme=dark") expect(response).to redirect_to("https://example.com/sessions/SESSION/view?theme=dark")
end end

View File

@ -1303,7 +1303,7 @@ describe CommunicationChannelsController do
user_with_pseudonym(:active_all => true) # new user user_with_pseudonym(:active_all => true) # new user
@enrollment = @course.enroll_user(@user) @enrollment = @course.enroll_user(@user)
expect_any_instantiation_of(@cc).to receive(:send_confirmation!).never expect_any_instantiation_of(@cc).not_to receive(:send_confirmation!)
get 're_send_confirmation', params: { :user_id => @pseudonym.user_id, :id => @cc.id, :enrollment_id => @enrollment.id } get 're_send_confirmation', params: { :user_id => @pseudonym.user_id, :id => @cc.id, :enrollment_id => @enrollment.id }
expect(response).to be_successful expect(response).to be_successful
end end

View File

@ -807,7 +807,7 @@ describe ContextModulesController do
override.assignment_override_students.create!(:user => student) override.assignment_override_students.create!(:user => student)
end end
expect(AssignmentOverrideApplicator).to receive(:overrides_for_assignment_and_user).never expect(AssignmentOverrideApplicator).not_to receive(:overrides_for_assignment_and_user)
get 'content_tag_assignment_data', params: { course_id: @course.id }, format: 'json' # precache get 'content_tag_assignment_data', params: { course_id: @course.id }, format: 'json' # precache
json = json_parse(response.body) json = json_parse(response.body)

View File

@ -2254,14 +2254,14 @@ describe CoursesController do
it "does not publish when offer is false" do it "does not publish when offer is false" do
@course.claim! @course.claim!
expect(Auditors::Course).to receive(:record_published).never expect(Auditors::Course).not_to receive(:record_published)
user_session(@teacher) user_session(@teacher)
put 'update', params: { :id => @course.id, :offer => "false" } put 'update', params: { :id => @course.id, :offer => "false" }
expect(@course.reload).to be_claimed expect(@course.reload).to be_claimed
end end
it "does not log published event if course was already published" do it "does not log published event if course was already published" do
expect(Auditors::Course).to receive(:record_published).never expect(Auditors::Course).not_to receive(:record_published)
user_session(@teacher) user_session(@teacher)
put 'update', params: { :id => @course.id, :offer => true } put 'update', params: { :id => @course.id, :offer => true }
end end
@ -2428,7 +2428,7 @@ describe CoursesController do
it "doesn't allow a teacher to undelete a course" do it "doesn't allow a teacher to undelete a course" do
@course.destroy @course.destroy
expect(Auditors::Course).to receive(:record_restored).never expect(Auditors::Course).not_to receive(:record_restored)
user_session(@teacher) user_session(@teacher)
put 'update', params: { :id => @course.id, :course => { :event => 'undelete' }, :format => :json } put 'update', params: { :id => @course.id, :course => { :event => 'undelete' }, :format => :json }
expect(response.status).to eq 401 expect(response.status).to eq 401
@ -2942,7 +2942,7 @@ describe CoursesController do
end end
it 'does not try and publish grades' do it 'does not try and publish grades' do
expect_any_instance_of(Course).to receive(:publish_final_grades).never expect_any_instance_of(Course).not_to receive(:publish_final_grades)
user_session(@teacher) user_session(@teacher)
get 'sis_publish_status', params: { :course_id => @course.id } get 'sis_publish_status', params: { :course_id => @course.id }
expect(response).to be_successful expect(response).to be_successful

View File

@ -1148,7 +1148,7 @@ describe GradebooksController do
shared_examples_for "working download" do shared_examples_for "working download" do
it "does not recompute enrollment grades" do it "does not recompute enrollment grades" do
expect(Enrollment).to receive(:recompute_final_score).never expect(Enrollment).not_to receive(:recompute_final_score)
get 'show', params: { :course_id => @course.id, :init => 1, :assignments => 1 }, :format => 'csv' get 'show', params: { :course_id => @course.id, :init => 1, :assignments => 1 }, :format => 'csv'
end end

View File

@ -215,7 +215,7 @@ describe Login::CanvasController do
.with('username', 'password') .with('username', 'password')
.and_return([{ 'uid' => ['12345'] }]) .and_return([{ 'uid' => ['12345'] }])
Account.default.authentication_providers.create!(:auth_type => 'ldap', :identifier_format => 'uid') Account.default.authentication_providers.create!(:auth_type => 'ldap', :identifier_format => 'uid')
expect_any_instantiation_of(aac).to receive(:ldap_bind_result).never expect_any_instantiation_of(aac).not_to receive(:ldap_bind_result)
post 'create', params: { :pseudonym_session => { :unique_id => 'username', :password => 'password' } } post 'create', params: { :pseudonym_session => { :unique_id => 'username', :password => 'password' } }
expect(response).to be_redirect expect(response).to be_redirect
expect(response).to redirect_to(dashboard_url(:login_success => 1)) expect(response).to redirect_to(dashboard_url(:login_success => 1))
@ -262,7 +262,7 @@ describe Login::CanvasController do
it "doesn't query the server at all if the enabled features don't require it, and there is no matching login" do it "doesn't query the server at all if the enabled features don't require it, and there is no matching login" do
ap = Account.default.authentication_providers.create!(auth_type: 'ldap') ap = Account.default.authentication_providers.create!(auth_type: 'ldap')
expect_any_instantiation_of(ap).to receive(:ldap_bind_result).never expect_any_instantiation_of(ap).not_to receive(:ldap_bind_result)
post 'create', params: { :pseudonym_session => { :unique_id => 'username', :password => 'password' } } post 'create', params: { :pseudonym_session => { :unique_id => 'username', :password => 'password' } }
assert_status(400) assert_status(400)
expect(response).to render_template(:new) expect(response).to render_template(:new)

View File

@ -182,7 +182,7 @@ describe Login::CasController do
it "redirects when a user is authorized but not found in canvas" do it "redirects when a user is authorized but not found in canvas" do
# We dont want to log them out of everything. # We dont want to log them out of everything.
expect(controller).to receive(:logout_user_action).never expect(controller).not_to receive(:logout_user_action)
# Default to Login url with a nil value # Default to Login url with a nil value
session[:sentinel] = true session[:sentinel] = true

View File

@ -53,7 +53,7 @@ describe Login::OAuth2Controller do
state = CGI.parse(URI.parse(response.location).query)['state'].first state = CGI.parse(URI.parse(response.location).query)['state'].first
expect(state).to_not be_nil expect(state).to_not be_nil
expect_any_instantiation_of(aac).to receive(:get_token).never expect_any_instantiation_of(aac).not_to receive(:get_token)
Timecop.travel(15.minutes) do Timecop.travel(15.minutes) do
get :create, params: { state: state } get :create, params: { state: state }
expect(response).to redirect_to(login_url) expect(response).to redirect_to(login_url)

View File

@ -161,7 +161,7 @@ describe Login::OtpController do
before do before do
@user.otp_secret_key = ROTP::Base32.random @user.otp_secret_key = ROTP::Base32.random
@user.save! @user.save!
expect_any_instance_of(CommunicationChannel).to receive(:send_otp!).never expect_any_instance_of(CommunicationChannel).not_to receive(:send_otp!)
user_session(@user, @pseudonym) user_session(@user, @pseudonym)
session[:pending_otp] = true session[:pending_otp] = true
end end
@ -223,7 +223,7 @@ describe Login::OtpController do
skip "needs redis" unless Canvas.redis_enabled? skip "needs redis" unless Canvas.redis_enabled?
Canvas.redis.set("otp_used:#{@user.global_id}:123456", '1') Canvas.redis.set("otp_used:#{@user.global_id}:123456", '1')
expect_any_instance_of(ROTP::TOTP).to receive(:verify).never expect_any_instance_of(ROTP::TOTP).not_to receive(:verify)
post :create, params: { :otp_login => { :verification_code => '123456' } } post :create, params: { :otp_login => { :verification_code => '123456' } }
expect(response).to redirect_to(otp_login_url) expect(response).to redirect_to(otp_login_url)
end end

View File

@ -159,7 +159,7 @@ describe Login::SamlController do
allow_any_instance_of(SAML2::Entity).to receive(:valid_response?) allow_any_instance_of(SAML2::Entity).to receive(:valid_response?)
# We dont want to log them out of everything. # We dont want to log them out of everything.
expect(controller).to receive(:logout_user_action).never expect(controller).not_to receive(:logout_user_action)
controller.request.env['canvas.domain_root_account'] = account controller.request.env['canvas.domain_root_account'] = account
# Default to Login url if set to nil or blank # Default to Login url if set to nil or blank
@ -207,7 +207,7 @@ describe Login::SamlController do
allow_any_instance_of(SAML2::Entity).to receive(:valid_response?) allow_any_instance_of(SAML2::Entity).to receive(:valid_response?)
# We dont want to log them out of everything. # We dont want to log them out of everything.
expect(controller).to receive(:logout_user_action).never expect(controller).not_to receive(:logout_user_action)
controller.request.env['canvas.domain_root_account'] = account controller.request.env['canvas.domain_root_account'] = account
expect(account.pseudonyms.active.by_unique_id(unique_id)).to_not be_exists expect(account.pseudonyms.active.by_unique_id(unique_id)).to_not be_exists
@ -503,13 +503,13 @@ describe Login::SamlController do
describe '#destroy' do describe '#destroy' do
it "returns bad request if a SAMLResponse or SAMLRequest parameter is not provided" do it "returns bad request if a SAMLResponse or SAMLRequest parameter is not provided" do
expect(controller).to receive(:logout_user_action).never expect(controller).not_to receive(:logout_user_action)
get :destroy get :destroy
expect(response.status).to eq 400 expect(response.status).to eq 400
end end
it "finds the correct AAC" do it "finds the correct AAC" do
expect_any_instantiation_of(@aac1).to receive(:debugging?).never expect_any_instantiation_of(@aac1).not_to receive(:debugging?)
expect_any_instantiation_of(@aac2).to receive(:debugging?).at_least(1) expect_any_instantiation_of(@aac2).to receive(:debugging?).at_least(1)
logout_response = SAML2::LogoutResponse.new logout_response = SAML2::LogoutResponse.new
@ -569,7 +569,7 @@ describe Login::SamlController do
logout_response.issuer = SAML2::NameID.new('entity') logout_response.issuer = SAML2::NameID.new('entity')
expect(SAML2::Bindings::HTTPRedirect).to receive(:decode).and_return(logout_response) expect(SAML2::Bindings::HTTPRedirect).to receive(:decode).and_return(logout_response)
expect(controller).to receive(:logout_user_action).never expect(controller).not_to receive(:logout_user_action)
controller.request.env['canvas.domain_root_account'] = @account controller.request.env['canvas.domain_root_account'] = @account
get :destroy, params: { :SAMLResponse => "foo", :RelayState => "/courses" } get :destroy, params: { :SAMLResponse => "foo", :RelayState => "/courses" }
expect(response.status).to eq 400 expect(response.status).to eq 400

View File

@ -2043,7 +2043,7 @@ describe Quizzes::QuizzesController do
due_date_cacher = instance_double(DueDateCacher) due_date_cacher = instance_double(DueDateCacher)
allow(DueDateCacher).to receive(:new).and_return(due_date_cacher) allow(DueDateCacher).to receive(:new).and_return(due_date_cacher)
expect(due_date_cacher).to receive(:recompute).never expect(due_date_cacher).not_to receive(:recompute)
post 'update', params: @no_changes post 'update', params: @no_changes
end end

View File

@ -89,7 +89,7 @@ describe SupportHelpers::TurnitinController do
end end
it "returns 400 status without id" do it "returns 400 status without id" do
expect(SupportHelpers::Tii::AssignmentFixer).to receive(:new).never expect(SupportHelpers::Tii::AssignmentFixer).not_to receive(:new)
get :assignment get :assignment
expect(response.body).to eq('Missing assignment `id` parameter') expect(response.body).to eq('Missing assignment `id` parameter')
assert_status(400) assert_status(400)

View File

@ -70,7 +70,7 @@ describe AttachmentHelper do
describe "set_cache_header" do describe "set_cache_header" do
it "does not allow caching of instfs redirects" do it "does not allow caching of instfs redirects" do
allow(@att).to receive(:instfs_hosted?).and_return(true) allow(@att).to receive(:instfs_hosted?).and_return(true)
expect(self).to receive(:cancel_cache_buster).never expect(self).not_to receive(:cancel_cache_buster)
set_cache_header(@att, false) set_cache_header(@att, false)
expect(response.headers).not_to have_key('Cache-Control') expect(response.headers).not_to have_key('Cache-Control')
end end

View File

@ -70,7 +70,7 @@ describe CollaborationsHelper do
allow(collab).to receive(:is_a?).with(ExternalToolCollaboration).and_return(true) allow(collab).to receive(:is_a?).with(ExternalToolCollaboration).and_return(true)
allow(collab).to receive(:update_url).and_return(nil) allow(collab).to receive(:update_url).and_return(nil)
allow(collab).to receive(:grants_any_right?).and_return(true) allow(collab).to receive(:grants_any_right?).and_return(true)
expect(helper).to receive(:render).never expect(helper).not_to receive(:render)
helper.edit_button(collab, user) helper.edit_button(collab, user)
end end
end end
@ -92,7 +92,7 @@ describe CollaborationsHelper do
it "doesn't return collaboration links if the user doesn't have permission" do it "doesn't return collaboration links if the user doesn't have permission" do
allow(collab).to receive(:grants_any_right?).and_return(false) allow(collab).to receive(:grants_any_right?).and_return(false)
expect(helper).to receive(:render).with('collaborations/collaboration_links', collaboration: collab, user: user).never expect(helper).not_to receive(:render).with('collaborations/collaboration_links', collaboration: collab, user: user)
helper.collaboration_links(collab, user) helper.collaboration_links(collab, user)
end end
end end

View File

@ -157,7 +157,7 @@ describe ContextModulesHelper do
it "does not set mastery_paths if cyoe is disabled" do it "does not set mastery_paths if cyoe is disabled" do
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(false) allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(false)
expect(ConditionalRelease::Service).to receive(:rules_for).never expect(ConditionalRelease::Service).not_to receive(:rules_for)
module_data = process_module_data(t_module, true, @student, @session) module_data = process_module_data(t_module, true, @student, @session)
item_data = module_data[:items_data][item.id] item_data = module_data[:items_data][item.id]
expect(item_data[:mastery_paths]).to be nil expect(item_data[:mastery_paths]).to be nil

View File

@ -220,7 +220,7 @@ describe "External Tools" do
course_with_teacher_logged_in(:account => @account, :active_all => true) course_with_teacher_logged_in(:account => @account, :active_all => true)
get "/courses" # populate the cache once get "/courses" # populate the cache once
expect(ContextExternalTool).to receive(:filtered_global_navigation_tools).never expect(ContextExternalTool).not_to receive(:filtered_global_navigation_tools)
get "/courses" get "/courses"
doc = Nokogiri::HTML5(response.body) doc = Nokogiri::HTML5(response.body)
expect(doc.at_css("##{@admin_tool.asset_string}_menu_item a")).to be_present expect(doc.at_css("##{@admin_tool.asset_string}_menu_item a")).to be_present
@ -262,7 +262,7 @@ describe "External Tools" do
expect(doc.at_css("##{@permissiony_tool.asset_string}_menu_item a")).to be_present expect(doc.at_css("##{@permissiony_tool.asset_string}_menu_item a")).to be_present
c2 = course_with_teacher(:account => @account, :active_all => true, :user => @teacher).course c2 = course_with_teacher(:account => @account, :active_all => true, :user => @teacher).course
expect(ContextExternalTool).to receive(:filtered_global_navigation_tools).never expect(ContextExternalTool).not_to receive(:filtered_global_navigation_tools)
get "/courses/#{c2.id}" # viewing different course but permissions are the same - should remain cached get "/courses/#{c2.id}" # viewing different course but permissions are the same - should remain cached
doc = Nokogiri::HTML5(response.body) doc = Nokogiri::HTML5(response.body)
expect(doc.at_css("##{@permissiony_tool.asset_string}_menu_item a")).to be_present expect(doc.at_css("##{@permissiony_tool.asset_string}_menu_item a")).to be_present

View File

@ -44,15 +44,15 @@ describe ActiveSupport::Cache::SafeRedisRaceCondition do
it "doesn't lock for an existing key" do it "doesn't lock for an existing key" do
store.write("bob", 42) store.write("bob", 42)
expect(store).to receive(:lock).never expect(store).not_to receive(:lock)
expect(store).to receive(:unlock).never expect(store).not_to receive(:unlock)
expect(store.fetch('bob') { raise "not reached" }).to eq 42 expect(store.fetch('bob') { raise "not reached" }).to eq 42
end end
it "doesn't populate for a stale key that someone else is populating" do it "doesn't populate for a stale key that someone else is populating" do
store.write("bob", 42, expires_in: -1) store.write("bob", 42, expires_in: -1)
expect(store).to receive(:lock).and_return(false) expect(store).to receive(:lock).and_return(false)
expect(store).to receive(:unlock).never expect(store).not_to receive(:unlock)
expect(store.fetch('bob') { raise "not reached" }).to eq 42 expect(store.fetch('bob') { raise "not reached" }).to eq 42
end end
@ -72,7 +72,7 @@ describe ActiveSupport::Cache::SafeRedisRaceCondition do
expect(store).to receive(:read_entry).and_return(nil).ordered expect(store).to receive(:read_entry).and_return(nil).ordered
expect(store).to receive(:lock).and_return(false).ordered expect(store).to receive(:lock).and_return(false).ordered
expect(store).to receive(:read_entry).and_call_original.ordered expect(store).to receive(:read_entry).and_call_original.ordered
expect(store).to receive(:unlock).never expect(store).not_to receive(:unlock)
expect(store.fetch('bob') { raise "not reached" }).to eq 42 expect(store.fetch('bob') { raise "not reached" }).to eq 42
end end
@ -99,7 +99,7 @@ describe ActiveSupport::Cache::SafeRedisRaceCondition do
expect(store).to receive(:read_entry).and_return(nil) expect(store).to receive(:read_entry).and_return(nil)
expect(store).to receive(:lock).and_return(true) expect(store).to receive(:lock).and_return(true)
expect(store).to receive(:write_entry) expect(store).to receive(:write_entry)
expect(store).to receive(:unlock).never expect(store).not_to receive(:unlock)
expect(store.fetch('bob') { 42 }).to eq 42 expect(store.fetch('bob') { 42 }).to eq 42
end end
end end

View File

@ -452,7 +452,7 @@ describe AddressBook::MessageableUser do
expect(Rails.cache).to receive(:fetch) expect(Rails.cache).to receive(:fetch)
.with(match(/address_book_preload/)) .with(match(/address_book_preload/))
.and_return(MessageableUser.where(id: student).to_a) .and_return(MessageableUser.where(id: student).to_a)
expect(teacher).to receive(:load_messageable_users).never expect(teacher).not_to receive(:load_messageable_users)
AddressBook::MessageableUser.new(teacher).preload_users([student]) AddressBook::MessageableUser.new(teacher).preload_users([student])
end end

View File

@ -102,7 +102,7 @@ describe Api::V1::QuizSubmissionQuestion do
describe "shuffle_answers false" do describe "shuffle_answers false" do
subject { api.quiz_submission_questions_json(quiz_questions, @quiz_submission, { shuffle_answers: false }) } subject { api.quiz_submission_questions_json(quiz_questions, @quiz_submission, { shuffle_answers: false }) }
it "shuffles answers when opt is given" do it "shuffles answers when opt is given" do
expect_any_instance_of(Array).to receive(:shuffle!).never expect_any_instance_of(Array).not_to receive(:shuffle!)
answer_text = subject[:quiz_submission_questions].first["answers"].map { |a| a["text"] } answer_text = subject[:quiz_submission_questions].first["answers"].map { |a| a["text"] }
expect(answer_text).to eq(["a", "b", "c", "d"]) expect(answer_text).to eq(["a", "b", "c", "d"])
end end

View File

@ -431,7 +431,7 @@ describe Api do
expect(Api).to receive(:sis_find_sis_mapping_for_collection).with(collection).and_return({ :lookups => { "id" => "test-lookup" } }) expect(Api).to receive(:sis_find_sis_mapping_for_collection).with(collection).and_return({ :lookups => { "id" => "test-lookup" } })
expect(Api).to receive(:sis_parse_ids).with("test-ids", { "id" => "test-lookup" }, anything, root_account: "test-root-account") expect(Api).to receive(:sis_parse_ids).with("test-ids", { "id" => "test-lookup" }, anything, root_account: "test-root-account")
.and_return({ "test-lookup" => ["thing1", "thing2"] }) .and_return({ "test-lookup" => ["thing1", "thing2"] })
expect(Api).to receive(:relation_for_sis_mapping_and_columns).never expect(Api).not_to receive(:relation_for_sis_mapping_and_columns)
expect(Api.map_ids("test-ids", collection, "test-root-account")).to eq ["thing1", "thing2"] expect(Api.map_ids("test-ids", collection, "test-root-account")).to eq ["thing1", "thing2"]
end end

View File

@ -49,7 +49,7 @@ describe AssetSignature do
end end
it 'returns nil if the signature does not check out' do it 'returns nil if the signature does not check out' do
expect(SomeModel).to receive(:where).never expect(SomeModel).not_to receive(:where)
expect(AssetSignature.find_by_signature(SomeModel, '24-not-the-sig')).to be_nil expect(AssetSignature.find_by_signature(SomeModel, '24-not-the-sig')).to be_nil
end end
end end

View File

@ -95,7 +95,7 @@ describe AssignmentOverrideApplicator do
it "does not attempt to apply overrides if an overridden assignment is overridden for the same user" do it "does not attempt to apply overrides if an overridden assignment is overridden for the same user" do
@overridden_assignment = AssignmentOverrideApplicator.assignment_overridden_for(@assignment, @student) @overridden_assignment = AssignmentOverrideApplicator.assignment_overridden_for(@assignment, @student)
expect(@overridden_assignment.overridden_for_user.id).to eq @student.id expect(@overridden_assignment.overridden_for_user.id).to eq @student.id
expect(AssignmentOverrideApplicator).to receive(:overrides_for_assignment_and_user).never expect(AssignmentOverrideApplicator).not_to receive(:overrides_for_assignment_and_user)
@reoverridden_assignment = AssignmentOverrideApplicator.assignment_overridden_for(@overridden_assignment, @student) @reoverridden_assignment = AssignmentOverrideApplicator.assignment_overridden_for(@overridden_assignment, @student)
end end
@ -185,7 +185,7 @@ describe AssignmentOverrideApplicator do
it "caches by assignment and user" do it "caches by assignment and user" do
enable_cache do enable_cache do
AssignmentOverrideApplicator.overrides_for_assignment_and_user(@assignment, @student) AssignmentOverrideApplicator.overrides_for_assignment_and_user(@assignment, @student)
expect(Rails.cache).to receive(:write_entry).never expect(Rails.cache).not_to receive(:write_entry)
AssignmentOverrideApplicator.overrides_for_assignment_and_user(@assignment, @student) AssignmentOverrideApplicator.overrides_for_assignment_and_user(@assignment, @student)
end end
end end
@ -869,7 +869,7 @@ describe AssignmentOverrideApplicator do
@override = assignment_override_model(:assignment => @assignment) @override = assignment_override_model(:assignment => @assignment)
enable_cache do enable_cache do
AssignmentOverrideApplicator.collapsed_overrides(@assignment, [@override]) AssignmentOverrideApplicator.collapsed_overrides(@assignment, [@override])
expect(Rails.cache).to receive(:write_entry).never expect(Rails.cache).not_to receive(:write_entry)
Timecop.freeze(5.seconds.from_now) do Timecop.freeze(5.seconds.from_now) do
AssignmentOverrideApplicator.collapsed_overrides(@assignment, [@override]) AssignmentOverrideApplicator.collapsed_overrides(@assignment, [@override])
end end

View File

@ -147,7 +147,7 @@ describe Canvas::Builders::EnrollmentDateBuilder do
expect(loaded_enrollment_term).to be_truthy expect(loaded_enrollment_term).to be_truthy
# should already be cached on the object # should already be cached on the object
expect(Rails.cache).to receive(:fetch).never expect(Rails.cache).not_to receive(:fetch)
@enrollment.enrollment_dates @enrollment.enrollment_dates
end end
@ -169,7 +169,7 @@ describe Canvas::Builders::EnrollmentDateBuilder do
expect(loaded_enrollment_term).to be_falsey expect(loaded_enrollment_term).to be_falsey
# should already be cached on the object # should already be cached on the object
expect(Rails.cache).to receive(:fetch).never expect(Rails.cache).not_to receive(:fetch)
@enrollment.enrollment_dates @enrollment.enrollment_dates
end end
end end

View File

@ -111,7 +111,7 @@ describe Canvas::CacheRegister do
it "does not do anything if reverted" do it "does not do anything if reverted" do
set_revert! set_revert!
expect(Canvas::CacheRegister).to receive(:redis).never expect(Canvas::CacheRegister).not_to receive(:redis)
@user.clear_cache_key(:enrollments) @user.clear_cache_key(:enrollments)
end end
@ -317,7 +317,7 @@ describe Canvas::CacheRegister do
it "falls back to a regular fetch (appending the keys) if not using a redis cache store" do it "falls back to a regular fetch (appending the keys) if not using a redis cache store" do
enable_cache(:memory_store) do enable_cache(:memory_store) do
expect(Rails.cache).to receive(:fetch_with_cache_register).never expect(Rails.cache).not_to receive(:fetch_with_cache_register)
check_cache check_cache
end end
end end

View File

@ -88,7 +88,7 @@ describe Canvas::Migration::ExternalContent::Translator do
assmt.save! assmt.save!
@cm.add_imported_item(assmt) @cm.add_imported_item(assmt)
expect(@course).to receive(:assignments).never expect(@course).not_to receive(:assignments)
expect(@translator.get_canvas_id_from_migration_id(Assignment, mig_id)).to eq assmt.id expect(@translator.get_canvas_id_from_migration_id(Assignment, mig_id)).to eq assmt.id
end end
end end

View File

@ -72,7 +72,7 @@ describe 'RequestThrottle' do
it "ignores non-ID tools" do it "ignores non-ID tools" do
request_grade_passback = base_req.merge('REQUEST_METHOD' => 'POST', 'PATH_INFO' => "/api/lti/v1/tools/garbage/grade_passback") request_grade_passback = base_req.merge('REQUEST_METHOD' => 'POST', 'PATH_INFO' => "/api/lti/v1/tools/garbage/grade_passback")
expect(ContextExternalTool).to receive(:find_by).never expect(ContextExternalTool).not_to receive(:find_by)
expect(throttler.client_identifier(req(request_grade_passback))).to eq nil expect(throttler.client_identifier(req(request_grade_passback))).to eq nil
end end
@ -85,7 +85,7 @@ describe 'RequestThrottle' do
it "ignores non-POST to tools" do it "ignores non-POST to tools" do
tool = ContextExternalTool.create!(domain: 'domain', context: Account.default, consumer_key: 'key', shared_secret: 'secret', name: 'tool') tool = ContextExternalTool.create!(domain: 'domain', context: Account.default, consumer_key: 'key', shared_secret: 'secret', name: 'tool')
request_grade_passback = base_req.merge('REQUEST_METHOD' => 'GET', 'PATH_INFO' => "/api/lti/v1/tools/#{tool.id}/grade_passback") request_grade_passback = base_req.merge('REQUEST_METHOD' => 'GET', 'PATH_INFO' => "/api/lti/v1/tools/#{tool.id}/grade_passback")
expect(ContextExternalTool).to receive(:find_by).never expect(ContextExternalTool).not_to receive(:find_by)
expect(throttler.client_identifier(req(request_grade_passback))).to eq nil expect(throttler.client_identifier(req(request_grade_passback))).to eq nil
end end
end end
@ -215,7 +215,7 @@ describe 'RequestThrottle' do
it "skips without redis enabled" do it "skips without redis enabled" do
if Canvas.redis_enabled? if Canvas.redis_enabled?
allow(Canvas).to receive(:redis_enabled?).and_return(false) allow(Canvas).to receive(:redis_enabled?).and_return(false)
expect_any_instance_of(Redis::Scripting::Module).to receive(:run).never expect_any_instance_of(Redis::Scripting::Module).not_to receive(:run)
end end
expect(strip_variable_headers(throttler.call(request_user_1))).to eq response expect(strip_variable_headers(throttler.call(request_user_1))).to eq response
end end

View File

@ -245,7 +245,7 @@ describe Course do
it 'uses sql if the assignments are still a relation' do it 'uses sql if the assignments are still a relation' do
args = @test_course.active_assignments args = @test_course.active_assignments
expect_any_instance_of(Assignment).to receive(:id).never expect_any_instance_of(Assignment).not_to receive(:id)
edd = EffectiveDueDates.for_course(@test_course, args) edd = EffectiveDueDates.for_course(@test_course, args)
edd.to_hash edd.to_hash
end end
@ -1623,7 +1623,7 @@ describe Course do
expect(@test_course).to receive(:grading_periods?).and_return false expect(@test_course).to receive(:grading_periods?).and_return false
edd = EffectiveDueDates.for_course(@test_course) edd = EffectiveDueDates.for_course(@test_course)
expect(edd).to receive(:to_hash).never expect(edd).not_to receive(:to_hash)
expect(edd.any_in_closed_grading_period?).to eq(false) expect(edd.any_in_closed_grading_period?).to eq(false)
end end
@ -1700,13 +1700,13 @@ describe Course do
expect(@test_course).to receive(:grading_periods?).and_return false expect(@test_course).to receive(:grading_periods?).and_return false
edd = EffectiveDueDates.for_course(@test_course) edd = EffectiveDueDates.for_course(@test_course)
expect(edd).to receive(:to_hash).never expect(edd).not_to receive(:to_hash)
expect(edd.in_closed_grading_period?(@assignment2)).to eq(false) expect(edd.in_closed_grading_period?(@assignment2)).to eq(false)
end end
it 'returns false if assignment id is nil' do it 'returns false if assignment id is nil' do
edd = EffectiveDueDates.for_course(@test_course, @assignment1) edd = EffectiveDueDates.for_course(@test_course, @assignment1)
expect(edd).to receive(:to_hash).never expect(edd).not_to receive(:to_hash)
expect(edd.in_closed_grading_period?(nil)).to eq(false) expect(edd.in_closed_grading_period?(nil)).to eq(false)
end end

View File

@ -163,7 +163,7 @@ describe FeatureFlags do
t_sub_account.feature_flags.create! feature: 'course_feature', state: 'on' t_sub_account.feature_flags.create! feature: 'course_feature', state: 'on'
t_root_account.feature_flags.create! feature: 'course_feature', state: 'off' t_root_account.feature_flags.create! feature: 'course_feature', state: 'off'
expect(t_sub_account.lookup_feature_flag('course_feature').context).to eql t_root_account expect(t_sub_account.lookup_feature_flag('course_feature').context).to eql t_root_account
expect_any_instance_of(Account).to receive(:feature_flag).never expect_any_instance_of(Account).not_to receive(:feature_flag)
expect(t_sub_account.lookup_feature_flag('course_feature').context).to eql t_root_account expect(t_sub_account.lookup_feature_flag('course_feature').context).to eql t_root_account
end end
end end
@ -205,7 +205,7 @@ describe FeatureFlags do
it "caches the nil of the feature beneath the root account" do it "caches the nil of the feature beneath the root account" do
expect(t_course.lookup_feature_flag('root_opt_in_feature')).to be_nil expect(t_course.lookup_feature_flag('root_opt_in_feature')).to be_nil
expect_any_instance_of(Account).to receive(:feature_flag).never expect_any_instance_of(Account).not_to receive(:feature_flag)
expect(t_course.lookup_feature_flag('root_opt_in_feature')).to be_nil expect(t_course.lookup_feature_flag('root_opt_in_feature')).to be_nil
end end
end end
@ -391,7 +391,7 @@ describe FeatureFlags do
enable_cache do enable_cache do
t_root_account.feature_flag('course_feature2') t_root_account.feature_flag('course_feature2')
expect(Rails.cache).to be_exist(t_root_account.feature_flag_cache_key('course_feature2')) expect(Rails.cache).to be_exist(t_root_account.feature_flag_cache_key('course_feature2'))
expect(FeatureFlag).to receive(:where).never expect(FeatureFlag).not_to receive(:where)
t_root_account.reload.feature_flag('course_feature2') t_root_account.reload.feature_flag('course_feature2')
end end
end end

View File

@ -86,13 +86,13 @@ describe Lti::ContentItemUtil do
subject { described_class.new(content_item) } subject { described_class.new(content_item) }
it "will not call back for success if no confirmUrl is present" do it "will not call back for success if no confirmUrl is present" do
expect(CanvasHttp).to receive(:post).never expect(CanvasHttp).not_to receive(:post)
subject.success_callback subject.success_callback
run_jobs run_jobs
end end
it "will not call back for failure if no confirmUrl is present" do it "will not call back for failure if no confirmUrl is present" do
expect(CanvasHttp).to receive(:delete).never expect(CanvasHttp).not_to receive(:delete)
subject.failure_callback subject.failure_callback
run_jobs run_jobs
end end

View File

@ -45,7 +45,7 @@ describe Mutable do
it "skips update if already muted" do it "skips update if already muted" do
expect(@mutable).to receive(:muted?).and_return(true) expect(@mutable).to receive(:muted?).and_return(true)
expect(@mutable).to receive(:update_attribute).never expect(@mutable).not_to receive(:update_attribute)
@mutable.mute! @mutable.mute!
end end
end end
@ -59,7 +59,7 @@ describe Mutable do
it "skips update if not muted" do it "skips update if not muted" do
expect(@mutable).to receive(:muted?).and_return(false) expect(@mutable).to receive(:muted?).and_return(false)
expect(@mutable).to receive(:update_attribute).never expect(@mutable).not_to receive(:update_attribute)
@mutable.unmute! @mutable.unmute!
end end
end end

View File

@ -53,7 +53,7 @@ describe SentryProxy do
it "does not send to sentry for low-level errors" do it "does not send to sentry for low-level errors" do
e = error_klass.new e = error_klass.new
expect(Raven).to receive(:capture_exception).never expect(Raven).not_to receive(:capture_exception)
SentryProxy.capture(e, data, :warn) SentryProxy.capture(e, data, :warn)
end end
end end

View File

@ -72,14 +72,14 @@ module Services
@account.save! @account.save!
@au.reload @au.reload
expect(@queue).to receive(:send_message).once expect(@queue).to receive(:send_message).once
expect(Mailer).to receive(:create_message).never expect(Mailer).not_to receive(:create_message)
@message.path_type = "slack" @message.path_type = "slack"
@message.to = "test@email.com" @message.to = "test@email.com"
expect { @message.deliver }.not_to raise_error expect { @message.deliver }.not_to raise_error
end end
it 'expects slack to not enqueue without slack api token' do it 'expects slack to not enqueue without slack api token' do
expect(@queue).to receive(:send_message).never expect(@queue).not_to receive(:send_message)
end end
it "processes push notification message type" do it "processes push notification message type" do

View File

@ -609,7 +609,7 @@ describe SIS::CSV::EnrollmentImporter do
user1 = user_with_managed_pseudonym(account: @account, sis_user_id: 'U001') user1 = user_with_managed_pseudonym(account: @account, sis_user_id: 'U001')
user2 = user_with_managed_pseudonym(account: @account, sis_user_id: 'U002') user2 = user_with_managed_pseudonym(account: @account, sis_user_id: 'U002')
course1.enroll_user(user2) course1.enroll_user(user2)
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
# there are no assignments so this will just return, but we just want to see # there are no assignments so this will just return, but we just want to see
# that it gets called correctly and for the users that wre imported # that it gets called correctly and for the users that wre imported
expect(DueDateCacher).to receive(:recompute_users_for_course).with([user1.id], course1.id, nil, update_grades: true) expect(DueDateCacher).to receive(:recompute_users_for_course).with([user1.id], course1.id, nil, update_grades: true)
@ -849,7 +849,7 @@ describe SIS::CSV::EnrollmentImporter do
account: account2 account: account2
) )
user = account2.pseudonyms.where(sis_user_id: 'user_1').first.user user = account2.pseudonyms.where(sis_user_id: 'user_1').first.user
expect(SisPseudonym).to receive(:for).with(user, @account, type: :implicit, require_sis: false).never expect(SisPseudonym).not_to receive(:for).with(user, @account, type: :implicit, require_sis: false)
warnings = [] warnings = []
work = SIS::EnrollmentImporter::Work.new(@account.sis_batches.create!, @account, Rails.logger, warnings) work = SIS::EnrollmentImporter::Work.new(@account.sis_batches.create!, @account, Rails.logger, warnings)

View File

@ -1066,7 +1066,7 @@ describe SIS::CSV::UserImporter do
"user_id,login_id,full_name,email,status", "user_id,login_id,full_name,email,status",
"u,'long_string_for_user_login_should_throw_an_error_and_be_caught_and_be_returned_to_import_and_not_sent_to_sentry',U U,u@example.com,active" "u,'long_string_for_user_login_should_throw_an_error_and_be_caught_and_be_returned_to_import_and_not_sent_to_sentry',U U,u@example.com,active"
) )
expect(Canvas::Errors).to receive(:capture_exception).never expect(Canvas::Errors).not_to receive(:capture_exception)
expect(importer.errors.map { |x| x[1] }).to eq ["Could not save the user with user_id: 'u'. Unknown reason: unique_id is too long (maximum is 100 characters)"] expect(importer.errors.map { |x| x[1] }).to eq ["Could not save the user with user_id: 'u'. Unknown reason: unique_id is too long (maximum is 100 characters)"]
end end

View File

@ -125,7 +125,7 @@ module SIS
end end
it "saves with broadcasting if notify is set" do it "saves with broadcasting if notify is set" do
expect(enrollment).to receive(:save_without_broadcasting!).never expect(enrollment).not_to receive(:save_without_broadcasting!)
EnrollmentImporter.new(Account.default, { batch: Account.default.sis_batches.create! }).process(messages) do |importer| EnrollmentImporter.new(Account.default, { batch: Account.default.sis_batches.create! }).process(messages) do |importer|
sis_enrollment = SIS::Models::Enrollment.new( sis_enrollment = SIS::Models::Enrollment.new(

View File

@ -41,7 +41,7 @@ describe SSLCommon do
end end
it "works with no auth" do it "works with no auth" do
expect_any_instance_of(Net::HTTP::Post).to receive(:basic_auth).never expect_any_instance_of(Net::HTTP::Post).not_to receive(:basic_auth)
expect_any_instance_of(Net::HTTP).to receive(:start) expect_any_instance_of(Net::HTTP).to receive(:start)
SSLCommon.post_data("http://localhost/endpoint", SSLCommon.post_data("http://localhost/endpoint",
"somedata", "application/x-jt-is-so-cool") "somedata", "application/x-jt-is-so-cool")

View File

@ -267,7 +267,7 @@ describe StickySisFields do
it "doesn't write to the database when there's not a change" do it "doesn't write to the database when there's not a change" do
ac = create_abstract_course ac = create_abstract_course
expect(ac.stuck_sis_fields).to eq [].to_set expect(ac.stuck_sis_fields).to eq [].to_set
expect(ac).to receive(:write_attribute).with(:stuck_sis_fields, anything).never expect(ac).not_to receive(:write_attribute).with(:stuck_sis_fields, anything)
ac.save! ac.save!
ac.add_sis_stickiness(:name) ac.add_sis_stickiness(:name)
ac.clear_sis_stickiness(:name) ac.clear_sis_stickiness(:name)
@ -520,14 +520,14 @@ describe StickySisFields do
end end
it "doesn't fire processing_as_sis with default args" do it "doesn't fire processing_as_sis with default args" do
expect(@ac).to receive(:set_sis_stickiness).never expect(@ac).not_to receive(:set_sis_stickiness)
AbstractCourse.process_as_sis do AbstractCourse.process_as_sis do
@ac.save! @ac.save!
end end
end end
it "doesn't fire processing_as_sis with sis_stickiness" do it "doesn't fire processing_as_sis with sis_stickiness" do
expect(@ac).to receive(:set_sis_stickiness).never expect(@ac).not_to receive(:set_sis_stickiness)
AbstractCourse.process_as_sis override_sis_stickiness: true do AbstractCourse.process_as_sis override_sis_stickiness: true do
@ac.save! @ac.save!
end end

View File

@ -108,7 +108,7 @@ describe SupportHelpers::Crocodoc::CrocodocFixer do
fixer = fixer =
SupportHelpers::Crocodoc::SubmissionFixer.new('email', nil, assignment2.id, student.id) SupportHelpers::Crocodoc::SubmissionFixer.new('email', nil, assignment2.id, student.id)
expect(fixer).to receive(:resubmit_attachment).never expect(fixer).not_to receive(:resubmit_attachment)
fixer.fix fixer.fix
end end

View File

@ -272,14 +272,14 @@ describe SupportHelpers::Tii do
expect(Turnitin::Client).to receive(:new).and_return(turnitin_client) expect(Turnitin::Client).to receive(:new).and_return(turnitin_client)
fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id) fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id)
expect(turnitin_client).to receive(:createCourse).never expect(turnitin_client).not_to receive(:createCourse)
expect(turnitin_client).to receive(:createOrUpdateAssignment).and_return({ assignment_id: 1 }) expect(turnitin_client).to receive(:createOrUpdateAssignment).and_return({ assignment_id: 1 })
expect_any_instantiation_of(@s1).to receive(:resubmit_to_turnitin) expect_any_instantiation_of(@s1).to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s2).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s2).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s3).to receive(:resubmit_to_turnitin) expect_any_instantiation_of(@s3).to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s4).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s4).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s5).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s5).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s6).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s6).not_to receive(:resubmit_to_turnitin)
Timecop.scale(300) { fixer.fix(:md5_fix) } Timecop.scale(300) { fixer.fix(:md5_fix) }
end end
@ -316,13 +316,13 @@ describe SupportHelpers::Tii do
describe '#fix' do describe '#fix' do
it 'does nothing' do it 'does nothing' do
expect(Turnitin::Client).to receive(:new).never expect(Turnitin::Client).not_to receive(:new)
expect_any_instantiation_of(@s1).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s1).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s2).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s2).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s3).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s3).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s4).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s4).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s5).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s5).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s6).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s6).not_to receive(:resubmit_to_turnitin)
fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id) fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id)
Timecop.scale(300) { fixer.fix } Timecop.scale(300) { fixer.fix }
@ -335,18 +335,18 @@ describe SupportHelpers::Tii do
turnitin_client = double turnitin_client = double
expect(Turnitin::Client).to receive(:new).and_return(turnitin_client) expect(Turnitin::Client).to receive(:new).and_return(turnitin_client)
else else
expect(Turnitin::Client).to receive(:new).never expect(Turnitin::Client).not_to receive(:new)
end end
fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id) fixer = SupportHelpers::Tii::AssignmentFixer.new('email', nil, @a1.id)
expect(turnitin_client).to receive(:createCourse) if create_course expect(turnitin_client).to receive(:createCourse) if create_course
expect(turnitin_client).to receive(:createOrUpdateAssignment).and_return({ assignment_id: 1 }) if create_or_update_assignment expect(turnitin_client).to receive(:createOrUpdateAssignment).and_return({ assignment_id: 1 }) if create_or_update_assignment
expect_any_instantiation_of(@s1).to receive(:resubmit_to_turnitin) expect_any_instantiation_of(@s1).to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s2).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s2).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s3).to receive(:resubmit_to_turnitin) expect_any_instantiation_of(@s3).to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s4).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s4).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s5).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s5).not_to receive(:resubmit_to_turnitin)
expect_any_instantiation_of(@s6).to receive(:resubmit_to_turnitin).never expect_any_instantiation_of(@s6).not_to receive(:resubmit_to_turnitin)
Timecop.scale(300) { fixer.fix } Timecop.scale(300) { fixer.fix }
end end
end end

View File

@ -293,7 +293,7 @@ describe UserListV2 do
skip_if_prepended_class_method_stubs_broken skip_if_prepended_class_method_stubs_broken
Setting.set('global_lookups_shard_threshold', '3') # i.e. if we'd have to look on more than 3 shards, we should use global lookups Setting.set('global_lookups_shard_threshold', '3') # i.e. if we'd have to look on more than 3 shards, we should use global lookups
expect(Pseudonym).to receive(:associated_shards_for_column).never expect(Pseudonym).not_to receive(:associated_shards_for_column)
ul = UserListV2.new('jt@instructure.com', search_type: 'unique_id') ul = UserListV2.new('jt@instructure.com', search_type: 'unique_id')
expect(ul.resolved_results).to be_empty expect(ul.resolved_results).to be_empty
expect(ul.duplicate_results.first.map { |r| r[:user_id] }).to match_array([@user1.id, @user2.id]) expect(ul.duplicate_results.first.map { |r| r[:user_id] }).to match_array([@user1.id, @user2.id])

View File

@ -509,7 +509,7 @@ describe AccountNotification do
context "broadcast_messages" do context "broadcast_messages" do
it "performs a sanity-check before" do it "performs a sanity-check before" do
an = account_notification(:account => Account.default) an = account_notification(:account => Account.default)
expect(an).to receive(:applicable_user_ids).never expect(an).not_to receive(:applicable_user_ids)
an.broadcast_messages # send_message? not set an.broadcast_messages # send_message? not set
an.send_message = true an.send_message = true

View File

@ -31,14 +31,14 @@ module Alerts
context "basic evaluation" do context "basic evaluation" do
it "does not trigger any alerts for unpublished courses" do it "does not trigger any alerts for unpublished courses" do
course = double('Course', :available? => false) course = double('Course', :available? => false)
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(course, nil) DelayedAlertSender.evaluate_for_course(course, nil)
end end
it "does not trigger any alerts for courses with no alerts" do it "does not trigger any alerts for courses with no alerts" do
course = double('Course', :available? => true, :alerts => []) course = double('Course', :available? => true, :alerts => [])
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(course, nil) DelayedAlertSender.evaluate_for_course(course, nil)
end end
@ -47,7 +47,7 @@ module Alerts
course = Account.default.courses.create! course = Account.default.courses.create!
course.offer! course.offer!
course.alerts.create!(:recipients => [:student], :criteria => [{ :criterion_type => 'Interaction', :threshold => 7 }]) course.alerts.create!(:recipients => [:student], :criteria => [{ :criterion_type => 'Interaction', :threshold => 7 }])
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(course, nil) DelayedAlertSender.evaluate_for_course(course, nil)
end end
@ -55,7 +55,7 @@ module Alerts
it "does not trigger any alerts when there are no teachers in the class" do it "does not trigger any alerts when there are no teachers in the class" do
course_with_student(:active_course => true) course_with_student(:active_course => true)
@course.alerts.create!(:recipients => [:student], :criteria => [{ :criterion_type => 'Interaction', :threshold => 7 }]) @course.alerts.create!(:recipients => [:student], :criteria => [{ :criterion_type => 'Interaction', :threshold => 7 }])
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(@course, nil) DelayedAlertSender.evaluate_for_course(@course, nil)
end end
@ -83,7 +83,7 @@ module Alerts
@course.reload @course.reload
@course.start_at = Time.zone.now - 30.days @course.start_at = Time.zone.now - 30.days
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(@course, []) DelayedAlertSender.evaluate_for_course(@course, [])
end end
@ -98,7 +98,7 @@ module Alerts
@course.reload @course.reload
@course.start_at = Time.zone.now - 30.days @course.start_at = Time.zone.now - 30.days
expect_any_instance_of(Notification).to receive(:create_message).never expect_any_instance_of(Notification).not_to receive(:create_message)
DelayedAlertSender.evaluate_for_course(@course, []) DelayedAlertSender.evaluate_for_course(@course, [])
end end
end end

View File

@ -34,7 +34,7 @@ describe Announcement do
@course.save! @course.save!
# should not trigger an update callback by re-saving inside a before_save # should not trigger an update callback by re-saving inside a before_save
expect_any_instance_of(Announcement).to receive(:clear_streams_if_not_published).never expect_any_instance_of(Announcement).not_to receive(:clear_streams_if_not_published)
announcement = @course.announcements.create!(valid_announcement_attributes) announcement = @course.announcements.create!(valid_announcement_attributes)
expect(announcement).to be_locked expect(announcement).to be_locked

View File

@ -654,7 +654,7 @@ describe AssignmentOverride do
describe '#update_grading_period_grades with no grading periods' do describe '#update_grading_period_grades with no grading periods' do
it 'does not update grades when due_at changes' do it 'does not update grades when due_at changes' do
assignment_model assignment_model
expect_any_instance_of(Course).to receive(:recompute_student_scores).never expect_any_instance_of(Course).not_to receive(:recompute_student_scores)
override = AssignmentOverride.new override = AssignmentOverride.new
override.assignment = @assignment override.assignment = @assignment
override.due_at = 6.months.ago override.due_at = 6.months.ago
@ -688,7 +688,7 @@ describe AssignmentOverride do
it 'does not update grades if there are no students on this override' do it 'does not update grades if there are no students on this override' do
@override.assignment_override_students.clear @override.assignment_override_students.clear
expect_any_instance_of(Course).to receive(:recompute_student_scores).never expect_any_instance_of(Course).not_to receive(:recompute_student_scores)
@override.due_at = 6.months.ago @override.due_at = 6.months.ago
@override.save! @override.save!
end end
@ -710,7 +710,7 @@ describe AssignmentOverride do
it 'does not update grades if grading period did not change' do it 'does not update grades if grading period did not change' do
@override.due_at = 1.month.ago @override.due_at = 1.month.ago
@override.save! @override.save!
expect_any_instance_of(Course).to receive(:recompute_student_scores).never expect_any_instance_of(Course).not_to receive(:recompute_student_scores)
@override.due_at = 2.months.ago @override.due_at = 2.months.ago
@override.save! @override.save!
end end
@ -785,7 +785,7 @@ describe AssignmentOverride do
end end
it "does not trigger when nothing changed" do it "does not trigger when nothing changed" do
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
@override.save @override.save
end end
end end
@ -846,7 +846,7 @@ describe AssignmentOverride do
it "does nothing if it is not ADHOC" do it "does nothing if it is not ADHOC" do
allow(@override).to receive(:set_type).and_return "NOT_ADHOC" allow(@override).to receive(:set_type).and_return "NOT_ADHOC"
expect(@override).to receive(:destroy).never expect(@override).not_to receive(:destroy)
@override.destroy_if_empty_set @override.destroy_if_empty_set
end end
@ -854,7 +854,7 @@ describe AssignmentOverride do
it "does nothing if the set is not empty" do it "does nothing if the set is not empty" do
allow(@override).to receive(:set_type).and_return "ADHOC" allow(@override).to receive(:set_type).and_return "ADHOC"
allow(@override).to receive(:set).and_return [1, 2, 3] allow(@override).to receive(:set).and_return [1, 2, 3]
expect(@override).to receive(:destroy).never expect(@override).not_to receive(:destroy)
@override.destroy_if_empty_set @override.destroy_if_empty_set
end end

View File

@ -6884,7 +6884,7 @@ describe Assignment do
end end
it "does not trigger when nothing changed" do it "does not trigger when nothing changed" do
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
@assignment.save @assignment.save
end end
end end
@ -7255,7 +7255,7 @@ describe Assignment do
end end
it 'does not update grades when due_at changes' do it 'does not update grades when due_at changes' do
expect(@assignment.context).to receive(:recompute_student_scores).never expect(@assignment.context).not_to receive(:recompute_student_scores)
@assignment.due_at = 6.months.ago @assignment.due_at = 6.months.ago
@assignment.save! @assignment.save!
end end
@ -7297,7 +7297,7 @@ describe Assignment do
it 'does not update grades if grading period did not change' do it 'does not update grades if grading period did not change' do
@assignment.due_at = 1.month.ago @assignment.due_at = 1.month.ago
@assignment.save! @assignment.save!
expect(@assignment.context).to receive(:recompute_student_scores).never expect(@assignment.context).not_to receive(:recompute_student_scores)
@assignment.due_at = 2.months.ago @assignment.due_at = 2.months.ago
@assignment.save! @assignment.save!
end end
@ -7333,7 +7333,7 @@ describe Assignment do
end end
it "does not update grades otherwise" do it "does not update grades otherwise" do
expect(@assignment.context).to receive(:recompute_student_scores).never expect(@assignment.context).not_to receive(:recompute_student_scores)
@assignment.title = 'hi' @assignment.title = 'hi'
@assignment.due_at = 1.hour.ago @assignment.due_at = 1.hour.ago
@assignment.description = 'blah' @assignment.description = 'blah'
@ -8126,7 +8126,7 @@ describe Assignment do
end end
it "does not dispatch update for ungraded submissions" do it "does not dispatch update for ungraded submissions" do
expect_any_instance_of(Submission).to receive(:assignment_muted_changed).never expect_any_instance_of(Submission).not_to receive(:assignment_muted_changed)
@assignment.unmute! @assignment.unmute!
end end
end end

View File

@ -503,7 +503,7 @@ describe "differentiated_assignments" do
it "does not call AssignmentStudentVisibility.users_with_visibility_by_assignment " \ it "does not call AssignmentStudentVisibility.users_with_visibility_by_assignment " \
"if all assignments are visible to everyone" do "if all assignments are visible to everyone" do
expect(AssignmentStudentVisibility).to receive(:users_with_visibility_by_assignment).never expect(AssignmentStudentVisibility).not_to receive(:users_with_visibility_by_assignment)
# change this assignment so that it is visible to all students # change this assignment so that it is visible to all students
assignment_only_visible_to_overrides.only_visible_to_overrides = false assignment_only_visible_to_overrides.only_visible_to_overrides = false
assignment_only_visible_to_overrides.save! assignment_only_visible_to_overrides.save!

View File

@ -444,8 +444,8 @@ describe Attachment do
allow(Rails.env).to receive(:test?).and_return(false) allow(Rails.env).to receive(:test?).and_return(false)
@attachment.uploaded_data = default_uploaded_data @attachment.uploaded_data = default_uploaded_data
expect(Attachment.connection).to receive(:after_transaction_commit).twice expect(Attachment.connection).to receive(:after_transaction_commit).twice
expect(@attachment).to receive(:touch_context_if_appropriate).never expect(@attachment).not_to receive(:touch_context_if_appropriate)
expect(@attachment).to receive(:ensure_media_object).never expect(@attachment).not_to receive(:ensure_media_object)
@attachment.save @attachment.save
end end
end end
@ -486,7 +486,7 @@ describe Attachment do
it "does not create a media object in a skip_media_object_creation block" do it "does not create a media object in a skip_media_object_creation block" do
Attachment.skip_media_object_creation do Attachment.skip_media_object_creation do
expect(@attachment).to receive(:build_media_object).never expect(@attachment).not_to receive(:build_media_object)
@attachment.save! @attachment.save!
end end
end end
@ -495,7 +495,7 @@ describe Attachment do
@attachment.filename = 'foo.png' @attachment.filename = 'foo.png'
@attachment.content_type = 'image/png' @attachment.content_type = 'image/png'
expect(@attachment).to receive(:ensure_media_object).once expect(@attachment).to receive(:ensure_media_object).once
expect(@attachment).to receive(:build_media_object).never expect(@attachment).not_to receive(:build_media_object)
@attachment.save! @attachment.save!
end end
@ -588,8 +588,8 @@ describe Attachment do
a2 = attachment_model(root_attachment: a) a2 = attachment_model(root_attachment: a)
expect(a).to receive(:make_childless).once expect(a).to receive(:make_childless).once
expect(a).to receive(:destroy_content).once expect(a).to receive(:destroy_content).once
expect(a2).to receive(:make_childless).never expect(a2).not_to receive(:make_childless)
expect(a2).to receive(:destroy_content).never expect(a2).not_to receive(:destroy_content)
a2.destroy_permanently_plus a2.destroy_permanently_plus
a.destroy_permanently_plus a.destroy_permanently_plus
expect { a.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { a.reload }.to raise_error(ActiveRecord::RecordNotFound)
@ -602,7 +602,7 @@ describe Attachment do
a = attachment_model a = attachment_model
allow(a).to receive(:s3object).and_return(double('s3object')) allow(a).to receive(:s3object).and_return(double('s3object'))
s3object = a.s3object s3object = a.s3object
expect(s3object).to receive(:delete).never expect(s3object).not_to receive(:delete)
a.destroy_content a.destroy_content
end end
@ -617,7 +617,7 @@ describe Attachment do
it 'does not do destroy_content_and_replace twice' do it 'does not do destroy_content_and_replace twice' do
a = attachment_model(uploaded_data: default_uploaded_data) a = attachment_model(uploaded_data: default_uploaded_data)
a.destroy_content_and_replace # works a.destroy_content_and_replace # works
expect(a).to receive(:send_to_purgatory).never expect(a).not_to receive(:send_to_purgatory)
a.destroy_content_and_replace # returns because it already happened a.destroy_content_and_replace # returns because it already happened
end end
@ -746,7 +746,7 @@ describe Attachment do
s3_storage! s3_storage!
a = attachment_model a = attachment_model
s3object = a.s3object s3object = a.s3object
expect(s3object).to receive(:delete).never expect(s3object).not_to receive(:delete)
a.destroy_permanently! a.destroy_permanently!
end end
end end
@ -1528,7 +1528,7 @@ describe Attachment do
end end
it "fails for non-root attachments" do it "fails for non-root attachments" do
expect(@old_object).to receive(:copy_to).never expect(@old_object).not_to receive(:copy_to)
expect { @child.change_namespace(@new_account.file_namespace) }.to raise_error('change_namespace must be called on a root attachment') expect { @child.change_namespace(@new_account.file_namespace) }.to raise_error('change_namespace must be called on a root attachment')
expect(@root.reload.namespace).to eq @old_account.file_namespace expect(@root.reload.namespace).to eq @old_account.file_namespace
expect(@child.reload.namespace).to eq @root.reload.namespace expect(@child.reload.namespace).to eq @root.reload.namespace
@ -1536,7 +1536,7 @@ describe Attachment do
it "does not copy if the destination exists" do it "does not copy if the destination exists" do
expect(@new_object).to receive(:exists?).and_return(true) expect(@new_object).to receive(:exists?).and_return(true)
expect(@old_object).to receive(:copy_to).never expect(@old_object).not_to receive(:copy_to)
@root.change_namespace(@new_account.file_namespace) @root.change_namespace(@new_account.file_namespace)
expect(@root.namespace).to eq @new_account.file_namespace expect(@root.namespace).to eq @new_account.file_namespace
expect(@child.reload.namespace).to eq @root.namespace expect(@child.reload.namespace).to eq @root.namespace
@ -1693,7 +1693,7 @@ describe Attachment do
@attachment.thumbnails.create!(:thumbnail => "640x>", :uploaded_data => stub_png_data) @attachment.thumbnails.create!(:thumbnail => "640x>", :uploaded_data => stub_png_data)
} }
@attachment.thumbnail_url(:size => "640x>") @attachment.thumbnail_url(:size => "640x>")
expect(@attachment).to receive(:create_dynamic_thumbnail).never expect(@attachment).not_to receive(:create_dynamic_thumbnail)
url = @attachment.thumbnail_url(:size => "640x>") url = @attachment.thumbnail_url(:size => "640x>")
thumb = @attachment.thumbnails.where(thumbnail: "640x>").first thumb = @attachment.thumbnails.where(thumbnail: "640x>").first
expect(url).to be_present expect(url).to be_present
@ -2116,7 +2116,7 @@ describe Attachment do
end end
it "does not delete the new s3object" do it "does not delete the new s3object" do
expect(@attachment.s3object).to receive(:delete).never expect(@attachment.s3object).not_to receive(:delete)
@attachment.process_s3_details!({}) @attachment.process_s3_details!({})
end end

View File

@ -70,7 +70,7 @@ describe Auditors::Authentication do
it "doesn't record an error when not configured" do it "doesn't record an error when not configured" do
allow(Auditors::Authentication::Stream).to receive(:database).and_return(nil) allow(Auditors::Authentication::Stream).to receive(:database).and_return(nil)
expect(CanvasCassandra::DatabaseBuilder).to receive(:configured?).with("auditors").once.and_return(false) expect(CanvasCassandra::DatabaseBuilder).to receive(:configured?).with("auditors").once.and_return(false)
expect(EventStream::Logger).to receive(:error).never expect(EventStream::Logger).not_to receive(:error)
Auditors::Authentication.record(@pseudonym, 'login') Auditors::Authentication.record(@pseudonym, 'login')
end end
end end

View File

@ -70,7 +70,7 @@ describe Auditors::FeatureFlag do
it "doesn't record an error when not configured" do it "doesn't record an error when not configured" do
allow(Auditors::FeatureFlag::Stream).to receive(:database).and_return(nil) allow(Auditors::FeatureFlag::Stream).to receive(:database).and_return(nil)
expect(CanvasCassandra::DatabaseBuilder).to receive(:configured?).with("auditors").once.and_return(false) expect(CanvasCassandra::DatabaseBuilder).to receive(:configured?).with("auditors").once.and_return(false)
expect(EventStream::Logger).to receive(:error).never expect(EventStream::Logger).not_to receive(:error)
Auditors::FeatureFlag.record(@flag, @user, 'off') Auditors::FeatureFlag.record(@flag, @user, 'off')
end end
end end

View File

@ -59,7 +59,7 @@ describe AuthenticationProvider::LDAP do
aac = AuthenticationProvider::LDAP.new aac = AuthenticationProvider::LDAP.new
aac.auth_type = 'ldap' aac.auth_type = 'ldap'
aac.ldap_filter = 'bob' aac.ldap_filter = 'bob'
expect(aac).to receive(:ldap_connection).never expect(aac).not_to receive(:ldap_connection)
aac.ldap_bind_result('test', '') aac.ldap_bind_result('test', '')
end end

View File

@ -36,13 +36,13 @@ describe AuthenticationProvider::SAML::InCommon do
it "does nothing if there aren't any InCommon providers" do it "does nothing if there aren't any InCommon providers" do
saml.destroy saml.destroy
expect(subject).to receive(:refresh_if_necessary).never expect(subject).not_to receive(:refresh_if_necessary)
subject.refresh_providers subject.refresh_providers
end end
it "does nothing if no changes" do it "does nothing if no changes" do
expect(subject).to receive(:refresh_if_necessary).and_return(false) expect(subject).to receive(:refresh_if_necessary).and_return(false)
expect(subject).to receive(:validate_and_parse_metadata).never expect(subject).not_to receive(:validate_and_parse_metadata)
subject.refresh_providers subject.refresh_providers
end end
@ -51,7 +51,7 @@ describe AuthenticationProvider::SAML::InCommon do
expect(subject).to receive(:validate_and_parse_metadata).and_return({}) expect(subject).to receive(:validate_and_parse_metadata).and_return({})
expect(Canvas::Errors).to receive(:capture_exception).once expect(Canvas::Errors).to receive(:capture_exception).once
expect_any_instantiation_of(saml).to receive(:populate_from_metadata).never expect_any_instantiation_of(saml).not_to receive(:populate_from_metadata)
subject.refresh_providers subject.refresh_providers
end end
@ -69,7 +69,7 @@ describe AuthenticationProvider::SAML::InCommon do
expect(Canvas::Errors).to receive(:capture_exception).once expect(Canvas::Errors).to receive(:capture_exception).once
expect_any_instantiation_of(saml).to receive(:populate_from_metadata).with('metadata1').and_raise('error') expect_any_instantiation_of(saml).to receive(:populate_from_metadata).with('metadata1').and_raise('error')
expect_any_instantiation_of(saml2).to receive(:populate_from_metadata).with('metadata2') expect_any_instantiation_of(saml2).to receive(:populate_from_metadata).with('metadata2')
expect_any_instantiation_of(saml2).to receive(:save!).never expect_any_instantiation_of(saml2).not_to receive(:save!)
subject.refresh_providers subject.refresh_providers
end end

View File

@ -42,7 +42,7 @@ describe AuthenticationProvider::SAML::MetadataRefresher do
it "doesn't populate if nothing changed" do it "doesn't populate if nothing changed" do
expect(subject).to receive(:refresh_if_necessary).with(saml1.global_id, '1').and_return(false) expect(subject).to receive(:refresh_if_necessary).with(saml1.global_id, '1').and_return(false)
expect(saml1).to receive(:populate_from_metadata_xml).never expect(saml1).not_to receive(:populate_from_metadata_xml)
subject.refresh_providers subject.refresh_providers
end end
@ -50,7 +50,7 @@ describe AuthenticationProvider::SAML::MetadataRefresher do
it "does populate, but doesn't save, if the XML changed, but nothing changes on the model" do it "does populate, but doesn't save, if the XML changed, but nothing changes on the model" do
expect(subject).to receive(:refresh_if_necessary).with(saml1.global_id, '1').and_return('xml') expect(subject).to receive(:refresh_if_necessary).with(saml1.global_id, '1').and_return('xml')
expect_any_instantiation_of(saml1).to receive(:populate_from_metadata_xml).with('xml') expect_any_instantiation_of(saml1).to receive(:populate_from_metadata_xml).with('xml')
expect_any_instantiation_of(saml1).to receive(:save!).never expect_any_instantiation_of(saml1).not_to receive(:save!)
subject.refresh_providers subject.refresh_providers
end end
@ -67,7 +67,7 @@ describe AuthenticationProvider::SAML::MetadataRefresher do
it "ignores nil/blank metadata_uris" do it "ignores nil/blank metadata_uris" do
AuthenticationProvider::SAML.where(id: saml1.id).update_all(metadata_uri: nil) AuthenticationProvider::SAML.where(id: saml1.id).update_all(metadata_uri: nil)
Account.default.authentication_providers.create!(auth_type: 'saml', metadata_uri: '') Account.default.authentication_providers.create!(auth_type: 'saml', metadata_uri: '')
expect(subject).to receive(:refresh_if_necessary).never expect(subject).not_to receive(:refresh_if_necessary)
subject.refresh_providers subject.refresh_providers
end end
@ -89,7 +89,7 @@ describe AuthenticationProvider::SAML::MetadataRefresher do
end end
it "doesn't pass ETag if force_fetch: true" do it "doesn't pass ETag if force_fetch: true" do
expect(redis).to receive(:get).never expect(redis).not_to receive(:get)
expect(CanvasHttp).to receive(:get).with("url", {}) expect(CanvasHttp).to receive(:get).with("url", {})
subject.send(:refresh_if_necessary, 1, 'url', force_fetch: true) subject.send(:refresh_if_necessary, 1, 'url', force_fetch: true)

View File

@ -192,7 +192,7 @@ describe BigBlueButtonConference do
it "doesn't look if setting is false" do it "doesn't look if setting is false" do
@bbb.save @bbb.save
expect(@bbb).to receive(:send_request).never expect(@bbb).not_to receive(:send_request)
@bbb.recordings @bbb.recordings
end end
@ -279,7 +279,7 @@ describe BigBlueButtonConference do
it "does not make a call for conferences without keys" do it "does not make a call for conferences without keys" do
allow(@bbb).to receive(:conference_key).and_return(nil) allow(@bbb).to receive(:conference_key).and_return(nil)
expect(BigBlueButtonConference).to receive(:send_request).never expect(BigBlueButtonConference).not_to receive(:send_request)
BigBlueButtonConference.preload_recordings([@bbb]) BigBlueButtonConference.preload_recordings([@bbb])
end end

View File

@ -156,8 +156,8 @@ describe BrandConfig do
describe "with cdn disabled" do describe "with cdn disabled" do
before do before do
expect(Canvas::Cdn).to receive(:enabled?).at_least(:once).and_return(false) expect(Canvas::Cdn).to receive(:enabled?).at_least(:once).and_return(false)
expect(@subaccount_bc).to receive(:s3_uploader).never expect(@subaccount_bc).not_to receive(:s3_uploader)
expect(File).to receive(:delete).never expect(File).not_to receive(:delete)
end end
it "writes the json representation to the json file" do it "writes the json representation to the json file" do

View File

@ -187,7 +187,7 @@ describe CommunicationChannel do
it "does not update cache if workflow_state doesn't change" do it "does not update cache if workflow_state doesn't change" do
cc = communication_channel_model cc = communication_channel_model
expect(cc.user).to receive(:clear_email_cache!).never expect(cc.user).not_to receive(:clear_email_cache!)
cc.save! cc.save!
end end
@ -746,7 +746,7 @@ describe CommunicationChannel do
cc.e164_path, cc.e164_path,
true true
) )
expect(cc).to receive(:send_otp_via_sms_gateway!).never expect(cc).not_to receive(:send_otp_via_sms_gateway!)
cc.send_otp!('123456', account) cc.send_otp!('123456', account)
expect(InstStatsd::Statsd).to have_received(:increment).with( expect(InstStatsd::Statsd).to have_received(:increment).with(
"message.deliver.sms.one_time_password", "message.deliver.sms.one_time_password",
@ -766,7 +766,7 @@ describe CommunicationChannel do
end end
it "sends via email if not configured" do it "sends via email if not configured" do
expect(Services::NotificationService).to receive(:process).never expect(Services::NotificationService).not_to receive(:process)
expect(cc).to receive(:send_otp_via_sms_gateway!).once expect(cc).to receive(:send_otp_via_sms_gateway!).once
cc.send_otp!('123456') cc.send_otp!('123456')
end end

View File

@ -38,11 +38,11 @@ describe ContentParticipationCount do
it "counts current unread objects correctly" do it "counts current unread objects correctly" do
["Submission"].each do |type| ["Submission"].each do |type|
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @teacher, :content_type => type) cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @teacher, :content_type => type)
expect(cpc).to receive(:refresh_unread_count).never expect(cpc).not_to receive(:refresh_unread_count)
expect(cpc.unread_count).to eq 0 expect(cpc.unread_count).to eq 0
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => type) cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => type)
expect(cpc).to receive(:refresh_unread_count).never expect(cpc).not_to receive(:refresh_unread_count)
expect(cpc.unread_count).to eq 1 expect(cpc.unread_count).to eq 1
end end
end end
@ -51,7 +51,7 @@ describe ContentParticipationCount do
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission") cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission")
ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission", :offset => -1) ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission", :offset => -1)
cpc.reload cpc.reload
expect(cpc).to receive(:refresh_unread_count).never expect(cpc).not_to receive(:refresh_unread_count)
expect(cpc.unread_count).to eq 0 expect(cpc.unread_count).to eq 0
end end
@ -103,7 +103,7 @@ describe ContentParticipationCount do
it "does not refresh if just created" do it "does not refresh if just created" do
["Submission"].each do |type| ["Submission"].each do |type|
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @teacher, :content_type => type) cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @teacher, :content_type => type)
expect(cpc).to receive(:refresh_unread_count).never expect(cpc).not_to receive(:refresh_unread_count)
expect(cpc.unread_count).to eq 0 expect(cpc.unread_count).to eq 0
end end
end end

View File

@ -304,7 +304,7 @@ describe ContextModuleProgression do
progression.reload progression.reload
expect(progression).to be_started expect(progression).to be_started
expect_any_instantiation_of(@topic).to receive(:recalculate_context_module_actions!).never # doesn't recalculate unless it's a new requirement expect_any_instantiation_of(@topic).not_to receive(:recalculate_context_module_actions!) # doesn't recalculate unless it's a new requirement
@module.update_attribute(:completion_requirements, { @tag1.id => { :type => 'must_submit' }, @tag2.id => { :type => 'must_contribute' } }) @module.update_attribute(:completion_requirements, { @tag1.id => { :type => 'must_submit' }, @tag2.id => { :type => 'must_contribute' } })
end end

View File

@ -1517,7 +1517,7 @@ describe ContextModule do
end end
it "does not reload the tags if already loaded" do it "does not reload the tags if already loaded" do
expect(ContentTag).to receive(:visible_to_students_in_course_with_da).never expect(ContentTag).not_to receive(:visible_to_students_in_course_with_da)
ActiveRecord::Associations::Preloader.new.preload(@module, content_tags: :content) ActiveRecord::Associations::Preloader.new.preload(@module, content_tags: :content)
@module.content_tags_visible_to(@student_1) @module.content_tags_visible_to(@student_1)
end end

View File

@ -120,7 +120,7 @@ describe CourseProgress do
[@module, @module2, @module3].each do |m| [@module, @module2, @module3].each do |m|
m.evaluate_for(@user) m.evaluate_for(@user)
expect_any_instantiation_of(m).to receive(:evaluate_for).never # shouldn't re-evaluate expect_any_instantiation_of(m).not_to receive(:evaluate_for) # shouldn't re-evaluate
end end
progress = CourseProgress.new(@course, @user, read_only: true).to_json progress = CourseProgress.new(@course, @user, read_only: true).to_json

View File

@ -499,13 +499,13 @@ describe CourseSection, "moving to new course" do
end end
it "does not invalidate unless something date-related changes" do it "does not invalidate unless something date-related changes" do
expect(EnrollmentState).to receive(:update_enrollment).never expect(EnrollmentState).not_to receive(:update_enrollment)
@section.name = "durp" @section.name = "durp"
@section.save! @section.save!
end end
it "does not invalidate if dates change if it isn't restricted to dates yet" do it "does not invalidate if dates change if it isn't restricted to dates yet" do
expect(EnrollmentState).to receive(:update_enrollment).never expect(EnrollmentState).not_to receive(:update_enrollment)
@section.start_at = 1.day.from_now @section.start_at = 1.day.from_now
@section.save! @section.save!
end end

View File

@ -3560,7 +3560,7 @@ describe Course, 'grade_publishing' do
current_time = Time.now.utc current_time = Time.now.utc
allow(Time).to receive(:now).and_return(current_time) allow(Time).to receive(:now).and_return(current_time)
allow(current_time).to receive(:utc).and_return(current_time) allow(current_time).to receive(:utc).and_return(current_time)
expect(@course).to receive(:delay).never expect(@course).not_to receive(:delay)
allow(@plugin).to receive(:enabled?).and_return(true) allow(@plugin).to receive(:enabled?).and_return(true)
@plugin_settings.merge!({ @plugin_settings.merge!({
:publish_endpoint => "http://localhost/endpoint", :publish_endpoint => "http://localhost/endpoint",
@ -3576,7 +3576,7 @@ describe Course, 'grade_publishing' do
current_time = Time.now.utc current_time = Time.now.utc
allow(Time).to receive(:now).and_return(current_time) allow(Time).to receive(:now).and_return(current_time)
allow(current_time).to receive(:utc).and_return(current_time) allow(current_time).to receive(:utc).and_return(current_time)
expect(@course).to receive(:delay).never expect(@course).not_to receive(:delay)
allow(@plugin).to receive(:enabled?).and_return(true) allow(@plugin).to receive(:enabled?).and_return(true)
@plugin_settings.merge!({ @plugin_settings.merge!({
:publish_endpoint => "http://localhost/endpoint", :publish_endpoint => "http://localhost/endpoint",
@ -3592,7 +3592,7 @@ describe Course, 'grade_publishing' do
current_time = Time.now.utc current_time = Time.now.utc
allow(Time).to receive(:now).and_return(current_time) allow(Time).to receive(:now).and_return(current_time)
allow(current_time).to receive(:utc).and_return(current_time) allow(current_time).to receive(:utc).and_return(current_time)
expect(@course).to receive(:delay).never expect(@course).not_to receive(:delay)
allow(@plugin).to receive(:enabled?).and_return(true) allow(@plugin).to receive(:enabled?).and_return(true)
@plugin_settings.merge!({ @plugin_settings.merge!({
:publish_endpoint => "http://localhost/endpoint", :publish_endpoint => "http://localhost/endpoint",
@ -3968,7 +3968,7 @@ describe Course, 'grade_publishing' do
} }
} }
}) })
expect(SSLCommon).to receive(:post_data).never expect(SSLCommon).not_to receive(:post_data)
@course.send_final_grades_to_endpoint @user @course.send_final_grades_to_endpoint @user
expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["unpublishable", "published", "unpublishable", "published", "published", "unpublishable", "unpublished", "unpublishable", "published"] expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["unpublishable", "published", "unpublishable", "published", "published", "unpublishable", "unpublished", "unpublishable", "published"]
expect(@student_enrollments.map(&:grade_publishing_message)).to eq [nil] * 9 expect(@student_enrollments.map(&:grade_publishing_message)).to eq [nil] * 9
@ -4327,7 +4327,7 @@ describe Course, 'grade_publishing' do
if expect_success if expect_success
expect(SSLCommon).to receive(:post_data).with("http://localhost/endpoint", "test-jt-data", "application/jtmimetype", {}) expect(SSLCommon).to receive(:post_data).with("http://localhost/endpoint", "test-jt-data", "application/jtmimetype", {})
else else
expect(SSLCommon).to receive(:post_data).never expect(SSLCommon).not_to receive(:post_data)
end end
@course.publish_final_grades(user) @course.publish_final_grades(user)
end end

View File

@ -1201,7 +1201,7 @@ describe DiscussionTopic do
it "does not attempt to clear stream items if a discussion topic was not section specific before last save" do it "does not attempt to clear stream items if a discussion topic was not section specific before last save" do
topic = @course.discussion_topics.create!(title: "Ben Loves Panda", user: @teacher) topic = @course.discussion_topics.create!(title: "Ben Loves Panda", user: @teacher)
expect(topic.stream_item).to receive(:stream_item_instances).never expect(topic.stream_item).not_to receive(:stream_item_instances)
topic.update!(title: "Lemon Loves Panda") topic.update!(title: "Lemon Loves Panda")
end end

View File

@ -1752,7 +1752,7 @@ describe Enrollment do
end end
it "does not attempt to recompute scores since the user is not a student" do it "does not attempt to recompute scores since the user is not a student" do
expect(Enrollment).to receive(:recompute_final_score).never expect(Enrollment).not_to receive(:recompute_final_score)
@enrollment.workflow_state = 'invited' @enrollment.workflow_state = 'invited'
@enrollment.save! @enrollment.save!
@enrollment.accept @enrollment.accept
@ -2666,7 +2666,7 @@ describe Enrollment do
@shard2.activate do @shard2.activate do
expect(Enrollment.cached_temporary_invitations('jt@instructure.com').sort_by(&:global_id)).to eq [@enrollment1, @enrollment2].sort_by(&:global_id) expect(Enrollment.cached_temporary_invitations('jt@instructure.com').sort_by(&:global_id)).to eq [@enrollment1, @enrollment2].sort_by(&:global_id)
end end
expect(Shard).to receive(:with_each_shard).never expect(Shard).not_to receive(:with_each_shard)
@shard1.activate do @shard1.activate do
expect(Enrollment.cached_temporary_invitations('jt@instructure.com').sort_by(&:global_id)).to eq [@enrollment1, @enrollment2].sort_by(&:global_id) expect(Enrollment.cached_temporary_invitations('jt@instructure.com').sort_by(&:global_id)).to eq [@enrollment1, @enrollment2].sort_by(&:global_id)
end end
@ -3127,7 +3127,7 @@ describe Enrollment do
end end
it "does not trigger a batch when enrollment is not student" do it "does not trigger a batch when enrollment is not student" do
expect(DueDateCacher).to receive(:recompute_users_for_course).never expect(DueDateCacher).not_to receive(:recompute_users_for_course)
@course.enroll_teacher(user_factory) @course.enroll_teacher(user_factory)
end end
@ -3137,12 +3137,12 @@ describe Enrollment do
end end
it "does not trigger when nothing changed" do it "does not trigger when nothing changed" do
expect(DueDateCacher).to receive(:recompute_users_for_course).never expect(DueDateCacher).not_to receive(:recompute_users_for_course)
@enrollment.save @enrollment.save
end end
it "does not trigger when set_update_cached_due_dates callback is suspended" do it "does not trigger when set_update_cached_due_dates callback is suspended" do
expect(DueDateCacher).to receive(:recompute_users_for_course).never expect(DueDateCacher).not_to receive(:recompute_users_for_course)
Enrollment.suspend_callbacks(:set_update_cached_due_dates) do Enrollment.suspend_callbacks(:set_update_cached_due_dates) do
@course.enroll_student(user_factory) @course.enroll_student(user_factory)
end end
@ -3152,7 +3152,7 @@ describe Enrollment do
override = assignment_override_model(assignment: @assignments.first) override = assignment_override_model(assignment: @assignments.first)
override.assignment_override_students.create(user: @student) override.assignment_override_students.create(user: @student)
expect(DueDateCacher).to receive(:recompute_users_for_course).once expect(DueDateCacher).to receive(:recompute_users_for_course).once
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
@enrollment.destroy @enrollment.destroy
end end

View File

@ -65,7 +65,7 @@ describe EnrollmentTerm do
end end
it 'does not recompute course scores if the grading period set is not changed' do it 'does not recompute course scores if the grading period set is not changed' do
expect(Enrollment).to receive(:recompute_final_score).never expect(Enrollment).not_to receive(:recompute_final_score)
@term.update!(name: 'The Best Term') @term.update!(name: 'The Best Term')
end end

View File

@ -521,7 +521,7 @@ describe GradingPeriodGroup do
end end
it 'does not recompute course scores when the weighted attribute is not changed' do it 'does not recompute course scores when the weighted attribute is not changed' do
expect(Enrollment).to receive(:recompute_final_score).never expect(Enrollment).not_to receive(:recompute_final_score)
@grading_period_set.update!(title: 'The Best Set') @grading_period_set.update!(title: 'The Best Set')
end end
end end

View File

@ -340,7 +340,7 @@ describe GroupMembership do
it "triggers a batch when membership is created" do it "triggers a batch when membership is created" do
new_user = user_factory new_user = user_factory
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
expect(DueDateCacher).to receive(:recompute_users_for_course).with( expect(DueDateCacher).to receive(:recompute_users_for_course).with(
new_user.id, new_user.id,
@course.id, @course.id,
@ -351,7 +351,7 @@ describe GroupMembership do
end end
it "triggers a batch when membership is deleted" do it "triggers a batch when membership is deleted" do
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
expect(DueDateCacher).to receive(:recompute_users_for_course).with( expect(DueDateCacher).to receive(:recompute_users_for_course).with(
@membership.user.id, @membership.user.id,
@course.id, @course.id,
@ -361,14 +361,14 @@ describe GroupMembership do
end end
it "does not trigger when nothing changed" do it "does not trigger when nothing changed" do
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
expect(DueDateCacher).to receive(:recompute_course).never expect(DueDateCacher).not_to receive(:recompute_course)
@membership.save @membership.save
end end
it "does not trigger when it's an account group" do it "does not trigger when it's an account group" do
expect(DueDateCacher).to receive(:recompute).never expect(DueDateCacher).not_to receive(:recompute)
expect(DueDateCacher).to receive(:recompute_course).never expect(DueDateCacher).not_to receive(:recompute_course)
@group = Account.default.groups.create!(:name => 'Group!') @group = Account.default.groups.create!(:name => 'Group!')
@group.group_memberships.create!(:user => user_factory) @group.group_memberships.create!(:user => user_factory)
end end

View File

@ -57,9 +57,9 @@ module Importers
expect(migration).to receive(:import_object?).with('attachments', migration_id).and_return(true) expect(migration).to receive(:import_object?).with('attachments', migration_id).and_return(true)
expect(attachment).to receive(:context=).with(course) expect(attachment).to receive(:context=).with(course)
expect(attachment).to receive(:migration_id=).with(migration_id) expect(attachment).to receive(:migration_id=).with(migration_id)
expect(attachment).to receive(:locked=).never expect(attachment).not_to receive(:locked=)
expect(attachment).to receive(:file_state=).never expect(attachment).not_to receive(:file_state=)
expect(attachment).to receive(:display_name=).never expect(attachment).not_to receive(:display_name=)
expect(attachment).to receive(:save_without_broadcasting!) expect(attachment).to receive(:save_without_broadcasting!)
Importers::AttachmentImporter.process_migration(data, migration) Importers::AttachmentImporter.process_migration(data, migration)
@ -155,7 +155,7 @@ module Importers
} }
} }
expect(::Attachment).to receive(:where).never expect(::Attachment).not_to receive(:where)
Importers::AttachmentImporter.process_migration(data, migration) Importers::AttachmentImporter.process_migration(data, migration)
end end
@ -172,7 +172,7 @@ module Importers
} }
} }
expect(::Attachment).to receive(:where).never expect(::Attachment).not_to receive(:where)
Importers::AttachmentImporter.process_migration(data, migration) Importers::AttachmentImporter.process_migration(data, migration)
end end

View File

@ -288,7 +288,7 @@ describe Course do
migration = build_migration(@course, params) migration = build_migration(@course, params)
@course.reload # seems to be holding onto saved_changes for some reason @course.reload # seems to be holding onto saved_changes for some reason
expect(DueDateCacher).to receive(:recompute_course).never expect(DueDateCacher).not_to receive(:recompute_course)
setup_import(@course, 'assessments.json', migration) setup_import(@course, 'assessments.json', migration)
expect(migration.workflow_state).to eq('imported') expect(migration.workflow_state).to eq('imported')
end end

View File

@ -103,8 +103,8 @@ describe IncomingMail::MessageHandler do
it "silently fails on no message notification id" do it "silently fails on no message notification id" do
message = double("original message without notification id", original_message_attributes.merge(:notification_id => nil)) message = double("original message without notification id", original_message_attributes.merge(:notification_id => nil))
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(message)
expect(Mailer).to receive(:create_message).never expect(Mailer).not_to receive(:create_message)
expect(message.context).to receive(:reply_from).never expect(message.context).not_to receive(:reply_from)
subject.handle(outgoing_from_address, body, html_body, incoming_message, tag) subject.handle(outgoing_from_address, body, html_body, incoming_message, tag)
end end
@ -112,31 +112,31 @@ describe IncomingMail::MessageHandler do
it "silently fails on invalid secure id" do it "silently fails on invalid secure id" do
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message)
allow(CanvasSecurity).to receive(:verify_hmac_sha1).and_return(false) allow(CanvasSecurity).to receive(:verify_hmac_sha1).and_return(false)
expect(Mailer).to receive(:create_message).never expect(Mailer).not_to receive(:create_message)
expect(original_message.context).to receive(:reply_from).never expect(original_message.context).not_to receive(:reply_from)
subject.handle(outgoing_from_address, body, html_body, incoming_message, tag) subject.handle(outgoing_from_address, body, html_body, incoming_message, tag)
end end
it "silently fails if the original message is missing" do it "silently fails if the original message is missing" do
expect(Message).to receive(:where).with(id: original_message_id).and_return(double(first: nil)) expect(Message).to receive(:where).with(id: original_message_id).and_return(double(first: nil))
expect_any_instance_of(Message).to receive(:deliver).never expect_any_instance_of(Message).not_to receive(:deliver)
subject.handle(outgoing_from_address, body, html_body, incoming_message, "#{secure_id}-#{original_message_id}") subject.handle(outgoing_from_address, body, html_body, incoming_message, "#{secure_id}-#{original_message_id}")
end end
it "silently fails if the address tag is invalid" do it "silently fails if the address tag is invalid" do
expect(Message).to receive(:where).never expect(Message).not_to receive(:where)
expect_any_instance_of(Message).to receive(:deliver).never expect_any_instance_of(Message).not_to receive(:deliver)
subject.handle(outgoing_from_address, body, html_body, incoming_message, "#{secure_id}-not-an-id") subject.handle(outgoing_from_address, body, html_body, incoming_message, "#{secure_id}-not-an-id")
end end
it "silently fails if the message is not from one of the original recipient's email addresses" do it "silently fails if the message is not from one of the original recipient's email addresses" do
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message)
expect_any_instance_of(Message).to receive(:deliver).never expect_any_instance_of(Message).not_to receive(:deliver)
expect(Account.site_admin).to receive(:feature_enabled?).with(:notification_service).and_return(false) expect(Account.site_admin).to receive(:feature_enabled?).with(:notification_service).and_return(false)
expect(original_message.context).to receive(:reply_from).never expect(original_message.context).not_to receive(:reply_from)
message = double("incoming message with bad from", message = double("incoming message with bad from",
incoming_message_attributes.merge(:from => ['not_lucy@example.com'], incoming_message_attributes.merge(:from => ['not_lucy@example.com'],
:reply_to => ['also_not_lucy@example.com'])) :reply_to => ['also_not_lucy@example.com']))
@ -146,7 +146,7 @@ describe IncomingMail::MessageHandler do
it 'raises BlankMessage for empty message' do it 'raises BlankMessage for empty message' do
message = double("original message without notification id", original_message_attributes) message = double("original message without notification id", original_message_attributes)
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(message)
expect(original_message.context).to receive(:reply_from).never expect(original_message.context).not_to receive(:reply_from)
subject.handle(outgoing_from_address, " ", html_body, incoming_message, tag) subject.handle(outgoing_from_address, " ", html_body, incoming_message, tag)
end end
end end
@ -180,7 +180,7 @@ describe IncomingMail::MessageHandler do
it "does not send a message if the incoming message has no from" do it "does not send a message if the incoming message has no from" do
invalid_incoming_message = double("invalid incoming message", incoming_message_attributes.merge(from: nil, reply_to: nil)) invalid_incoming_message = double("invalid incoming message", incoming_message_attributes.merge(from: nil, reply_to: nil))
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message)
expect_any_instance_of(Message).to receive(:deliver).never expect_any_instance_of(Message).not_to receive(:deliver)
subject.handle(outgoing_from_address, body, html_body, invalid_incoming_message, tag) subject.handle(outgoing_from_address, body, html_body, invalid_incoming_message, tag)
end end
@ -282,7 +282,7 @@ describe IncomingMail::MessageHandler do
it "bounces the message back to the incoming from address" do it "bounces the message back to the incoming from address" do
allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message) allow(subject).to receive(:get_original_message).with(original_message_id, timestamp).and_return(original_message)
expect_any_instance_of(Message).to receive(:deliver).never expect_any_instance_of(Message).not_to receive(:deliver)
expect(Mailer).to receive(:create_message) expect(Mailer).to receive(:create_message)
message = double("incoming message with bad from", message = double("incoming message with bad from",

View File

@ -36,7 +36,7 @@ describe KalturaMediaFileHandler do
end end
it "returns without action when all attachments have media objects already" do it "returns without action when all attachments have media objects already" do
expect(kaltura_client).to receive(:bulkUploadAdd).never expect(kaltura_client).not_to receive(:bulkUploadAdd)
attachment.media_object = media_object() attachment.media_object = media_object()
res = KalturaMediaFileHandler.new.add_media_files(attachment, wait_for_completion) res = KalturaMediaFileHandler.new.add_media_files(attachment, wait_for_completion)
expect(res).to be_nil expect(res).to be_nil

View File

@ -32,7 +32,7 @@ describe MasterCourses::ChildSubscription do
it "caches the result" do it "caches the result" do
enable_cache do enable_cache do
expect(check).to be_falsey expect(check).to be_falsey
expect(MasterCourses::ChildSubscription).to receive(:where).never expect(MasterCourses::ChildSubscription).not_to receive(:where)
expect(check).to be_falsey expect(check).to be_falsey
expect(MasterCourses::ChildSubscription.is_child_course?(@course.id)).to be_falsey # should work with ids too expect(MasterCourses::ChildSubscription.is_child_course?(@course.id)).to be_falsey # should work with ids too
end end

View File

@ -45,7 +45,7 @@ describe MasterCourses::MasterMigration do
@template.active_migration = running @template.active_migration = running
@template.save! @template.save!
expect_any_instance_of(MasterCourses::MasterMigration).to receive(:queue_export_job).never expect_any_instance_of(MasterCourses::MasterMigration).not_to receive(:queue_export_job)
expect { expect {
MasterCourses::MasterMigration.start_new_migration!(@template, @user) MasterCourses::MasterMigration.start_new_migration!(@template, @user)
}.to raise_error("cannot start new migration while another one is running") }.to raise_error("cannot start new migration while another one is running")
@ -75,7 +75,7 @@ describe MasterCourses::MasterMigration do
end end
it "does not do anything if there aren't any child courses to push to" do it "does not do anything if there aren't any child courses to push to" do
expect(@migration).to receive(:create_export).never expect(@migration).not_to receive(:create_export)
@migration.perform_exports @migration.perform_exports
@migration.reload @migration.reload
expect(@migration).to be_completed expect(@migration).to be_completed
@ -87,7 +87,7 @@ describe MasterCourses::MasterMigration do
sub = @template.add_child_course!(other_course) sub = @template.add_child_course!(other_course)
sub.destroy! sub.destroy!
expect(@migration).to receive(:create_export).never expect(@migration).not_to receive(:create_export)
@migration.perform_exports @migration.perform_exports
end end
@ -1875,7 +1875,7 @@ describe MasterCourses::MasterMigration do
child_sub_folder = copied_att.folder child_sub_folder = copied_att.folder
child_parent_folder = child_sub_folder.parent_folder child_parent_folder = child_sub_folder.parent_folder
expected_ids = [child_sub_folder, child_parent_folder, Folder.root_folders(@copy_to).first].map(&:id) expected_ids = [child_sub_folder, child_parent_folder, Folder.root_folders(@copy_to).first].map(&:id)
expect(Folder.connection).to receive(:select_values).never # should have already been cached in migration expect(Folder.connection).not_to receive(:select_values) # should have already been cached in migration
expect(MasterCourses::FolderHelper.locked_folder_ids_for_course(@copy_to)).to match_array(expected_ids) expect(MasterCourses::FolderHelper.locked_folder_ids_for_course(@copy_to)).to match_array(expected_ids)
end end
end end

View File

@ -65,7 +65,7 @@ describe MasterCourses::MasterTemplate do
MasterCourses::MasterTemplate.remove_as_master_course(@course) MasterCourses::MasterTemplate.remove_as_master_course(@course)
expect(template).to receive(:destroy).never expect(template).not_to receive(:destroy)
expect(template).to be_deleted expect(template).to be_deleted
end end
end end
@ -78,7 +78,7 @@ describe MasterCourses::MasterTemplate do
it "caches the result" do it "caches the result" do
enable_cache do enable_cache do
expect(check).to be_falsey expect(check).to be_falsey
expect(@course).to receive(:master_course_templates).never expect(@course).not_to receive(:master_course_templates)
expect(check).to be_falsey expect(check).to be_falsey
expect(MasterCourses::MasterTemplate.is_master_course?(@course.id)).to be_falsey # should work with ids too expect(MasterCourses::MasterTemplate.is_master_course?(@course.id)).to be_falsey # should work with ids too
end end
@ -108,7 +108,7 @@ describe MasterCourses::MasterTemplate do
it "finds tags" do it "finds tags" do
tag = @template.create_content_tag_for!(@assignment) tag = @template.create_content_tag_for!(@assignment)
expect(@template).to receive(:create_content_tag_for!).never # don't try to recreate expect(@template).not_to receive(:create_content_tag_for!) # don't try to recreate
expect(@template.content_tag_for(@assignment)).to eq tag expect(@template.content_tag_for(@assignment)).to eq tag
end end

View File

@ -120,7 +120,7 @@ describe MasterCourses::Restrictor do
MasterCourses::Restrictor.preload_child_restrictions([@page_copy, page2_copy]) MasterCourses::Restrictor.preload_child_restrictions([@page_copy, page2_copy])
expect(MasterCourses::MasterContentTag).to receive(:where).never # don't load again expect(MasterCourses::MasterContentTag).not_to receive(:where) # don't load again
expect(@page_copy.child_content_restrictions).to eq({}) expect(@page_copy.child_content_restrictions).to eq({})
expect(page2_copy.child_content_restrictions).to eq({ :content => true }) expect(page2_copy.child_content_restrictions).to eq({ :content => true })
end end

View File

@ -84,13 +84,13 @@ describe MediaObject do
describe ".ensure_media_object" do describe ".ensure_media_object" do
it "does not create if the media object exists already" do it "does not create if the media object exists already" do
MediaObject.create!(:context => user_factory, :media_id => "test") MediaObject.create!(:context => user_factory, :media_id => "test")
expect(MediaObject).to receive(:create!).never expect(MediaObject).not_to receive(:create!)
MediaObject.ensure_media_object("test", {}) MediaObject.ensure_media_object("test", {})
end end
it "does not create if the media id doesn't exist in kaltura" do it "does not create if the media id doesn't exist in kaltura" do
expect(MediaObject).to receive(:media_id_exists?).with("test").and_return(false) expect(MediaObject).to receive(:media_id_exists?).with("test").and_return(false)
expect(MediaObject).to receive(:create!).never expect(MediaObject).not_to receive(:create!)
MediaObject.ensure_media_object("test", {}) MediaObject.ensure_media_object("test", {})
run_jobs run_jobs
end end
@ -137,7 +137,7 @@ describe MediaObject do
mo = MediaObject.create!(:context => user_factory, :media_id => "test") mo = MediaObject.create!(:context => user_factory, :media_id => "test")
mo.data = { extensions: { mp4: { id: "t-yyy" } } } mo.data = { extensions: { mp4: { id: "t-yyy" } } }
expect(mo).to receive(:retrieve_details) expect(mo).to receive(:retrieve_details)
expect(mo).to receive(:delay).never expect(mo).not_to receive(:delay)
mo.retrieve_details_ensure_codecs(1) mo.retrieve_details_ensure_codecs(1)
end end
end end

View File

@ -273,8 +273,8 @@ describe Message do
it "does not deliver if canceled" do it "does not deliver if canceled" do
message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email') message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email')
@message.cancel @message.cancel
expect(@message).to receive(:deliver_via_email).never expect(@message).not_to receive(:deliver_via_email)
expect(Mailer).to receive(:create_message).never expect(Mailer).not_to receive(:create_message)
expect(@message.deliver).to be_nil expect(@message.deliver).to be_nil
expect(@message.reload.state).to eq :cancelled expect(@message.reload.state).to eq :cancelled
end end
@ -287,12 +287,12 @@ describe Message do
message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email') message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email')
expect(Mailer).to receive(:create_message).and_raise(Timeout::Error.new) expect(Mailer).to receive(:create_message).and_raise(Timeout::Error.new)
expect(ErrorReport).to receive(:log_exception).never expect(ErrorReport).not_to receive(:log_exception)
expect { @message.deliver }.to raise_exception(Timeout::Error) expect { @message.deliver }.to raise_exception(Timeout::Error)
message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email') message_model(:dispatch_at => Time.now, :workflow_state => 'staged', :to => 'somebody', :updated_at => Time.now.utc - 11.minutes, :user => user_factory, :path_type => 'email')
expect(Mailer).to receive(:create_message).and_raise("450 recipient address rejected") expect(Mailer).to receive(:create_message).and_raise("450 recipient address rejected")
expect(ErrorReport).to receive(:log_exception).never expect(ErrorReport).not_to receive(:log_exception)
expect(@message.deliver).to eq false expect(@message.deliver).to eq false
end end
@ -361,7 +361,7 @@ describe Message do
it "delivers to each of a user's push endpoints" do it "delivers to each of a user's push endpoints" do
ne = double() ne = double()
expect(ne).to receive(:push_json).twice.and_return(true) expect(ne).to receive(:push_json).twice.and_return(true)
expect(ne).to receive(:destroy).never expect(ne).not_to receive(:destroy)
expect(@user).to receive(:notification_endpoints).and_return([ne, ne]) expect(@user).to receive(:notification_endpoints).and_return([ne, ne])
message_model(notification_name: 'Assignment Created', message_model(notification_name: 'Assignment Created',
@ -394,7 +394,7 @@ describe Message do
notification_name: 'New Wiki Page', notification_name: 'New Wiki Page',
user: @user user: @user
) )
expect(@message).to receive(:deliver_via_push).never expect(@message).not_to receive(:deliver_via_push)
@message.deliver @message.deliver
end end
end end
@ -419,7 +419,7 @@ describe Message do
notification_name: 'New Wiki Page', notification_name: 'New Wiki Page',
user: @user user: @user
) )
expect(@message).to receive(:deliver_via_push).never expect(@message).not_to receive(:deliver_via_push)
@message.deliver @message.deliver
end end
end end

View File

@ -95,7 +95,7 @@ describe NotificationEndpoint do
ne = @at.notification_endpoints.create!(token: 'token') ne = @at.notification_endpoints.create!(token: 'token')
expect(@sns_client).to receive(:get_endpoint_attributes).and_return(double(attributes: { 'Enabled' => 'true', 'CustomUserData' => 'not my id' })) expect(@sns_client).to receive(:get_endpoint_attributes).and_return(double(attributes: { 'Enabled' => 'true', 'CustomUserData' => 'not my id' }))
expect(@sns_client).to receive(:delete_endpoint).never expect(@sns_client).not_to receive(:delete_endpoint)
ne.destroy ne.destroy
end end
end end

View File

@ -31,7 +31,7 @@ describe NotificationFinder do
it 'loads notifications from the cache' do it 'loads notifications from the cache' do
expect(finder.notifications.length).to eq(1) expect(finder.notifications.length).to eq(1)
expect(Notification).to receive(:connection).never expect(Notification).not_to receive(:connection)
finder.by_name(notification.name) finder.by_name(notification.name)
finder.find_by_name(notification.name) finder.find_by_name(notification.name)
end end

View File

@ -61,7 +61,7 @@ describe PageView do
it "does not start a db transaction on save" do it "does not start a db transaction on save" do
PageView.new { |p| p.assign_attributes({ :user => @user, :url => "http://test.one/", :session_id => "phony", :context => @course, :controller => 'courses', :action => 'show', :user_request => true, :render_time => 0.01, :user_agent => 'None', :account_id => Account.default.id, :request_id => "abcdef", :interaction_seconds => 5 }) }.store PageView.new { |p| p.assign_attributes({ :user => @user, :url => "http://test.one/", :session_id => "phony", :context => @course, :controller => 'courses', :action => 'show', :user_request => true, :render_time => 0.01, :user_agent => 'None', :account_id => Account.default.id, :request_id => "abcdef", :interaction_seconds => 5 }) }.store
expect(PageView.connection).to receive(:transaction).never expect(PageView.connection).not_to receive(:transaction)
expect(PageView.find("abcdef")).to be_present expect(PageView.find("abcdef")).to be_present
end end
@ -580,7 +580,7 @@ describe PageView do
it "store doesn't do anything" do it "store doesn't do anything" do
pv = PageView.new pv = PageView.new
expect(pv).to receive(:save).never expect(pv).not_to receive(:save)
expect(pv).to receive(:store_page_view_to_user_counts) expect(pv).to receive(:store_page_view_to_user_counts)
pv.user = User.new pv.user = User.new
pv.store pv.store

View File

@ -199,14 +199,14 @@ describe Pseudonym do
it "only checks an explicit LDAP provider" do it "only checks an explicit LDAP provider" do
aac2 = @pseudonym.account.authentication_providers.create!(auth_type: 'ldap') aac2 = @pseudonym.account.authentication_providers.create!(auth_type: 'ldap')
@pseudonym.update_attribute(:authentication_provider, aac2) @pseudonym.update_attribute(:authentication_provider, aac2)
expect_any_instantiation_of(@aac).to receive(:ldap_bind_result).never expect_any_instantiation_of(@aac).not_to receive(:ldap_bind_result)
expect(aac2).to receive(:ldap_bind_result).and_return(42) expect(aac2).to receive(:ldap_bind_result).and_return(42)
expect(@pseudonym.ldap_bind_result('stuff')).to eq 42 expect(@pseudonym.ldap_bind_result('stuff')).to eq 42
end end
it "doesn't even check LDAP for a Canvas pseudonym" do it "doesn't even check LDAP for a Canvas pseudonym" do
@pseudonym.update_attribute(:authentication_provider, @pseudonym.account.canvas_authentication_provider) @pseudonym.update_attribute(:authentication_provider, @pseudonym.account.canvas_authentication_provider)
expect_any_instantiation_of(@aac).to receive(:ldap_bind_result).never expect_any_instantiation_of(@aac).not_to receive(:ldap_bind_result)
expect(@pseudonym.ldap_bind_result('stuff')).to eq nil expect(@pseudonym.ldap_bind_result('stuff')).to eq nil
end end
end end
@ -219,10 +219,10 @@ describe Pseudonym do
it "does not attempt validating a blank password" do it "does not attempt validating a blank password" do
pseudonym_model pseudonym_model
expect(@pseudonym).to receive(:sis_ssha).never expect(@pseudonym).not_to receive(:sis_ssha)
@pseudonym.valid_ssha?('') @pseudonym.valid_ssha?('')
expect(@pseudonym).to receive(:ldap_bind_result).never expect(@pseudonym).not_to receive(:ldap_bind_result)
@pseudonym.valid_ldap_credentials?('') @pseudonym.valid_ldap_credentials?('')
end end

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