spec: mocha => rspec-stubs for views
whoa, a commit that I didn't have to manually fix anything after running thorugh the automated fixer! Change-Id: I6ff371a3d8fa775afdf224027dfb5162580506d5 Reviewed-on: https://gerrit.instructure.com/120565 Tested-by: Jenkins Reviewed-by: Rob Orton <rob@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
20ff5a9910
commit
114a923c83
|
@ -23,8 +23,8 @@ describe "accounts/_sis_batch_counts.html.erb" do
|
|||
|
||||
it "should render sis count data" do
|
||||
data = {:counts => {:xlists => 2, :enrollments => 3, :courses => 5, :users => 6, :terms => 6, :group_memberships => 7, :groups => 8, :sections => 9, :accounts => 10}}
|
||||
report = mock()
|
||||
report.expects(:data).returns(data)
|
||||
report = double()
|
||||
expect(report).to receive(:data).and_return(data)
|
||||
render :partial => 'accounts/sis_batch_counts', :object => report
|
||||
|
||||
map = {:xlists => "Crosslists", :group_memberships => "Group Enrollments"}
|
||||
|
|
|
@ -136,7 +136,7 @@ describe "accounts/settings.html.erb" do
|
|||
context "should not show settings to site admin user" do
|
||||
context "new_sis_integrations => true" do
|
||||
before do
|
||||
@account.stubs(:feature_enabled?).with(:new_sis_integrations).returns(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:new_sis_integrations).and_return(true)
|
||||
end
|
||||
|
||||
it { expect(response).not_to have_tag("#sis_integration_settings") }
|
||||
|
@ -148,7 +148,7 @@ describe "accounts/settings.html.erb" do
|
|||
|
||||
context "new_sis_integrations => false" do
|
||||
before do
|
||||
@account.stubs(:feature_enabled?).with(:new_sis_integrations).returns(false)
|
||||
allow(@account).to receive(:feature_enabled?).with(:new_sis_integrations).and_return(false)
|
||||
end
|
||||
|
||||
it { expect(response).not_to have_tag("#sis_integration_settings") }
|
||||
|
@ -168,20 +168,20 @@ describe "accounts/settings.html.erb" do
|
|||
assign(:root_account, @account)
|
||||
assign(:current_user, current_user)
|
||||
|
||||
@account.stubs(:feature_enabled?).with(:post_grades).returns(true)
|
||||
@account.stubs(:feature_enabled?).with(:google_docs_domain_restriction).returns(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:post_grades).and_return(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:google_docs_domain_restriction).and_return(true)
|
||||
end
|
||||
|
||||
context "new_sis_integrations => false" do
|
||||
before do
|
||||
@account.stubs(:feature_enabled?).with(:new_sis_integrations).returns(false)
|
||||
@account.stubs(:grants_right?).with(current_user, :manage_account_memberships).returns(true)
|
||||
@account.stubs(:feature_enabled?).with(:plagiarism_detection_platform).returns(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:new_sis_integrations).and_return(false)
|
||||
allow(@account).to receive(:grants_right?).with(current_user, :manage_account_memberships).and_return(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:plagiarism_detection_platform).and_return(true)
|
||||
end
|
||||
|
||||
context "show old version of settings to regular admin user" do
|
||||
before do
|
||||
@account.stubs(:grants_right?).with(current_user, :manage_site_settings).returns(true)
|
||||
allow(@account).to receive(:grants_right?).with(current_user, :manage_site_settings).and_return(true)
|
||||
do_render(current_user)
|
||||
end
|
||||
|
||||
|
@ -203,8 +203,8 @@ describe "accounts/settings.html.erb" do
|
|||
let(:assignment_name_length) { "#account_settings_sis_assignment_name_length_value" }
|
||||
|
||||
before do
|
||||
@account.stubs(:feature_enabled?).with(:new_sis_integrations).returns(true)
|
||||
@account.stubs(:feature_enabled?).with(:plagiarism_detection_platform).returns(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:new_sis_integrations).and_return(true)
|
||||
allow(@account).to receive(:feature_enabled?).with(:plagiarism_detection_platform).and_return(true)
|
||||
end
|
||||
|
||||
context "should show settings to regular admin user" do
|
||||
|
@ -226,13 +226,13 @@ describe "accounts/settings.html.erb" do
|
|||
|
||||
context "SIS syncing enabled" do
|
||||
before do
|
||||
Assignment.stubs(:sis_grade_export_enabled?).returns(true)
|
||||
allow(Assignment).to receive(:sis_grade_export_enabled?).and_return(true)
|
||||
end
|
||||
|
||||
context "for root account" do
|
||||
before do
|
||||
@account.stubs(:sis_syncing).returns({value: true, locked: true})
|
||||
@account.stubs(:feature_enabled?).with(:plagiarism_detection_platform).returns(true)
|
||||
allow(@account).to receive(:sis_syncing).and_return({value: true, locked: true})
|
||||
allow(@account).to receive(:feature_enabled?).with(:plagiarism_detection_platform).and_return(true)
|
||||
do_render(current_user)
|
||||
end
|
||||
|
||||
|
@ -250,7 +250,7 @@ describe "accounts/settings.html.erb" do
|
|||
context "locked" do
|
||||
before do
|
||||
@account.enable_feature!(:post_grades)
|
||||
@account.stubs(:sis_syncing).returns({value: true, locked: true, inherited: true })
|
||||
allow(@account).to receive(:sis_syncing).and_return({value: true, locked: true, inherited: true })
|
||||
do_render(current_user, @account)
|
||||
end
|
||||
|
||||
|
@ -265,8 +265,8 @@ describe "accounts/settings.html.erb" do
|
|||
|
||||
context "not locked" do
|
||||
before do
|
||||
@account.stubs(:sis_syncing).returns({value: true, locked: false, inherited: true })
|
||||
@account.stubs(:feature_enabled?).with(:plagiarism_detection_platform).returns(true)
|
||||
allow(@account).to receive(:sis_syncing).and_return({value: true, locked: false, inherited: true })
|
||||
allow(@account).to receive(:feature_enabled?).with(:plagiarism_detection_platform).and_return(true)
|
||||
do_render(current_user)
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ describe "communication_channels/confirm.html.erb" do
|
|||
assign(:nonce, @cc.confirmation_code)
|
||||
assign(:body_classes, [])
|
||||
assign(:domain_root_account, assign(:root_account, Account.default))
|
||||
view.stubs(:require_terms?).returns(nil) # since controller-defined helper methods don't get plumbed down here
|
||||
allow(view).to receive(:require_terms?).and_return(nil) # since controller-defined helper methods don't get plumbed down here
|
||||
end
|
||||
|
||||
shared_examples_for "user registration" do
|
||||
|
|
|
@ -107,7 +107,7 @@ describe "/courses/_recent_event" do
|
|||
Quizzes::SubmissionGrader.new(@quiz_submission).grade_submission
|
||||
|
||||
@submission = @quiz_submission.submission
|
||||
Submission.any_instance.stubs(:grade).returns('1234567890')
|
||||
allow_any_instance_of(Submission).to receive(:grade).and_return('1234567890')
|
||||
end
|
||||
|
||||
it "should show the grade for a non-muted assignment" do
|
||||
|
|
|
@ -109,8 +109,8 @@ describe "courses/_to_do_list.html.erb" do
|
|||
submission_types: "online_text_entry",
|
||||
points_possible: 15,
|
||||
title: "GradeMe")
|
||||
Assignment.stubs(:need_grading_info).returns(Assignment.where(id: @assignment.id))
|
||||
Assignments::NeedsGradingCountQuery.any_instance.stubs(:manual_count).returns(1000)
|
||||
allow(Assignment).to receive(:need_grading_info).and_return(Assignment.where(id: @assignment.id))
|
||||
allow_any_instance_of(Assignments::NeedsGradingCountQuery).to receive(:manual_count).and_return(1000)
|
||||
@user = @teacher
|
||||
@user.course_nicknames[@course.id] = "My Awesome Course"
|
||||
@user.save!
|
||||
|
@ -136,7 +136,7 @@ describe "courses/_to_do_list.html.erb" do
|
|||
points_possible: 15,
|
||||
title: "ModerateMe",
|
||||
moderated_grading: true)
|
||||
Assignments::NeedsGradingCountQuery.any_instance.stubs(:manual_count).returns(1)
|
||||
allow_any_instance_of(Assignments::NeedsGradingCountQuery).to receive(:manual_count).and_return(1)
|
||||
@submission = submission_model(assignment: @assignment, body: "my submission")
|
||||
@submission.find_or_create_provisional_grade!(@teacher, grade: 5)
|
||||
@user = @teacher
|
||||
|
|
|
@ -33,7 +33,7 @@ describe "courses/_settings_sidebar.html.erb" do
|
|||
|
||||
describe "End this course button" do
|
||||
it "should not display if the course or term end date has passed" do
|
||||
@course.stubs(:soft_concluded?).returns(true)
|
||||
allow(@course).to receive(:soft_concluded?).and_return(true)
|
||||
view_context(@course, @user)
|
||||
assign(:current_user, @user)
|
||||
render
|
||||
|
@ -41,7 +41,7 @@ describe "courses/_settings_sidebar.html.erb" do
|
|||
end
|
||||
|
||||
it "should display if the course and its term haven't ended" do
|
||||
@course.stubs(:soft_concluded?).returns(false)
|
||||
allow(@course).to receive(:soft_concluded?).and_return(false)
|
||||
view_context(@course, @user)
|
||||
assign(:current_user, @user)
|
||||
render
|
||||
|
|
|
@ -34,8 +34,8 @@ describe "/gradebooks/gradebook" do
|
|||
if course_allows && permissions_allow
|
||||
assign(:post_grades_tools, [{type: :post_grades}])
|
||||
end
|
||||
@course.expects(:allows_grade_publishing_by).with(@user).returns(course_allows)
|
||||
@course.expects(:grants_any_right?).returns(permissions_allow) if course_allows
|
||||
expect(@course).to receive(:allows_grade_publishing_by).with(@user).and_return(course_allows)
|
||||
expect(@course).to receive(:grants_any_right?).and_return(permissions_allow) if course_allows
|
||||
render "/gradebooks/gradebook"
|
||||
expect(response).not_to be_nil
|
||||
if course_allows && permissions_allow
|
||||
|
|
|
@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
|
|||
|
||||
describe "plugins/show" do
|
||||
it "renders without exploding" do
|
||||
plugin = stub(
|
||||
plugin = double(
|
||||
id: 'some_plugin',
|
||||
name: "Some Plugin",
|
||||
settings_partial: "settings_header"
|
||||
|
@ -29,8 +29,8 @@ describe "plugins/show" do
|
|||
|
||||
assign(:plugin, plugin)
|
||||
assign(:plugin_setting, plugin_setting)
|
||||
view.stubs(:plugin_path).returns("/some/path")
|
||||
view.stubs(:params).returns({id: 'some_plugin'})
|
||||
allow(view).to receive(:plugin_path).and_return("/some/path")
|
||||
allow(view).to receive(:params).and_return({id: 'some_plugin'})
|
||||
render 'plugins/show'
|
||||
expect(response.body).to match("Return to plugins list")
|
||||
end
|
||||
|
|
|
@ -24,14 +24,14 @@ describe "/quiz_submissions/show" do
|
|||
it "should render" do
|
||||
course_with_student
|
||||
view_context
|
||||
@submission = mock('Quizzes::QuizSubmission')
|
||||
@submission.stubs(:score).returns(10)
|
||||
@submission.stubs(:data).returns([])
|
||||
@quiz = mock('Quizzes::Quiz')
|
||||
@quiz.stubs(:questions).returns([])
|
||||
@quiz.stubs(:points_possible).returns(10)
|
||||
@quiz.stubs(:stored_questions).returns([])
|
||||
@quiz.stubs(:show_correct_answers?).returns(true)
|
||||
@submission = double('Quizzes::QuizSubmission')
|
||||
allow(@submission).to receive(:score).and_return(10)
|
||||
allow(@submission).to receive(:data).and_return([])
|
||||
@quiz = double('Quizzes::Quiz')
|
||||
allow(@quiz).to receive(:questions).and_return([])
|
||||
allow(@quiz).to receive(:points_possible).and_return(10)
|
||||
allow(@quiz).to receive(:stored_questions).and_return([])
|
||||
allow(@quiz).to receive(:show_correct_answers?).and_return(true)
|
||||
assign(:quiz, @quiz)
|
||||
assign(:submission, @submission)
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ describe "/quizzes/quizzes/_quiz_edit" do
|
|||
end
|
||||
|
||||
it 'should include conditional content if configured' do
|
||||
ConditionalRelease::Service.stubs(:enabled_in_context?).returns(true)
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(true)
|
||||
render :partial => "quizzes/quizzes/quiz_edit"
|
||||
expect(response.body).to match /conditional_release/
|
||||
end
|
||||
|
||||
it 'should not include conditional content if not configured' do
|
||||
ConditionalRelease::Service.stubs(:enabled_in_context?).returns(false)
|
||||
allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(false)
|
||||
render :partial => "quizzes/quizzes/quiz_edit"
|
||||
expect(response.body).not_to match /conditional_release/
|
||||
end
|
||||
|
|
|
@ -65,7 +65,7 @@ describe "/quizzes/quizzes/_quiz_submission" do
|
|||
course_with_teacher course: @course, active_all: true
|
||||
view_context
|
||||
|
||||
Quizzes::Quiz.stubs(:lockdown_browser_plugin_enabled?).returns(true)
|
||||
allow(Quizzes::Quiz).to receive(:lockdown_browser_plugin_enabled?).and_return(true)
|
||||
quiz = @course.quizzes.create!
|
||||
quiz.require_lockdown_browser = true
|
||||
quiz.require_lockdown_browser_for_results = true
|
||||
|
|
|
@ -61,14 +61,14 @@ describe "/quizzes/quizzes/new" do
|
|||
end
|
||||
|
||||
it 'has a published inditactor when the quiz is published' do
|
||||
@quiz.stubs(:published?).returns true
|
||||
allow(@quiz).to receive(:published?).and_return true
|
||||
render 'quizzes/quizzes/new'
|
||||
expect(response.inspect).to include("Published")
|
||||
expect(response.inspect).not_to include("Not Published")
|
||||
end
|
||||
|
||||
it 'has a not_published indicator when the quiz is not published' do
|
||||
@quiz.stubs(:published?).returns false
|
||||
allow(@quiz).to receive(:published?).and_return false
|
||||
render 'quizzes/quizzes/new'
|
||||
expect(response.inspect).to include("Not Published")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue