rspec 3-ify spec/integration

refs CNVS-16239

Change-Id: Ifdda42582111e144648af46ab6c383f71c1858ab
Reviewed-on: https://gerrit.instructure.com/42678
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <braden@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Braden Anderson <braden@instructure.com>
This commit is contained in:
Cody Cutrer 2014-10-13 12:51:52 -06:00
parent 575e9ab344
commit a40c037d81
37 changed files with 854 additions and 858 deletions

View File

@ -22,18 +22,14 @@ describe AccountsController do
context "SAML meta data" do
before(:each) do
pending("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled
ConfigFile.stub('saml', {
:tech_contact_name => nil,
:tech_contact_email => nil
})
skip("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled
@account = Account.create!(:name => "test")
end
it 'should render for non SAML configured accounts' do
get "/saml_meta_data"
response.should be_success
response.body.should_not == ""
expect(response).to be_success
expect(response.body).not_to eq ""
end
it "should use the correct entity_id" do
@ -41,9 +37,9 @@ describe AccountsController do
@aac = @account.account_authorization_configs.create!(:auth_type => "saml")
get "/saml_meta_data"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css("EntityDescriptor")['entityID'].should == "http://bob.cody.instructure.com/saml2"
expect(doc.at_css("EntityDescriptor")['entityID']).to eq "http://bob.cody.instructure.com/saml2"
end
end
@ -57,9 +53,9 @@ describe AccountsController do
user_session @admin
Timecop.freeze(61.minutes.ago) do
get "/accounts/#{@account.id}"
response.should be_ok
expect(response).to be_ok
doc = Nokogiri::HTML(response.body)
doc.at_css('#section-tabs .section .outcomes').should_not be_nil
expect(doc.at_css('#section-tabs .section .outcomes')).not_to be_nil
end
# change a permission on the user's role
@ -68,9 +64,9 @@ describe AccountsController do
# ensure the change is reflected once the user's cached permissions expire
get "/accounts/#{@account.id}"
response.should be_ok
expect(response).to be_ok
doc = Nokogiri::HTML(response.body)
doc.at_css('#section-tabs .section .outcomes').should be_nil
expect(doc.at_css('#section-tabs .section .outcomes')).to be_nil
end
end
end

View File

@ -35,25 +35,25 @@ describe "site-wide" do
it "should set the x-ua-compatible http header" do
get "/login"
response['x-ua-compatible'].should == "IE=Edge,chrome=1"
expect(response['x-ua-compatible']).to eq "IE=Edge,chrome=1"
end
it "should set no-cache headers for html requests" do
get "/login"
response['Pragma'].should match(/no-cache/)
response['Cache-Control'].should match(/must-revalidate/)
expect(response['Pragma']).to match(/no-cache/)
expect(response['Cache-Control']).to match(/must-revalidate/)
end
it "should NOT set no-cache headers for API/xhr requests" do
get "/api/v1/courses"
response['Pragma'].should be_nil
response['Cache-Control'].should_not match(/must-revalidate/)
expect(response['Pragma']).to be_nil
expect(response['Cache-Control']).not_to match(/must-revalidate/)
end
it "should set the x-frame-options http header" do
get "/login"
assigns[:files_domain].should be_false
response['x-frame-options'].should == "SAMEORIGIN"
expect(assigns[:files_domain]).to be_falsey
expect(response['x-frame-options']).to eq "SAMEORIGIN"
end
it "should not set x-frame-options when on a files domain" do
@ -61,7 +61,7 @@ describe "site-wide" do
attachment_model(:context => @user)
FilesController.any_instance.expects(:files_domain?).returns(true)
get "http://files-test.host/files/#{@attachment.id}/download"
response['x-frame-options'].should be_nil
expect(response['x-frame-options']).to be_nil
end
context "user headers" do
@ -81,36 +81,36 @@ describe "site-wide" do
it "should not set the logged in user headers when no one is logged in" do
get "/"
response['x-canvas-user-id'].should be_nil
response['x-canvas-real-user-id'].should be_nil
expect(response['x-canvas-user-id']).to be_nil
expect(response['x-canvas-real-user-id']).to be_nil
end
it "should set them when a user is logged in" do
user_session(@student, @student_pseudonym)
get "/"
response['x-canvas-user-id'].should == @student.global_id.to_s
response['x-canvas-real-user-id'].should be_nil
expect(response['x-canvas-user-id']).to eq @student.global_id.to_s
expect(response['x-canvas-real-user-id']).to be_nil
end
it "should set them when masquerading" do
user_session(@admin, @admin.pseudonyms.first)
post "/users/#{@student.id}/masquerade"
get "/"
response['x-canvas-user-id'].should == @student.global_id.to_s
response['x-canvas-real-user-id'].should == @admin.global_id.to_s
expect(response['x-canvas-user-id']).to eq @student.global_id.to_s
expect(response['x-canvas-real-user-id']).to eq @admin.global_id.to_s
end
end
context "breadcrumbs" do
it "should be absent for error pages" do
get "/apagethatdoesnotexist"
response.body.should_not match(%r{id="breadcrumbs"})
expect(response.body).not_to match(%r{id="breadcrumbs"})
end
it "should be absent for error pages with user info" do
course_with_teacher
get "/users/#{@user.id}/files/apagethatdoesnotexist"
response.body.to_s.should_not match(%r{id="breadcrumbs"})
expect(response.body.to_s).not_to match(%r{id="breadcrumbs"})
end
end

View File

@ -52,17 +52,17 @@ describe "user asset accesses" do
user_session(@student)
get "/courses/#{@course.id}/assignments/#{assignment.id}"
response.should be_success
expect(response).to be_success
user_session(@teacher)
get "/courses/#{@course.id}/users/#{@student.id}/usage"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#usage_report .access.assignment').length.should == 1
html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1'
html.css('#usage_report .access.assignment .view_score').text.strip.should == '1'
html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now)
AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now.to_i
expect(html.css('#usage_report .access.assignment').length).to eq 1
expect(html.css('#usage_report .access.assignment .readable_name').text.strip).to eq 'Assignment 1'
expect(html.css('#usage_report .access.assignment .view_score').text.strip).to eq '1'
expect(html.css('#usage_report .access.assignment .last_viewed').text.strip).to eq datetime_string(now)
expect(AssetUserAccess.where(:user_id => @student).first.last_access.to_i).to eq now.to_i
now2 = now + 1.hour
Time.stubs(:now).returns(now2)
@ -72,16 +72,16 @@ describe "user asset accesses" do
user_session(@student)
get "/courses/#{@course.id}/assignments/#{assignment.id}"
response.should be_success
expect(response).to be_success
user_session(@teacher)
get "/courses/#{@course.id}/users/#{@student.id}/usage"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#usage_report .access.assignment').length.should == 1
html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1'
html.css('#usage_report .access.assignment .view_score').text.strip.should == '2'
html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now2)
AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now2.to_i
expect(html.css('#usage_report .access.assignment').length).to eq 1
expect(html.css('#usage_report .access.assignment .readable_name').text.strip).to eq 'Assignment 1'
expect(html.css('#usage_report .access.assignment .view_score').text.strip).to eq '2'
expect(html.css('#usage_report .access.assignment .last_viewed').text.strip).to eq datetime_string(now2)
expect(AssetUserAccess.where(:user_id => @student).first.last_access.to_i).to eq now2.to_i
end
end

View File

@ -45,8 +45,8 @@ describe "assignments" do
course_with_teacher_logged_in(:course => @course, :active_all => true)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 2/)
expect(response).to be_success
expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 2/)
end
it "should correctly list ungraded and total submissions for ta" do
@ -59,8 +59,8 @@ describe "assignments" do
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 1/)
expect(response).to be_success
expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 1/)
end
it "should show student view student submission as needing grading" do
@ -71,8 +71,8 @@ describe "assignments" do
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 1/)
expect(response).to be_success
expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 1/)
end
describe "due date overrides" do
@ -90,8 +90,8 @@ describe "assignments" do
get "courses/#{@course.id}/assignments/#{@assignment.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should include "Everyone"
doc.css(".assignment_dates").text.should_not include "Everyone else"
expect(doc.css(".assignment_dates").text).to include "Everyone"
expect(doc.css(".assignment_dates").text).not_to include "Everyone else"
end
it "should show 'Everyone else' when some sections have due date overrides" do
@ -101,7 +101,7 @@ describe "assignments" do
get "courses/#{@course.id}/assignments/#{@assignment.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should include "Everyone else"
expect(doc.css(".assignment_dates").text).to include "Everyone else"
end
it "should not show 'Everyone else' when all sections have due date overrides" do
@ -112,7 +112,7 @@ describe "assignments" do
get "courses/#{@course.id}/assignments/#{@assignment.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should_not include "Everyone"
expect(doc.css(".assignment_dates").text).not_to include "Everyone"
end
end
end
@ -139,20 +139,20 @@ describe "download submissions link" do
it "should not show download submissions button with no submissions" do
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#download_submission_button').should be_nil
expect(doc.at_css('#download_submission_button')).to be_nil
end
it "should show download submissions button with submission not graded" do
@submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url')
@submission.state.should eql(:submitted)
expect(@submission.state).to eql(:submitted)
@submission.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#download_submission_button').should_not be_nil
expect(doc.at_css('#download_submission_button')).not_to be_nil
end
it "should show download submissions button with a submission graded" do
@ -161,13 +161,13 @@ describe "download submissions link" do
@submission.grade_it
@submission.score = 5
@submission.save!
@submission.state.should eql(:graded)
expect(@submission.state).to eql(:graded)
@submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url')
@submission2.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#download_submission_button').should_not be_nil
expect(doc.at_css('#download_submission_button')).not_to be_nil
end
it "should show download submissions button with all submissions graded" do
@ -176,28 +176,28 @@ describe "download submissions link" do
@submission.grade_it
@submission.score = 5
@submission.save!
@submission.state.should eql(:graded)
expect(@submission.state).to eql(:graded)
@submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url')
@submission2.grade_it
@submission2.score = 5
@submission2.save!
@submission2.state.should eql(:graded)
expect(@submission2.state).to eql(:graded)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#download_submission_button').should_not be_nil
expect(doc.at_css('#download_submission_button')).not_to be_nil
end
it "should not show download submissions button to students" do
@submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url')
@submission.state.should eql(:submitted)
expect(@submission.state).to eql(:submitted)
@submission.save!
user_session(@student)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#download_submission_button').should be_nil
expect(doc.at_css('#download_submission_button')).to be_nil
end
end
@ -224,23 +224,23 @@ describe "ratio of submissions graded" do
it "should not show ratio of submissions graded with no submissions" do
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#ratio_of_submissions_graded').should be_nil
expect(doc.at_css('#ratio_of_submissions_graded')).to be_nil
end
it "should show ratio of submissions graded with submission not graded" do
@submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url')
@submission.save!
@submission.state.should eql(:submitted)
expect(@submission.state).to eql(:submitted)
@submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url')
@submission2.state.should eql(:submitted)
expect(@submission2.state).to eql(:submitted)
@submission2.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#ratio_of_submissions_graded').text.strip.should == "0 out of 2 Submissions Graded"
expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "0 out of 2 Submissions Graded"
end
it "should show ratio of submissions graded with a submission graded" do
@ -249,14 +249,14 @@ describe "ratio of submissions graded" do
@submission.grade_it
@submission.score = 5
@submission.save!
@submission.state.should eql(:graded)
expect(@submission.state).to eql(:graded)
@submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url')
@submission2.state.should eql(:submitted)
expect(@submission2.state).to eql(:submitted)
@submission2.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#ratio_of_submissions_graded').text.strip.should == "1 out of 2 Submissions Graded"
expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "1 out of 2 Submissions Graded"
end
it "should show ratio of submissions graded with all submissions graded" do
@ -266,28 +266,28 @@ describe "ratio of submissions graded" do
@submission.grade_it
@submission.score = 5
@submission.save!
@submission.state.should eql(:graded)
expect(@submission.state).to eql(:graded)
@submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url')
@submission2.grade_it
@submission2.score = 5
@submission2.save!
@submission2.state.should eql(:graded)
expect(@submission2.state).to eql(:graded)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#ratio_of_submissions_graded').text.strip.should == "2 out of 2 Submissions Graded"
expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "2 out of 2 Submissions Graded"
end
it "should not show ratio of submissions graded to students" do
@submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url')
@submission.state.should eql(:submitted)
expect(@submission.state).to eql(:submitted)
@submission.save!
user_session(@student)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('#ratio_of_submissions_graded').should be_nil
expect(doc.at_css('#ratio_of_submissions_graded')).to be_nil
end
end

View File

@ -35,19 +35,19 @@ describe CollaborationsController, type: :request do
)
get "/courses/#{@course.id}/collaborations/"
response.should be_success
expect(response).to be_success
post "/courses/#{@course.id}/collaborations/", { :collaboration => { :collaboration_type => "EtherPad", :title => "My Collab" } }
response.should be_redirect
expect(response).to be_redirect
get "/courses/#{@course.id}/collaborations/"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
links = html.css("div.collaboration_#{Collaboration.last.id} a.collaborator_link")
links.count.should == 1
expect(links.count).to eq 1
link = links.first
link.attr("href").should == "/courses/#{@course.id}/users/#{@teacher.id}"
link.text.should == "teacher 1"
expect(link.attr("href")).to eq "/courses/#{@course.id}/users/#{@teacher.id}"
expect(link.text).to eq "teacher 1"
end
end

View File

@ -39,76 +39,76 @@ describe "concluded/unconcluded courses" do
@group = @course.assignment_groups.create!(:name => "default")
@assignment = @course.assignments.create!(:submission_types => 'online_quiz', :title => 'quiz assignment', :assignment_group => @group)
@quiz = @assignment.reload.quiz
@quiz.should_not be_nil
expect(@quiz).not_to be_nil
@qsub = Quizzes::SubmissionManager.new(@quiz).find_or_create_submission(@student)
@qsub.quiz_data = [{:correct_comments=>"", :assessment_question_id=>nil, :incorrect_comments=>"", :question_name=>"Question 1", :points_possible=>1, :question_text=>"Which book(s) are required for this course?", :name=>"Question 1", :id=>128, :answers=>[{:weight=>0, :text=>"A", :comments=>"", :id=>1490}, {:weight=>0, :text=>"B", :comments=>"", :id=>1020}, {:weight=>0, :text=>"C", :comments=>"", :id=>7051}], :question_type=>"multiple_choice_question"}]
@qsub.submission_data = [{:points=>0, :text=>"7051", :question_id=>128, :correct=>false, :answer_id=>7051}]
@qsub.workflow_state = 'complete'
@qsub.save!
@sub = @qsub.submission
@sub.should_not be_nil
expect(@sub).not_to be_nil
end
it "should let the teacher change grades in the speed grader by default" do
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#add_a_comment').length.should == 1
html.css('#grade_container').length.should == 1
expect(html.css('#add_a_comment').length).to eq 1
expect(html.css('#grade_container').length).to eq 1
end
it "should not let the teacher change grades in the speed grader when concluded" do
@e.conclude
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#add_a_comment').length.should == 0
html.css('#grade_container').length.should == 0
expect(html.css('#add_a_comment').length).to eq 0
expect(html.css('#grade_container').length).to eq 0
end
it "should let the teacher change grades on the submission details page by default" do
get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('.submission_details .grading_box').length.should == 1
html.css('#add_comment_form').length.should == 1
expect(html.css('.submission_details .grading_box').length).to eq 1
expect(html.css('#add_comment_form').length).to eq 1
end
it "should not let the teacher change grades on the submission details page when concluded" do
@e.conclude
get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('.submission_details .grading_box').length.should == 0
html.css('#add_comment_form')[0]['style'].should match(/display: none/)
expect(html.css('.submission_details .grading_box').length).to eq 0
expect(html.css('#add_comment_form')[0]['style']).to match(/display: none/)
end
it "should let the teacher change quiz submission scores by default" do
get "/courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@qsub.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#fudge_points_entry').length.should == 1
html.css('.quiz_comment textarea').length.should == 1
html.css('.user_points .question_input').length.should == 1
expect(html.css('#fudge_points_entry').length).to eq 1
expect(html.css('.quiz_comment textarea').length).to eq 1
expect(html.css('.user_points .question_input').length).to eq 1
end
it "should not let the teacher change quiz submission scores when concluded" do
@e.conclude
get "/courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@qsub.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#fudge_points_entry').length.should == 0
html.css('.quiz_comment textarea').length.should == 0
html.css('.user_points .question_input').length.should == 0
expect(html.css('#fudge_points_entry').length).to eq 0
expect(html.css('.quiz_comment textarea').length).to eq 0
expect(html.css('.user_points .question_input').length).to eq 0
end
end

View File

@ -34,15 +34,15 @@ describe ConferencesController, type: :request do
@student2.register!
post "/courses/#{@course.id}/conferences", { :web_conference => {"duration"=>"60", "conference_type"=>"Wimba", "title"=>"let's chat", "description"=>""}, :user => { "all" => "1" } }
response.should be_redirect
expect(response).to be_redirect
@conference = WebConference.first
Set.new(Message.all.map(&:user)).should == Set.new([@teacher, @student1, @student2])
expect(Set.new(Message.all.map(&:user))).to eq Set.new([@teacher, @student1, @student2])
@student3 = student_in_course(:active_all => true, :user => user_with_pseudonym(:username => "student3@example.com")).user
@student3.register!
put "/courses/#{@course.id}/conferences/#{@conference.id}", { :web_conference => { "title" => "moar" }, :user => { @student3.id => '1' } }
response.should be_redirect
Set.new(Message.all.map(&:user)).should == Set.new([@teacher, @student1, @student2, @student3])
expect(response).to be_redirect
expect(Set.new(Message.all.map(&:user))).to eq Set.new([@teacher, @student1, @student2, @student3])
end
it "should find the correct conferences for group news feed" do
@ -56,8 +56,8 @@ describe ConferencesController, type: :request do
group_conference.add_initiator(@user)
get "/courses/#{@course.id}/groups/#{@group.id}"
response.should be_success
assigns['current_conferences'].map(&:id).should == [group_conference.id]
expect(response).to be_success
expect(assigns['current_conferences'].map(&:id)).to eq [group_conference.id]
end
it "shouldn't show concluded users" do
@ -71,14 +71,14 @@ describe ConferencesController, type: :request do
@student2 = @enroll2.user
@student2.register!
@enroll1.attributes['workflow_state'].should == 'active'
@enroll2.attributes['workflow_state'].should == 'active'
expect(@enroll1.attributes['workflow_state']).to eq 'active'
expect(@enroll2.attributes['workflow_state']).to eq 'active'
@enroll2.update_attributes('workflow_state' => 'completed')
@enroll2.attributes['workflow_state'].should == 'completed'
expect(@enroll2.attributes['workflow_state']).to eq 'completed'
get "/courses/#{@course.id}/conferences"
assigns['users'].member?(@teacher).should be_false
assigns['users'].member?(@student1).should be_true
assigns['users'].member?(@student2).should be_false
expect(assigns['users'].member?(@teacher)).to be_falsey
expect(assigns['users'].member?(@student1)).to be_truthy
expect(assigns['users'].member?(@student2)).to be_falsey
end
end

View File

@ -8,17 +8,17 @@ describe ContentZipper do
# This really needs to get refactored at some point.
def grab_zip
expect { yield }.to change(Delayed::Job, :count).by(1)
response.should be_success
expect(response).to be_success
attachment_id = json_parse['attachment']['id']
attachment_id.should be_present
expect(attachment_id).to be_present
a = Attachment.find attachment_id
a.should be_to_be_zipped
expect(a).to be_to_be_zipped
# a second query should just return status
expect { yield }.to change(Delayed::Job, :count).by(0)
response.should be_success
json_parse['attachment']['id'].should == a.id
expect(response).to be_success
expect(json_parse['attachment']['id']).to eq a.id
end
context "submission zips" do

View File

@ -29,14 +29,14 @@ describe ContextModule do
course_with_teacher_logged_in active_all: true
get "/courses/#{@course.id}/modules"
doc = Nokogiri::HTML(response.body)
doc.at_css('.context-modules-main-toolbar .add_module_link').should_not be_nil
expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).not_to be_nil
@course.account.role_overrides.create! enrollment_type: 'TaEnrollment', permission: 'manage_content', enabled: false
course_with_ta course: @course
user_session(@ta)
get "/courses/#{@course.id}/modules"
doc = Nokogiri::HTML(response.body)
doc.at_css('.context-modules-main-toolbar .add_module_link').should be_nil
expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).to be_nil
end
end
@ -47,12 +47,12 @@ describe ContextModule do
content_tag = context_module.add_item :type => 'context_module_sub_header', :title => "My Sub Header Title"
ContextModule.where(:id => context_module).update_all(:updated_at => 1.hour.ago)
get "/courses/#{@course.id}/modules"
response.body.should match(/My Sub Header Title/)
expect(response.body).to match(/My Sub Header Title/)
content_tag.update_attributes(:title => "My New Title")
get "/courses/#{@course.id}/modules"
response.body.should match(/My New Title/)
expect(response.body).to match(/My New Title/)
end
end
@ -68,14 +68,14 @@ describe ContextModule do
@module.save!
@progression = @module.evaluate_for(@user)
@progression.should_not be_nil
@progression.should_not be_completed
@progression.should be_unlocked
@progression.current_position.should eql(@tag.position)
expect(@progression).not_to be_nil
expect(@progression).not_to be_completed
expect(@progression).to be_unlocked
expect(@progression.current_position).to eql(@tag.position)
yield
@progression = @module.evaluate_for(@user)
@progression.should be_completed
@progression.current_position.should eql(@tag.position)
expect(@progression).to be_completed
expect(@progression.current_position).to eql(@tag.position)
end
it "should progress for discussions" do
@ -83,7 +83,7 @@ describe ContextModule do
@tag = @module.add_item(:type => 'discussion_topic', :id => @discussion.id)
before_after do
post "/courses/#{@course.id}/discussion_entries", :discussion_entry => { :message => 'ohai', :discussion_topic_id => @discussion.id }
response.should be_redirect
expect(response).to be_redirect
end
end
@ -92,7 +92,7 @@ describe ContextModule do
@tag = @module.add_item(:type => 'wiki_page', :id => @page.id)
before_after do
put "/courses/#{@course.id}/wiki/#{@page.url}", :wiki_page => { :body => 'i agree', :title => 'talk page' }
response.should be_redirect
expect(response).to be_redirect
end
end
@ -101,7 +101,7 @@ describe ContextModule do
@tag = @module.add_item(:type => 'assignment', :id => @assignment.id)
before_after do
post "/courses/#{@course.id}/discussion_entries", :discussion_entry => { :message => 'ohai', :discussion_topic_id => @assignment.discussion_topic.id }
response.should be_redirect
expect(response).to be_redirect
end
end
end
@ -131,23 +131,23 @@ describe ContextModule do
end
# all modules, tags, etc need to be published
@mod1.should be_published
@mod2.should be_published
@quiz.should be_published
@tag1.should be_published
expect(@mod1).to be_published
expect(@mod2).to be_published
expect(@quiz).to be_published
expect(@tag1).to be_published
yield '<div id="test_content">yay!</div>'
@tag2.should be_published
expect(@tag2).to be_published
# verify the second item is locked (doesn't display)
get @test_url
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#test_content').length.should == (@test_content_length || 0)
expect(html.css('#test_content').length).to eq(@test_content_length || 0)
# complete first module's requirements
p1 = @mod1.evaluate_for(@student)
p1.workflow_state.should == 'unlocked'
expect(p1.workflow_state).to eq 'unlocked'
@quiz_submission = @quiz.generate_submission(@student)
Quizzes::SubmissionGrader.new(@quiz_submission).grade_submission
@ -161,17 +161,17 @@ describe ContextModule do
"/courses/#{@course.id}/modules/items/#{@tag2.id}" :
"/courses/#{@course.id}/modules/#{@mod2.id}/items/first"
get next_link
response.should be_redirect
response.location.ends_with?(@test_url + "?module_item_id=#{@tag2.id}").should be_true
expect(response).to be_redirect
expect(response.location.ends_with?(@test_url + "?module_item_id=#{@tag2.id}")).to be_truthy
# verify the second item is accessible
get @test_url
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
if @is_attachment
html.at_css('#file_content')['src'].should =~ %r{#{@test_url}}
expect(html.at_css('#file_content')['src']).to match %r{#{@test_url}}
else
html.css('#test_content').length.should == 1
expect(html.css('#test_content').length).to eq 1
end
end
end
@ -182,7 +182,7 @@ describe ContextModule do
asmnt = @course.assignments.create!(:title => 'assignment', :description => content)
@test_url = "/courses/#{@course.id}/assignments/#{asmnt.id}"
@tag2 = @mod2.add_item(:type => 'assignment', :id => asmnt.id)
@tag2.should be_published
expect(@tag2).to be_published
end
end
end
@ -193,7 +193,7 @@ describe ContextModule do
discussion = @course.discussion_topics.create!(:title => "topic", :message => content)
@test_url = "/courses/#{@course.id}/discussion_topics/#{discussion.id}"
@tag2 = @mod2.add_item(:type => 'discussion_topic', :id => discussion.id)
@tag2.should be_published
expect(@tag2).to be_published
@test_content_length = 1
end
end
@ -206,7 +206,7 @@ describe ContextModule do
quiz.publish!
@test_url = "/courses/#{@course.id}/quizzes/#{quiz.id}"
@tag2 = @mod2.add_item(:type => 'quiz', :id => quiz.id)
@tag2.should be_published
expect(@tag2).to be_published
end
end
end
@ -217,7 +217,7 @@ describe ContextModule do
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => content)
@test_url = "/courses/#{@course.id}/wiki/#{page.url}"
@tag2 = @mod2.add_item(:type => 'wiki_page', :id => page.id)
@tag2.should be_published
expect(@tag2).to be_published
end
end
end
@ -229,7 +229,7 @@ describe ContextModule do
att = Attachment.create!(:filename => 'test.html', :display_name => "test.html", :uploaded_data => StringIO.new(content), :folder => Folder.unfiled_folder(@course), :context => @course)
@test_url = "/courses/#{@course.id}/files/#{att.id}"
@tag2 = @mod2.add_item(:type => 'attachment', :id => att.id)
@tag2.should be_published
expect(@tag2).to be_published
end
end
end
@ -255,16 +255,16 @@ describe ContextModule do
user_session teacher1
get "/courses/#{@course.id}/modules"
response.should be_success
expect(response).to be_success
body1 = Nokogiri::HTML(response.body)
user_session teacher2
get "/courses/#{@course.id}/modules"
response.should be_success
expect(response).to be_success
body2 = Nokogiri::HTML(response.body)
body1.at_css("#context_module_content_#{mod.id} .unlock_details").text.should =~ /4am/
body2.at_css("#context_module_content_#{mod.id} .unlock_details").text.should =~ /7am/
expect(body1.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /4am/
expect(body2.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /7am/
end
end
end

View File

@ -26,14 +26,14 @@ describe "course" do
course(:active_all => true)
@course.update_attribute(:is_public, true)
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
end
it "should load syllabus on public course with no user logged in" do
course(:active_all => true)
@course.update_attribute(:is_public, true)
get "/courses/#{@course.id}/assignments/syllabus"
response.should be_success
expect(response).to be_success
end
it "should show the migration-in-progress notice" do
@ -46,15 +46,15 @@ describe "course" do
migration.update_attribute(:workflow_state, 'importing')
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
body = Nokogiri::HTML(response.body)
body.css('div.import-in-progress-notice').should_not be_empty
expect(body.css('div.import-in-progress-notice')).not_to be_empty
migration.update_attribute(:workflow_state, 'imported')
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
body = Nokogiri::HTML(response.body)
body.css('div.import-in-progress-notice').should be_empty
expect(body.css('div.import-in-progress-notice')).to be_empty
end
end
@ -69,9 +69,9 @@ describe "course" do
migration.update_attribute(:workflow_state, 'importing')
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
body = Nokogiri::HTML(response.body)
body.css('div.import-in-progress-notice').should be_empty
expect(body.css('div.import-in-progress-notice')).to be_empty
end
end
end

View File

@ -32,7 +32,7 @@ describe CoursesController, type: :request do
@course.reload
user_session(ta)
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
# We do a page load before the test because something during the first load
# will touch the course, invalidating the cache anyway and making this test
@ -41,16 +41,16 @@ describe CoursesController, type: :request do
original_course_updated_at = @course.reload.updated_at
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
page = Nokogiri::HTML(response.body)
page.css(".wizard_options_list li.publish_step").length.should == 0
expect(page.css(".wizard_options_list li.publish_step").length).to eq 0
user_session(teacher)
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
page = Nokogiri::HTML(response.body)
page.css(".wizard_options_list li.publish_step").length.should == 1
@course.reload.updated_at.should == original_course_updated_at
expect(page.css(".wizard_options_list li.publish_step").length).to eq 1
expect(@course.reload.updated_at).to eq original_course_updated_at
end
end
end

View File

@ -54,7 +54,7 @@ describe "cross listing" do
"X1,S2,active",
"C4,S3,active")
CommunicationChannel.find_by_path('u1@example.com').user.cached_current_enrollments.map(&:course).map(&:sis_source_id).sort.should == ["C1", "X1", "C4"].sort
expect(CommunicationChannel.find_by_path('u1@example.com').user.cached_current_enrollments.map(&:course).map(&:sis_source_id).sort).to eq ["C1", "X1", "C4"].sort
end
end

View File

@ -30,13 +30,13 @@ describe "discussion_topics" do
@group.users << @user
get "/groups/#{@group.id}/discussion_topics/#{@topic.id}"
response.should be_success
expect(response).to be_success
post "/groups/#{@group.id}/discussion_entries", :discussion_entry => { :discussion_topic_id => @topic.id, :message => "frist!!1" }
response.should be_redirect
expect(response).to be_redirect
get "/groups/#{@group.id}/discussion_topics/#{@topic.id}"
response.should be_success
expect(response).to be_success
end
it "should show speed grader button" do
@ -44,9 +44,9 @@ describe "discussion_topics" do
discussion_assignment
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('.admin-links .icon-speed-grader').should_not be_nil
expect(doc.at_css('.admin-links .icon-speed-grader')).not_to be_nil
end
it "should show peer reviews button" do
@ -56,9 +56,9 @@ describe "discussion_topics" do
@assignment.save
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::XML(response.body)
doc.at_css('.admin-links .icon-peer-review').should_not be_nil
expect(doc.at_css('.admin-links .icon-peer-review')).not_to be_nil
end
end

View File

@ -28,28 +28,28 @@ describe "enrollment_date_restrictions" do
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => true)
e2 = student_in_course(:user => @student, :active_all => 1)
e1.state.should == :active
e1.state_based_on_date.should == :active
e2.state.should == :active
e2.state_based_on_date.should == :inactive
expect(e1.state).to eq :active
expect(e1.state_based_on_date).to eq :active
expect(e2.state).to eq :active
expect(e2.state_based_on_date).to eq :inactive
user_session(@student, @pseudonym)
get "/"
page = Nokogiri::HTML(response.body)
list = page.css(".menu-item-drop-column-list li")
list.length.should == 1
list[0].text.should match /Course 1/
page.css(".menu-item-drop-padded").should be_empty
expect(list.length).to eq 1
expect(list[0].text).to match /Course 1/
expect(page.css(".menu-item-drop-padded")).to be_empty
get "/courses"
page = Nokogiri::HTML(response.body)
active_enrollments = page.css(".current_enrollments tr")
active_enrollments.length.should == 1
expect(active_enrollments.length).to eq 1
# Make sure that the active coures have the star column.
active_enrollments[0].css('td')[0]['class'].should match /star-column/
expect(active_enrollments[0].css('td')[0]['class']).to match /star-column/
page.css(".past_enrollments tr").should be_empty
expect(page.css(".past_enrollments tr")).to be_empty
end
it "should not show deleted enrollments in past enrollments when course is completed" do
@ -57,16 +57,16 @@ describe "enrollment_date_restrictions" do
e1 = student_in_course(:user => @student, :active_all => 1)
e1.destroy
e1.workflow_state.should == 'deleted'
expect(e1.workflow_state).to eq 'deleted'
@course.complete
@course.workflow_state.should == 'completed'
expect(@course.workflow_state).to eq 'completed'
user_session(@student, @pseudonym)
get "/courses"
page = Nokogiri::HTML(response.body)
page.css(".past_enrollments tr").should be_empty
expect(page.css(".past_enrollments tr")).to be_empty
end
it "should not list groups from inactive enrollments in the menu" do
@ -90,10 +90,10 @@ describe "enrollment_date_restrictions" do
list = page.css(".menu-item-drop-column-list li").to_a
# course lis are still there and view all groups should always show up when
# there's at least one 'visible' group
list.size.should == 3
list.select{ |li| li.text =~ /Group 1/ }.should_not be_empty
list.select{ |li| li.text =~ /View all groups/ }.should_not be_empty
list.select{ |li| li.text =~ /Group 2/ }.should be_empty
expect(list.size).to eq 3
expect(list.select{ |li| li.text =~ /Group 1/ }).not_to be_empty
expect(list.select{ |li| li.text =~ /View all groups/ }).not_to be_empty
expect(list.select{ |li| li.text =~ /Group 2/ }).to be_empty
end
it "should not show date inactive/completed courses in grades" do
@ -121,13 +121,13 @@ describe "enrollment_date_restrictions" do
get '/grades'
html = Nokogiri::HTML(response.body)
html.css('.course').length.should == 2
expect(html.css('.course').length).to eq 2
Account.default.account_users.create!(user: @user)
get "/users/#{@user.id}"
response.body.should match /Inactive/
response.body.should match /Completed/
response.body.should match /Active/
expect(response.body).to match /Inactive/
expect(response.body).to match /Completed/
expect(response.body).to match /Active/
end
it "should not included date-inactive courses when searching for pertinent contexts" do
@ -139,10 +139,10 @@ describe "enrollment_date_restrictions" do
@course.conclude_at = 4.days.from_now
@course.restrict_enrollments_to_course_dates = true
@course.save!
@enrollment.reload.state_based_on_date.should == :inactive
expect(@enrollment.reload.state_based_on_date).to eq :inactive
get '/calendar2'
html = Nokogiri::HTML(response.body)
html.css(".group_course_#{@course.id}").length.should == 0
expect(html.css(".group_course_#{@course.id}").length).to eq 0
end
end

View File

@ -33,18 +33,18 @@ describe "External Tools" do
student_in_course(:course => @course, :active_all => true)
user_session(@user)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
form = doc.at_css('form#tool_form')
form.at_css('input#launch_presentation_locale')['value'].should == 'en'
form.at_css('input#oauth_callback')['value'].should == 'about:blank'
form.at_css('input#oauth_signature_method')['value'].should == 'HMAC-SHA1'
form.at_css('input#launch_presentation_return_url')['value'].should == "http://www.example.com/external_content/success/external_tool_redirect"
form.at_css('input#lti_message_type')['value'].should == "basic-lti-launch-request"
form.at_css('input#lti_version')['value'].should == "LTI-1p0"
form.at_css('input#oauth_version')['value'].should == "1.0"
form.at_css('input#roles')['value'].should == "Learner"
expect(form.at_css('input#launch_presentation_locale')['value']).to eq 'en'
expect(form.at_css('input#oauth_callback')['value']).to eq 'about:blank'
expect(form.at_css('input#oauth_signature_method')['value']).to eq 'HMAC-SHA1'
expect(form.at_css('input#launch_presentation_return_url')['value']).to eq "http://www.example.com/external_content/success/external_tool_redirect"
expect(form.at_css('input#lti_message_type')['value']).to eq "basic-lti-launch-request"
expect(form.at_css('input#lti_version')['value']).to eq "LTI-1p0"
expect(form.at_css('input#oauth_version')['value']).to eq "1.0"
expect(form.at_css('input#roles')['value']).to eq "Learner"
end
it "should include outcome service params when viewing as student" do
@ -54,22 +54,22 @@ describe "External Tools" do
payload = [@tool.id, @course.id, @assignment.id, @user.id].join('-')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('form#tool_form input#lis_result_sourcedid')['value'].should == "#{payload}-some_sha"
doc.at_css('form#tool_form input#lis_outcome_service_url')['value'].should == lti_grade_passback_api_url(@tool)
doc.at_css('form#tool_form input#ext_ims_lis_basic_outcome_url')['value'].should == blti_legacy_grade_passback_api_url(@tool)
expect(doc.at_css('form#tool_form input#lis_result_sourcedid')['value']).to eq "#{payload}-some_sha"
expect(doc.at_css('form#tool_form input#lis_outcome_service_url')['value']).to eq lti_grade_passback_api_url(@tool)
expect(doc.at_css('form#tool_form input#ext_ims_lis_basic_outcome_url')['value']).to eq blti_legacy_grade_passback_api_url(@tool)
end
it "should not include outcome service sourcedid when viewing as teacher" do
@course.enroll_teacher(user(:active_all => true))
user_session(@user)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('form#tool_form input#lis_result_sourcedid').should be_nil
doc.at_css('form#tool_form input#lis_outcome_service_url').should_not be_nil
expect(doc.at_css('form#tool_form input#lis_result_sourcedid')).to be_nil
expect(doc.at_css('form#tool_form input#lis_outcome_service_url')).not_to be_nil
end
it "should include time zone in LTI paramaters if included in custom fields" do
@ -85,17 +85,17 @@ describe "External Tools" do
account.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "America/Juneau"
expect(doc.at_css('form#tool_form input#custom_time_zone')['value']).to eq "America/Juneau"
@user.time_zone = "Hawaii"
@user.save!
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "Pacific/Honolulu"
expect(doc.at_css('form#tool_form input#custom_time_zone')['value']).to eq "Pacific/Honolulu"
end
it "should redirect if the tool can't be configured" do
@ -104,18 +104,18 @@ describe "External Tools" do
student_in_course(:active_all => true)
user_session(@user)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
response.should redirect_to(course_url(@course))
flash[:error].should be_present
expect(response).to redirect_to(course_url(@course))
expect(flash[:error]).to be_present
end
it "should render inline external tool links with a full return url" do
student_in_course(:active_all => true)
user_session(@user)
get "/courses/#{@course.id}/external_tools/retrieve?url=#{CGI.escape(@tag.url)}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('#tool_form').should_not be_nil
doc.at_css("input[name='launch_presentation_return_url']")['value'].should match(/^http/)
expect(doc.at_css('#tool_form')).not_to be_nil
expect(doc.at_css("input[name='launch_presentation_return_url']")['value']).to match(/^http/)
end
it "should render user navigation tools with a full return url" do
@ -126,10 +126,10 @@ describe "External Tools" do
student_in_course(:active_all => true)
user_session(@user)
get "/users/#{@user.id}/external_tools/#{tool.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
doc.at_css('#tool_form').should_not be_nil
doc.at_css("input[name='launch_presentation_return_url']")['value'].should match(/^http/)
expect(doc.at_css('#tool_form')).not_to be_nil
expect(doc.at_css("input[name='launch_presentation_return_url']")['value']).to match(/^http/)
end
end
@ -142,11 +142,11 @@ describe "External Tools" do
@tool.save!
get "/courses/#{@course.id}/external_tools/#{@tool.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
tab = doc.at_css("a.#{@tool.asset_string}")
tab.should_not be_nil
tab['class'].split.should include("active")
expect(tab).not_to be_nil
expect(tab['class'].split).to include("active")
end
it "should highlight the navigation tab when using an external tool" do
@ -157,11 +157,11 @@ describe "External Tools" do
@tool.save!
get "/courses/#{@course.id}/external_tools/#{@tool.id}"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
tab = doc.at_css("a.#{@tool.asset_string}")
tab.should_not be_nil
tab['class'].split.should include("active")
expect(tab).not_to be_nil
expect(tab['class'].split).to include("active")
end
context 'global navigation' do
@ -178,33 +178,33 @@ describe "External Tools" do
it "should show the admin level global navigation menu items to teachers" do
course_with_teacher_logged_in(:account => @account, :active_all => true)
get "/courses"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
menu_link1 = doc.at_css("##{@admin_tool.asset_string}_menu_item a")
menu_link1.should_not be_nil
menu_link1['href'].should == account_external_tool_path(Account.default, @admin_tool, :launch_type => 'global_navigation')
menu_link1.text.should match_ignoring_whitespace(@admin_tool.label_for(:global_navigation))
expect(menu_link1).not_to be_nil
expect(menu_link1['href']).to eq account_external_tool_path(Account.default, @admin_tool, :launch_type => 'global_navigation')
expect(menu_link1.text).to match_ignoring_whitespace(@admin_tool.label_for(:global_navigation))
menu_link2 = doc.at_css("##{@member_tool.asset_string}_menu_item a")
menu_link2.should_not be_nil
menu_link2['href'].should == account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation')
menu_link2.text.should match_ignoring_whitespace(@member_tool.label_for(:global_navigation))
expect(menu_link2).not_to be_nil
expect(menu_link2['href']).to eq account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation')
expect(menu_link2.text).to match_ignoring_whitespace(@member_tool.label_for(:global_navigation))
end
it "should only show the member level global navigation menu items to students" do
course_with_student_logged_in(:account => @account, :active_all => true)
get "/courses"
response.should be_success
expect(response).to be_success
doc = Nokogiri::HTML.parse(response.body)
menu_link1 = doc.at_css("##{@admin_tool.asset_string}_menu_item a")
menu_link1.should be_nil
expect(menu_link1).to be_nil
menu_link2 = doc.at_css("##{@member_tool.asset_string}_menu_item a")
menu_link2.should_not be_nil
menu_link2['href'].should == account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation')
menu_link2.text.should match_ignoring_whitespace(@member_tool.label_for(:global_navigation))
expect(menu_link2).not_to be_nil
expect(menu_link2['href']).to eq account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation')
expect(menu_link2.text).to match_ignoring_whitespace(@member_tool.label_for(:global_navigation))
end
end
end

View File

@ -15,30 +15,30 @@ describe FilesController do
it "with safefiles" do
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/files/#{@submission.attachment.id}/download", :inline => '1', :verifier => @submission.attachment.uuid
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/files/#{@submission.attachment.id}/download"
@me.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true
qs['verifier'].should == @submission.attachment.uuid
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/files/#{@submission.attachment.id}/download"
expect(@me.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy
expect(qs['verifier']).to eq @submission.attachment.uuid
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
it "without safefiles" do
HostUrl.stubs(:file_host_with_shard).returns(['test.host', Shard.default])
get "http://test.host/files/#{@submission.attachment.id}/download", :inline => '1', :verifier => @submission.attachment.uuid
response.should be_success
response.content_type.should == 'image/png'
response['Pragma'].should be_nil
response['Cache-Control'].should_not match(/no-cache/)
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
expect(response['Pragma']).to be_nil
expect(response['Cache-Control']).not_to match(/no-cache/)
end
end
@ -54,30 +54,30 @@ describe FilesController do
it "with safefiles" do
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/users/#{@me.id}/files/#{@att.id}/download"
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
expect(uri.host).to eq 'files-test.host'
# redirects to a relative url, since relative files are available in user context
uri.path.should == "/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/my-pic.png"
@me.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true
expect(uri.path).to eq "/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/my-pic.png"
expect(@me.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
it "without safefiles" do
HostUrl.stubs(:file_host).returns('test.host')
get "http://test.host/users/#{@me.id}/files/#{@att.id}/download"
response.should be_success
response.content_type.should == 'image/png'
response['Pragma'].should be_nil
response['Cache-Control'].should_not match(/no-cache/)
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
expect(response['Pragma']).to be_nil
expect(response['Cache-Control']).not_to match(/no-cache/)
end
context "with inlineable html files" do
@ -88,39 +88,39 @@ describe FilesController do
it "with safefiles" do
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/users/#{@me.id}/files/#{@att.id}/download", :wrap => '1'
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'test.host'
uri.path.should == "/users/#{@me.id}/files/#{@att.id}"
expect(uri.host).to eq 'test.host'
expect(uri.path).to eq "/users/#{@me.id}/files/#{@att.id}"
location = response['Location']
get location
# the response will be on the main domain, with an iframe pointing to the files domain and the actual uploaded html file
response.should be_success
response.content_type.should == 'text/html'
expect(response).to be_success
expect(response.content_type).to eq 'text/html'
doc = Nokogiri::HTML::DocumentFragment.parse(response.body)
doc.at_css('iframe#file_content')['src'].should =~ %r{^http://files-test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html}
expect(doc.at_css('iframe#file_content')['src']).to match %r{^http://files-test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html}
end
it "without safefiles" do
HostUrl.stubs(:file_host_with_shard).returns(['test.host', Shard.default])
get "http://test.host/users/#{@me.id}/files/#{@att.id}/download", :wrap => '1'
response.should be_redirect
expect(response).to be_redirect
location = response['Location']
URI.parse(location).path.should == "/users/#{@me.id}/files/#{@att.id}"
expect(URI.parse(location).path).to eq "/users/#{@me.id}/files/#{@att.id}"
get location
response.content_type.should == 'text/html'
expect(response.content_type).to eq 'text/html'
doc = Nokogiri::HTML::DocumentFragment.parse(response.body)
doc.at_css('iframe#file_content')['src'].should =~ %r{^http://test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html}
expect(doc.at_css('iframe#file_content')['src']).to match %r{^http://test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html}
end
it "should not inline the file if passed download_frd param" do
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/users/#{@me.id}/files/#{@att.id}/download?download_frd=1&verifier=#{@att.uuid}"
response.should be_redirect
expect(response).to be_redirect
get response['Location']
response.headers['Content-Disposition'].should match /attachment/
expect(response.headers['Content-Disposition']).to match /attachment/
end
end
@ -133,43 +133,43 @@ describe FilesController do
a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course)
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/courses/#{@course.id}/files/#{a1.id}/download", :inline => '1'
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
@user.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true
qs['verifier'].should be_nil
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
expect(@user.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy
expect(qs['verifier']).to be_nil
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
it "should be able to use verifier in course context" do
course_with_teacher(:active_all => true, :user => user_with_pseudonym)
a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course)
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/courses/#{@course.id}/files/#{a1.id}/download?verifier=#{a1.uuid}"
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
qs['verifier'].should == a1.uuid
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
expect(qs['verifier']).to eq a1.uuid
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
it "should be able to directly download in course context preview links with verifier" do
@ -177,21 +177,21 @@ describe FilesController do
a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course)
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/courses/#{@course.id}/files/#{a1.id}/preview?verifier=#{a1.uuid}"
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
qs['verifier'].should == a1.uuid
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png"
expect(qs['verifier']).to eq a1.uuid
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
it "should update module progressions for html safefiles iframe" do
@ -207,12 +207,12 @@ describe FilesController do
hash[@tag.id.to_s] = {:type => 'must_view'}
@module.completion_requirements = hash
@module.save!
@module.evaluate_for(@user).state.should eql(:unlocked)
expect(@module.evaluate_for(@user).state).to eql(:unlocked)
# the response will be on the main domain, with an iframe pointing to the files domain and the actual uploaded html file
get "http://test.host/courses/#{@course.id}/files/#{@att.id}"
response.should be_success
response.content_type.should == 'text/html'
expect(response).to be_success
expect(response.content_type).to eq 'text/html'
doc = Nokogiri::HTML::DocumentFragment.parse(response.body)
location = doc.at_css('iframe#file_content')['src']
@ -220,8 +220,8 @@ describe FilesController do
# and verify the module progress was recorded
reset!
get location
response.should be_success
@module.evaluate_for(@user).state.should eql(:completed)
expect(response).to be_success
expect(@module.evaluate_for(@user).state).to eql(:completed)
end
context "should support AssessmentQuestion as a context" do
@ -237,28 +237,28 @@ describe FilesController do
def do_with_safefiles_test(url)
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get url
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/files/#{@att.id}/download"
@user.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true
qs['verifier'].should == @att.uuid
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/files/#{@att.id}/download"
expect(@user.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy
expect(qs['verifier']).to eq @att.uuid
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
# ensure that the user wasn't logged in by the normal means
controller.instance_variable_get(:@current_user).should be_nil
expect(controller.instance_variable_get(:@current_user)).to be_nil
end
context "with safefiles" do
it "with new url style" do
do_with_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/#{@att.uuid}")
end
it "with old url style" do
do_with_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/download?verifier=#{@att.uuid}")
end
@ -267,17 +267,17 @@ describe FilesController do
def do_without_safefiles_test(url)
HostUrl.stubs(:file_host).returns('test.host')
get url
response.should be_success
response.content_type.should == 'image/png'
response['Pragma'].should be_nil
response['Cache-Control'].should_not match(/no-cache/)
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
expect(response['Pragma']).to be_nil
expect(response['Cache-Control']).not_to match(/no-cache/)
end
context "without safefiles" do
it "with new url style" do
do_without_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/#{@att.uuid}")
end
it "with old url style" do
do_without_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/download?verifier=#{@att.uuid}")
end
@ -290,21 +290,21 @@ describe FilesController do
@submission.save!
HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default])
get "http://test.host/users/#{@submission.user.id}/files/#{@submission.attachment.id}/download", :verifier => @submission.attachment.uuid
response.should be_redirect
expect(response).to be_redirect
uri = URI.parse response['Location']
qs = Rack::Utils.parse_nested_query(uri.query)
uri.host.should == 'files-test.host'
uri.path.should == "/files/#{@submission.attachment.id}/download"
qs['verifier'].should == @submission.attachment.uuid
expect(uri.host).to eq 'files-test.host'
expect(uri.path).to eq "/files/#{@submission.attachment.id}/download"
expect(qs['verifier']).to eq @submission.attachment.uuid
location = response['Location']
reset!
get location
response.should be_success
response.content_type.should == 'image/png'
controller.instance_variable_get(:@current_user).should be_nil
controller.instance_variable_get(:@context).should be_nil
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
expect(controller.instance_variable_get(:@current_user)).to be_nil
expect(controller.instance_variable_get(:@context)).to be_nil
end
it "shouldn't use relative urls for safefiles in other contexts" do
@ -318,17 +318,17 @@ describe FilesController do
@attachment.any_instantiation.expects(:create_or_update_thumbnail).with(anything, sz, sz).returns { @attachment.thumbnails.create!(:thumbnail => "640x>", :uploaded_data => stub_png_data) }
get "/images/thumbnails/#{@attachment.id}/#{@attachment.uuid}?size=640x#{URI.encode '>'}"
thumb = @attachment.thumbnails.find_by_thumbnail("640x>")
response.should redirect_to(thumb.authenticated_s3_url)
expect(response).to redirect_to(thumb.authenticated_s3_url)
end
it "should reorder files" do
course_with_teacher_logged_in(:active_all => true, :user => user_with_pseudonym)
att1 = attachment_model(:uploaded_data => stub_png_data, :context => @course)
att2 = attachment_model(:uploaded_data => stub_png_data("file2.png"), :context => @course)
post "/courses/#{@course.id}/files/reorder", {:order => "#{att2.id}, #{att1.id}", :folder_id => @folder.id}
response.should be_success
@folder.file_attachments.by_position_then_display_name.should == [att2, att1]
expect(response).to be_success
expect(@folder.file_attachments.by_position_then_display_name).to eq [att2, att1]
end
end

View File

@ -25,10 +25,10 @@ describe GroupsController do
@group = Group.create!(:name => "group1", :group_category => group_category, :context => @course)
get "/courses/#{@course.id}/groups/#{@group.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#right-side a.add').attribute("href").text.should == "/groups/#{@group.id}/announcements#new"
expect(html.css('#right-side a.add').attribute("href").text).to eq "/groups/#{@group.id}/announcements#new"
end
it "should not rendering 'pending' page when joining a self-signup group" do
@ -40,7 +40,7 @@ describe GroupsController do
g1 = @course.groups.create!(:name => "some group", :group_category => category1)
get "/courses/#{@course.id}/groups/#{g1.id}?join=1"
response.body.should_not =~ /This group has received your request to join/
expect(response.body).not_to match /This group has received your request to join/
end
end
@ -49,6 +49,6 @@ describe GroupsController do
group = Account.default.groups.create!(name: 'SIS imported')
get "/groups/#{group.id}"
response.should be_success
expect(response).to be_success
end
end

View File

@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "hair_trigger" do
describe "migrations" do
it "should be current for all models" do
HairTrigger::migrations_current?.should be_true
expect(HairTrigger::migrations_current?).to be_truthy
end
end
end

View File

@ -25,17 +25,17 @@ describe InfoController do
enable_cache do
user
get "/images/users/#{@user.id}"
response.should be_redirect
response['Location'].should match(%r{gravatar})
response['Location'].should match(%r{avatar-50})
expect(response).to be_redirect
expect(response['Location']).to match(%r{gravatar})
expect(response['Location']).to match(%r{avatar-50})
@user.avatar_image = { 'type' => 'attachment', 'url' => '/images/thumbnails/blah' }
@user.save!
get "/images/users/#{@user.id}"
response.should be_redirect
response['Location'].should_not match(%r{gravatar})
response['Location'].should match(%r{/images/thumbnails/blah})
expect(response).to be_redirect
expect(response['Location']).not_to match(%r{gravatar})
expect(response['Location']).to match(%r{/images/thumbnails/blah})
end
end
end

View File

@ -33,16 +33,16 @@ describe "locale_selection" do
@user.update_attribute :locale, 'es'
@pseudonym.reload
get dashboard_url
response.should be_success
I18n.locale.should eql(:es)
expect(response).to be_success
expect(I18n.locale).to eql(:es)
end
it "should set the locale when not authenticated" do
account = Account.default
account.update_attribute :default_locale, 'fr'
get login_url
response.should be_success
I18n.locale.should eql(:fr)
expect(response).to be_success
expect(I18n.locale).to eql(:fr)
end
end

View File

@ -39,11 +39,11 @@ describe "navigation" do
list = page.css(".menu-item-drop-column-list li")
# order of tests assumes alphabetical order of list
list[4].text.should match /Summer Term/m # course 3, Summer Term
list[3].text.should match /Spring Term/m # course 3, Spring Term
list[2].text.should match /Spring Term/ # don't show term cause it doesn't have a name collision
list[1].text.should_not match /Term/ # don't show term cause it's the default term
list[0].text.should_not match /Term/ # "
expect(list[4].text).to match /Summer Term/m # course 3, Summer Term
expect(list[3].text).to match /Spring Term/m # course 3, Spring Term
expect(list[2].text).to match /Spring Term/ # don't show term cause it doesn't have a name collision
expect(list[1].text).not_to match /Term/ # don't show term cause it's the default term
expect(list[0].text).not_to match /Term/ # "
end
it "should not fail on courses where the term no longer exists" do
@ -56,7 +56,7 @@ describe "navigation" do
course_with_teacher :course_name => "Course of doom", :user => @user, :active_all => true
get '/'
page = Nokogiri::HTML(response.body)
page.css('.customListOpen').should_not be_empty
expect(page.css('.customListOpen')).not_to be_empty
end
end

View File

@ -45,21 +45,21 @@ describe integration do
it "should error if the service isn't enabled" do
UsersController.any_instance.expects(:feature_and_service_enabled?).with(integration.underscore).returns(false)
get "/oauth?service=#{integration.underscore}"
response.should redirect_to(user_profile_url(@user))
flash[:error].should be_present
expect(response).to redirect_to(user_profile_url(@user))
expect(flash[:error]).to be_present
end
it "should redirect to the service for auth" do
oauth_start(integration)
response.should redirect_to("http://oauth.example.com/start")
expect(response).to redirect_to("http://oauth.example.com/start")
oreq = OauthRequest.last
oreq.should be_present
oreq.service.should == integration.underscore
oreq.token.should == "test_token"
oreq.secret.should == "test_secret"
oreq.user.should == @user
oreq.return_url.should == user_profile_url(@user)
expect(oreq).to be_present
expect(oreq.service).to eq integration.underscore
expect(oreq.token).to eq "test_token"
expect(oreq.secret).to eq "test_secret"
expect(oreq.user).to eq @user
expect(oreq.return_url).to eq user_profile_url(@user)
end
describe "oauth_success" do
@ -76,20 +76,20 @@ describe integration do
it "should fail without a valid token" do
get "/oauth_success?service=#{integration.underscore}&oauth_token=wrong&oauth_verifier=test_verifier"
response.should redirect_to(user_profile_url(@user))
flash[:error].should be_present
expect(response).to redirect_to(user_profile_url(@user))
expect(flash[:error]).to be_present
end
it "should fail with the wrong user" do
OauthRequest.last.update_attribute(:user, User.create!)
get "/oauth_success?service=#{integration.underscore}&oauth_token=test_token&oauth_verifier=test_verifier"
response.should redirect_to(user_profile_url(@user))
flash[:error].should be_present
expect(response).to redirect_to(user_profile_url(@user))
expect(flash[:error]).to be_present
end
it "should redirect to the original host if a different host is returned to" do
get "http://otherschool.example.com/oauth_success?service=#{integration.underscore}&oauth_token=test_token&oauth_verifier=test_verifier"
response.should redirect_to("http://www.example.com/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}")
expect(response).to redirect_to("http://www.example.com/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}")
end
it "should create the UserService on successful auth" do
@ -108,15 +108,15 @@ describe integration do
end
get "/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}"
response.should redirect_to(user_profile_url(@user))
flash[:error].should be_blank
flash[:notice].should be_present
expect(response).to redirect_to(user_profile_url(@user))
expect(flash[:error]).to be_blank
expect(flash[:notice]).to be_present
us = UserService.find_by_service_and_user_id(integration.underscore, @user.id)
us.should be_present
us.service_user_id.should == "test_user_id"
us.service_user_name.should == "test_user_name"
us.token.should == "test_token"
us.secret.should == "test_secret"
expect(us).to be_present
expect(us.service_user_id).to eq "test_user_id"
expect(us.service_user_name).to eq "test_user_name"
expect(us.token).to eq "test_token"
expect(us.secret).to eq "test_secret"
end
it "should fail creating the UserService if getting the initial user info fails" do
@ -137,11 +137,11 @@ describe integration do
end
get "/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}"
response.should redirect_to(user_profile_url(@user))
flash[:error].should be_present
flash[:notice].should be_blank
expect(response).to redirect_to(user_profile_url(@user))
expect(flash[:error]).to be_present
expect(flash[:notice]).to be_blank
us = UserService.find_by_service_and_user_id(integration.underscore, @user.id)
us.should_not be_present
expect(us).not_to be_present
end
end
end

View File

@ -30,21 +30,21 @@ describe "one time passwords" do
context "mid-login" do
before do
post '/login', :pseudonym_session => { :unique_id => @pseudonym.unique_id, :password => 'qwerty' }
response.should render_template('otp_login')
expect(response).to render_template('otp_login')
end
it "should not allow access to the rest of canvas" do
get '/'
response.should redirect_to login_url
expect(response).to redirect_to login_url
follow_redirect!
response.should be_success
expect(response).to be_success
end
it "should not allow re-enrolling" do
get '/login/otp'
response.should redirect_to login_url
expect(response).to redirect_to login_url
follow_redirect!
response.should be_success
expect(response).to be_success
end
end
end

View File

@ -28,12 +28,12 @@ describe "page views" do
@topic = @course.discussion_topics.create!
post "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries", :message => 'hello'
response.should be_success
expect(response).to be_success
pv = PageView.last
pv.context.should == @course
pv.controller.should == 'discussion_topics_api'
pv.action.should == 'add_entry'
expect(pv.context).to eq @course
expect(pv.controller).to eq 'discussion_topics_api'
expect(pv.action).to eq 'add_entry'
end
end

View File

@ -28,22 +28,22 @@ describe ProfileController do
user_session(u, p)
get '/profile/settings'
Nokogiri::HTML(response.body).css('input#user_short_name').should_not be_empty
expect(Nokogiri::HTML(response.body).css('input#user_short_name')).not_to be_empty
put '/profile', :user => { :short_name => 'Cody' }
response.should be_redirect
u.reload.short_name.should == 'Cody'
expect(response).to be_redirect
expect(u.reload.short_name).to eq 'Cody'
a.settings[:users_can_edit_name] = false
a.save!
p.reload
get '/profile/settings'
Nokogiri::HTML(response.body).css('input#user_short_name').should be_empty
expect(Nokogiri::HTML(response.body).css('input#user_short_name')).to be_empty
put '/profile', :user => { :short_name => 'JT' }
response.should be_redirect
u.reload.short_name.should == 'Cody'
expect(response).to be_redirect
expect(u.reload.short_name).to eq 'Cody'
end
it "should not show student view student edit profile or other services options" do

View File

@ -22,10 +22,10 @@ describe PseudonymSessionsController do
def redirect_until(uri)
count = 0
while true
response.should be_redirect
expect(response).to be_redirect
return if response.location == uri
count += 1
count.should < 5
expect(count).to be < 5
follow_redirect!
end
end
@ -59,11 +59,11 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(dashboard_url(:login_success => 1))
session[:cas_session].should == 'ST-abcd'
expect(response).to redirect_to(dashboard_url(:login_success => 1))
expect(session[:cas_session]).to eq 'ST-abcd'
delete logout_url
response.should redirect_to(@cas_client.logout_url(cas_login_url))
expect(response).to redirect_to(@cas_client.logout_url(cas_login_url))
end
it "should inform the user CAS validation denied" do
@ -73,8 +73,8 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(cas_login_url :no_auto => true)
flash[:delegated_message].should match(/There was a problem logging in/)
expect(response).to redirect_to(cas_login_url :no_auto => true)
expect(flash[:delegated_message]).to match(/There was a problem logging in/)
end
it "should inform the user CAS validation failed" do
@ -87,8 +87,8 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(cas_login_url :no_auto => true)
flash[:delegated_message].should match(/There was a problem logging in/)
expect(response).to redirect_to(cas_login_url :no_auto => true)
expect(flash[:delegated_message]).to match(/There was a problem logging in/)
end
it "should inform the user that CAS account doesn't exist" do
@ -98,9 +98,9 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(cas_login_url(:no_auto => true))
expect(response).to redirect_to(cas_login_url(:no_auto => true))
get cas_login_url :no_auto => true
flash[:delegated_message].should match(/Canvas doesn't have an account for user/)
expect(flash[:delegated_message]).to match(/Canvas doesn't have an account for user/)
end
it "should redirect to a custom url if the user CAS account doesn't exist" do
@ -115,7 +115,7 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(redirect_url)
expect(response).to redirect_to(redirect_url)
end
it "should login case insensitively" do
@ -127,13 +127,13 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(dashboard_url(:login_success => 1))
session[:cas_session].should == 'ST-abcd'
expect(response).to redirect_to(dashboard_url(:login_success => 1))
expect(session[:cas_session]).to eq 'ST-abcd'
end
context "single sign out" do
before do
pending "needs redis" unless Canvas.redis_enabled?
skip "needs redis" unless Canvas.redis_enabled?
end
it "should do a single sign out" do
@ -145,13 +145,13 @@ describe PseudonymSessionsController do
redirect_until(@cas_client.add_service_to_login_url(cas_login_url))
get cas_login_url :ticket => 'ST-abcd'
response.should redirect_to(dashboard_url(:login_success => 1))
session[:cas_session].should == 'ST-abcd'
Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s
expect(response).to redirect_to(dashboard_url(:login_success => 1))
expect(session[:cas_session]).to eq 'ST-abcd'
expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s
# pretend we lost the cache somehow
Canvas.redis.del("cas_session:ST-abcd")
Canvas.redis.get("cas_session:ST-abcd").should == nil
expect(Canvas.redis.get("cas_session:ST-abcd")).to eq nil
back_channel = open_session
# it starts out as a clone of the current session
@ -164,19 +164,19 @@ describe PseudonymSessionsController do
<samlp:SessionIndex>ST-abcd</samlp:SessionIndex>
</samlp:LogoutRequest>
SAML
back_channel.response.status.to_i.should == 404
expect(back_channel.response.status.to_i).to eq 404
# this should refresh it
get dashboard_url
response.should be_success
Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s
expect(response).to be_success
expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s
# unrelated logout should have no effect
back_channel.post cas_logout_url :garbage => 1
back_channel.response.status.to_i.should == 404
expect(back_channel.response.status.to_i).to eq 404
back_channel.post cas_logout_url :logoutRequest => "garbage"
back_channel.response.status.to_i.should == 404
expect(back_channel.response.status.to_i).to eq 404
back_channel.post cas_logout_url :logoutRequest => <<-SAML
<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="1371236167rDkbdl8FGzbqwBhICvi" Version="2.0" IssueInstant="Fri, 14 Jun 2013 12:56:07 -0600">
@ -184,12 +184,12 @@ describe PseudonymSessionsController do
<samlp:SessionIndex>ST-abc</samlp:SessionIndex>
</samlp:LogoutRequest>
SAML
back_channel.response.status.to_i.should == 404
expect(back_channel.response.status.to_i).to eq 404
# still logged in
get dashboard_url
response.should be_success
Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s
expect(response).to be_success
expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s
# this time it works
back_channel.post cas_logout_url :logoutRequest => <<-SAML
@ -198,8 +198,8 @@ describe PseudonymSessionsController do
<samlp:SessionIndex>ST-abcd</samlp:SessionIndex>
</samlp:LogoutRequest>
SAML
back_channel.response.should be_success
Canvas.redis.get("cas_session:ST-abcd").should == nil
expect(back_channel.response).to be_success
expect(Canvas.redis.get("cas_session:ST-abcd")).to eq nil
# logged out!
get dashboard_url
@ -210,7 +210,7 @@ describe PseudonymSessionsController do
context "SAML" do
before do
pending("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled
skip("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled
end
it 'redirects to the discovery page when hitting a deep link while unauthenticated' do
@ -229,9 +229,9 @@ describe PseudonymSessionsController do
Account.site_admin.account_users.create!(user: @user)
get jobs_url
response.should redirect_to login_url
expect(response).to redirect_to login_url
post login_url, :pseudonym_session => { :unique_id => @pseudonym.unique_id, :password => 'qwerty' }
response.should redirect_to jobs_url
expect(response).to redirect_to jobs_url
end
end

View File

@ -38,7 +38,7 @@ describe "QuizRegrading" do
course_with_student_logged_in(active_all: true)
quiz_model(course: @course)
@regrade = @quiz.quiz_regrades.where(quiz_id: @quiz.id, quiz_version: @quiz.version_number).first_or_create(user: @student)
@regrade.should_not be_new_record
expect(@regrade).not_to be_new_record
@true_false_question = create_quiz_question!({
:points_possible => 1,
:question_type => 'true_false_question',
@ -76,13 +76,13 @@ describe "QuizRegrading" do
@submission = @quiz.generate_submission(@student)
reset_submission_data!
@submission.save!
@submission.score.should == 0.5
expect(@submission.score).to eq 0.5
end
it 'succesfully regrades the submissions and updates the scores' do
set_regrade_option!('full_credit')
Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz)
@submission.reload.score.should == 3
expect(@submission.reload.score).to eq 3
set_regrade_option!('current_correct_only')
data = @true_false_question.question_data
@ -102,7 +102,7 @@ describe "QuizRegrading" do
@quiz.reload
Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz)
@submission.reload.score.should == 3
expect(@submission.reload.score).to eq 3
end
it 'does not expose the question names' do
@ -124,10 +124,10 @@ describe "QuizRegrading" do
Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz)
@submission.reload
@quiz.quiz_data[0][:question_name].should == 'foo'
@quiz.quiz_data[1][:question_name].should == 'bar'
@submission.quiz_data[0][:question_name].should == 'Question 1'
@submission.quiz_data[1][:question_name].should == 'Question 2'
expect(@quiz.quiz_data[0][:question_name]).to eq 'foo'
expect(@quiz.quiz_data[1][:question_name]).to eq 'bar'
expect(@submission.quiz_data[0][:question_name]).to eq 'Question 1'
expect(@submission.quiz_data[1][:question_name]).to eq 'Question 2'
end
end

View File

@ -44,19 +44,19 @@ describe Quizzes::QuizSubmissionsController do
def record_answer_1
post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer",
:question_1 => 'blah', :last_question_id => 1, :validation_token => @qs.validation_token
response.should be_redirect
expect(response).to be_redirect
end
def backup_answer_1
put "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/backup",
:question_1 => 'blah_overridden', :validation_token => @qs.validation_token
response.should be_success
expect(response).to be_success
end
def record_answer_2
post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer",
:question_2 => 'M&Ms', :last_question_id => 2, :validation_token => @qs.validation_token
response.should be_redirect
expect(response).to be_redirect
end
describe "record_answer / backup" do
@ -64,26 +64,26 @@ describe Quizzes::QuizSubmissionsController do
@quiz.update_attribute :cant_go_back, true
record_answer_1
backup_answer_1
@qs.reload.submission_data[:question_1].should == 'blah'
expect(@qs.reload.submission_data[:question_1]).to eq 'blah'
end
it "should allow overwriting answers otherwise" do
record_answer_1
backup_answer_1
@qs.reload.submission_data[:question_1].should == 'blah_overridden'
expect(@qs.reload.submission_data[:question_1]).to eq 'blah_overridden'
end
it "should redirect back to take quiz if the user loses connection" do
get "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer",
:question_1 => 'blah', :last_question_id => 1, :validation_token => @qs.validation_token
response.should be_redirect
expect(response).to be_redirect
end
end
def submit_quiz
post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/",
:question_1 => 'password', :attempt => 1, :validation_token => @qs.validation_token
response.should be_redirect
expect(response).to be_redirect
end
describe "submit quiz" do
@ -94,14 +94,14 @@ describe Quizzes::QuizSubmissionsController do
record_answer_1
submit_quiz
@qs.reload.submission_data[0][:correct].should be_true
expect(@qs.reload.submission_data[0][:correct]).to be_truthy
end
it "allows overwriting answers otherwise" do
record_answer_1
submit_quiz
@qs.reload.submission_data[0][:correct].should be_false
expect(@qs.reload.submission_data[0][:correct]).to be_falsey
end
context "with a symbol in an answer" do
@ -109,7 +109,7 @@ describe Quizzes::QuizSubmissionsController do
record_answer_2
submit_quiz
@qs.reload.submission_data[1][:correct].should be_true
expect(@qs.reload.submission_data[1][:correct]).to be_truthy
end
end
end

View File

@ -30,8 +30,8 @@ describe Quizzes::QuizzesController do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should include "Everyone"
doc.css(".assignment_dates").text.should_not include "Everyone else"
expect(doc.css(".assignment_dates").text).to include "Everyone"
expect(doc.css(".assignment_dates").text).not_to include "Everyone else"
end
end
@ -48,14 +48,14 @@ describe Quizzes::QuizzesController do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css("#quiz_student_details .value").first.text.should include(datetime_string(@due_at))
expect(doc.css("#quiz_student_details .value").first.text).to include(datetime_string(@due_at))
end
it "should show 'Everyone else' when some sections have a due date override" do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should include "Everyone else"
expect(doc.css(".assignment_dates").text).to include "Everyone else"
end
end
@ -70,16 +70,16 @@ describe Quizzes::QuizzesController do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates tbody tr").count.should be 2
doc.css(".assignment_dates tbody tr > td:first-child").text.
should include(datetime_string(@due_at1), datetime_string(@due_at2))
expect(doc.css(".assignment_dates tbody tr").count).to be 2
expect(doc.css(".assignment_dates tbody tr > td:first-child").text).
to include(datetime_string(@due_at1), datetime_string(@due_at2))
end
it "should not show a date for 'Everyone else'" do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css(".assignment_dates").text.should_not include "Everyone"
expect(doc.css(".assignment_dates").text).not_to include "Everyone"
end
end
end
@ -89,14 +89,14 @@ describe Quizzes::QuizzesController do
@course.large_roster = false
@course.save!
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
response.body.should match(%r{SpeedGrader})
expect(response.body).to match(%r{SpeedGrader})
end
it "should not link to SpeedGrader when large_roster" do
@course.large_roster = true
@course.save!
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
response.body.should_not match(%r{SpeedGrader})
expect(response.body).not_to match(%r{SpeedGrader})
end
end
end
@ -115,7 +115,7 @@ describe Quizzes::QuizzesController do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css("#not_right_side .take_quiz_button").text.should include "Resume Quiz"
expect(doc.css("#not_right_side .take_quiz_button").text).to include "Resume Quiz"
end
end
@ -124,7 +124,7 @@ describe Quizzes::QuizzesController do
get "courses/#{@course.id}/quizzes/#{@quiz.id}"
doc = Nokogiri::HTML(response.body)
doc.css("#right-side .rs-margin-top").text.should_not include "Resume Quiz"
expect(doc.css("#right-side .rs-margin-top").text).not_to include "Resume Quiz"
end
end
end
@ -146,12 +146,12 @@ describe Quizzes::QuizzesController do
it "should list the questions needing review" do
mkquiz
get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}"
response.body.should match(%r{The following questions need review})
response.body.should_not match(%r{The quiz has changed significantly since this submission was made})
expect(response.body).to match(%r{The following questions need review})
expect(response.body).not_to match(%r{The quiz has changed significantly since this submission was made})
doc = Nokogiri::HTML(response.body)
needing_review = doc.at_css('#questions_needing_review')
needing_review.should be_present
needing_review.children.css('li a').map { |n| n.text }.should == @quiz.quiz_data.map { |qq| qq['name'] }
expect(needing_review).to be_present
expect(needing_review.children.css('li a').map { |n| n.text }).to eq @quiz.quiz_data.map { |qq| qq['name'] }
end
it "should display message about the quiz changing significantly" do
@ -161,20 +161,20 @@ describe Quizzes::QuizzesController do
@quiz_submission.submission_data.each { |q| q[:correct] = "false" }
@quiz_submission.save
get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}"
response.body.should_not match(%r{The following questions need review})
response.body.should match(%r{The quiz has changed significantly since this submission was made})
expect(response.body).not_to match(%r{The following questions need review})
expect(response.body).to match(%r{The quiz has changed significantly since this submission was made})
end
it "should display both messages" do
Quizzes::Quiz.any_instance.stubs(:changed_significantly_since?).returns(true)
mkquiz
get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}"
response.body.should match(%r{The following questions need review})
response.body.should match(%r{The quiz has changed significantly since this submission was made})
expect(response.body).to match(%r{The following questions need review})
expect(response.body).to match(%r{The quiz has changed significantly since this submission was made})
doc = Nokogiri::HTML(response.body)
needing_review = doc.at_css('#questions_needing_review')
needing_review.should be_present
needing_review.children.css('li a').map { |n| n.text }.should == @quiz.quiz_data.map { |qq| qq['name'] }
expect(needing_review).to be_present
expect(needing_review.children.css('li a').map { |n| n.text }).to eq @quiz.quiz_data.map { |qq| qq['name'] }
end
it "shoudn't show the user's name/email when it's an anonymous submission" do
@ -188,9 +188,9 @@ describe Quizzes::QuizzesController do
@student.save!
@student.reload
get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}"
response.body.should_not match @student.name
response.body.should_not match @student.sortable_name
response.body.should_not match @student.email
expect(response.body).not_to match @student.name
expect(response.body).not_to match @student.sortable_name
expect(response.body).not_to match @student.email
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -33,25 +33,25 @@ describe "Session Timeout" do
it "should time out after 40 minutes of inactivity" do
now = Time.now
get "/"
response.should be_success
expect(response).to be_success
Time.stubs(:now).returns(now + 40.minutes)
get "/"
response.should redirect_to "http://www.example.com/login"
expect(response).to redirect_to "http://www.example.com/login"
end
it "should not time out if the user remains active" do
now = Time.now
get "/"
response.should be_success
expect(response).to be_success
Time.stubs(:now).returns(now + 20.minutes)
get "/"
response.should be_success
expect(response).to be_success
Time.stubs(:now).returns(now + 40.minutes)
get "/"
response.should be_success
expect(response).to be_success
end
end
end

View File

@ -44,37 +44,37 @@ describe "student interactions links" do
it "should show the student link on the student's page" do
get "/courses/#{@course.id}/users/#{@student.id}"
response.should be_success
response.body.should match(/Interactions with You/)
expect(response).to be_success
expect(response.body).to match(/Interactions with You/)
end
it "should show the teacher link on the teacher's page" do
get "/courses/#{@course.id}/users/#{@teacher.id}"
response.should be_success
response.body.should match(/Student Interactions Report/)
expect(response).to be_success
expect(response.body).to match(/Student Interactions Report/)
end
it "should show mail link for teachers" do
get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('.message_student_link').should_not be_nil
expect(html.css('.message_student_link')).not_to be_nil
end
it "should recalculate grades on the first page load" do
Enrollment.expects(:recompute_final_score).twice # once for the course, once for the student ('s course)
enable_cache do
get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}"
response.should be_success
expect(response).to be_success
get "/users/#{@teacher.id}/teacher_activity/student/#{@student.id}"
response.should be_success
expect(response).to be_success
get "/users/#{@teacher.id}/teacher_activity/student/#{@student.id}"
response.should be_success
expect(response).to be_success
get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}"
response.should be_success
expect(response).to be_success
end
end
@ -83,9 +83,9 @@ describe "student interactions links" do
Account.site_admin.account_users.create!(user: @user)
user_session(@user)
get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}"
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('.message_student_link').should be_empty
expect(html.css('.message_student_link')).to be_empty
end
end

View File

@ -26,10 +26,10 @@ describe "syllabus" do
get "/courses/#{@course.id}/assignments/syllabus"
response.should be_success
expect(response).to be_success
page = Nokogiri::HTML(response.body)
page.css('#identity a[href="/login"]').should_not be_nil
page.at_css('#syllabusContainer').should_not be_nil
expect(page.css('#identity a[href="/login"]')).not_to be_nil
expect(page.at_css('#syllabusContainer')).not_to be_nil
end
it "should allow access to public courses" do
@ -49,8 +49,8 @@ describe "syllabus" do
get "/courses/#{@course.id}"
response.should be_success
expect(response).to be_success
page = Nokogiri::HTML(response.body)
page.at_css('#course_syllabus').text.should include(syllabus_body)
expect(page.at_css('#course_syllabus').text).to include(syllabus_body)
end
end

View File

@ -29,12 +29,12 @@ describe "User Content" do
snippet = Base64.encode64 obj_data
sig = Canvas::Security.hmac_sha1(snippet)
post "http://files.example.com/object_snippet", :object_data => snippet, :s => sig
response.should be_success
response.body.should be_include(obj_data)
expect(response).to be_success
expect(response.body).to be_include(obj_data)
post "http://canvas.example.com/object_snippet", :object_data => snippet, :s => sig
assert_status(400)
response.body.should be_blank
expect(response.body).to be_blank
end
it "should allow object_snippet if there is no safefiles domain configured" do
@ -45,8 +45,8 @@ describe "User Content" do
snippet = Base64.encode64 obj_data
sig = Canvas::Security.hmac_sha1(snippet)
post "http://files.example.com/object_snippet", :object_data => snippet, :s => sig
response.should be_success
response.body.should be_include(obj_data)
expect(response).to be_success
expect(response.body).to be_include(obj_data)
end
end
end

View File

@ -36,28 +36,28 @@ describe UsersController do
it "should count conversations as interaction" do
get user_student_teacher_activity_url(@teacher, @e1.user)
Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text.should match(/never/)
expect(Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text).to match(/never/)
@conversation = Conversation.initiate([@e1.user, @teacher], false)
@conversation.add_message(@teacher, "hello")
get user_student_teacher_activity_url(@teacher, @e1.user)
Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text.should match(/less than 1 day/)
expect(Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text).to match(/less than 1 day/)
end
it "should only include students the teacher can view" do
get user_course_teacher_activity_url(@teacher, @course)
response.should be_success
response.body.should match(/studentname1/)
response.body.should_not match(/studentname2/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
expect(response.body).not_to match(/studentname2/)
end
it "should show user notes if enabled" do
get user_course_teacher_activity_url(@teacher, @course)
response.body.should_not match(/journal entry/i)
expect(response.body).not_to match(/journal entry/i)
@course.root_account.update_attribute(:enable_user_notes, true)
get user_course_teacher_activity_url(@teacher, @course)
response.body.should match(/journal entry/i)
expect(response.body).to match(/journal entry/i)
end
it "should show individual user info across courses" do
@ -66,18 +66,18 @@ describe UsersController do
@course2.update_attribute(:name, 'coursename2')
student_in_course(:course => @course2, :user => @e1.user)
get user_student_teacher_activity_url(@teacher, @e1.user)
response.should be_success
response.body.should match(/studentname1/)
response.body.should_not match(/studentname2/)
response.body.should match(/coursename1/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
expect(response.body).not_to match(/studentname2/)
expect(response.body).to match(/coursename1/)
# teacher not in course2
response.body.should_not match(/coursename2/)
expect(response.body).not_to match(/coursename2/)
# now put teacher in course2
@course2.enroll_teacher(@teacher).accept!
get user_student_teacher_activity_url(@teacher, @e1.user)
response.should be_success
response.body.should match(/coursename1/)
response.body.should match(/coursename2/)
expect(response).to be_success
expect(response.body).to match(/coursename1/)
expect(response.body).to match(/coursename2/)
end
it "should be available for concluded courses/enrollments" do
@ -89,24 +89,24 @@ describe UsersController do
@e1.conclude
get user_student_teacher_activity_url(@teacher, @e1.user)
response.should be_success
response.body.should match(/studentname1/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
get user_course_teacher_activity_url(@teacher, @course)
response.should be_success
response.body.should match(/studentname1/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
end
it "should show concluded students to active teachers" do
@e1.conclude
get user_student_teacher_activity_url(@teacher, @e1.user)
response.should be_success
response.body.should match(/studentname1/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
get user_course_teacher_activity_url(@teacher, @course)
response.should be_success
response.body.should match(/studentname1/)
expect(response).to be_success
expect(response.body).to match(/studentname1/)
end
end
@ -119,8 +119,8 @@ describe UsersController do
Account.default.account_users.create!(user: @user)
user_session(@user, @pseudonym)
get account_users_url(Account.default)
response.should be_success
response.body.should match /Olds, JT.*St\. Clair, John/m
expect(response).to be_success
expect(response.body).to match /Olds, JT.*St\. Clair, John/m
end
it "should not show any student view students at the account level" do
@ -132,8 +132,8 @@ describe UsersController do
get account_users_url Account.default.id
body = Nokogiri::HTML(response.body)
body.css("#user_#{@fake_student.id}").should be_empty
body.at_css('.users').text.should_not match(/Test Student/)
expect(body.css("#user_#{@fake_student.id}")).to be_empty
expect(body.at_css('.users').text).not_to match(/Test Student/)
end
end
@ -145,7 +145,7 @@ describe UsersController do
course
student_in_course(:course => @course)
get "/users/#{@student.id}"
response.should be_success
expect(response).to be_success
course(:account => account_model)
student_in_course(:course => @course)
@ -162,7 +162,7 @@ describe UsersController do
user_session(@user)
get "/users/#{@student.id}"
response.should be_success
expect(response).to be_success
end
it "should show course user to account users that have the read_roster permission" do
@ -174,7 +174,7 @@ describe UsersController do
user_session(@user)
get "/courses/#{@course.id}/users/#{@student.id}"
response.should be_success
expect(response).to be_success
end
end
@ -199,33 +199,33 @@ describe UsersController do
disable_avatars!
enable_cache do
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "http://someschool.instructure.com/images/no_pic.gif"
expect(response).to redirect_to "http://someschool.instructure.com/images/no_pic.gif"
get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "https://otherschool.instructure.com/images/no_pic.gif"
expect(response).to redirect_to "https://otherschool.instructure.com/images/no_pic.gif"
end
end
it "should maintain protocol and domain name in gravatar redirect fallback" do
enable_cache do
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/images/messages/avatar-50.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/images/messages/avatar-50.png")}"
end
end
it "should return different urls for different fallbacks" do
enable_cache do
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI.escape("/my/custom/fallback/url.png")}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/my/custom/fallback/url.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/my/custom/fallback/url.png")}"
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI.escape("https://test.domain/another/custom/fallback/url.png")}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://test.domain/another/custom/fallback/url.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://test.domain/another/custom/fallback/url.png")}"
end
end
@ -235,23 +235,23 @@ describe UsersController do
orig_size = data.size
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}"
get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=/my/custom/fallback/url.png"
response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/my/custom/fallback/url.png")}"
expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/my/custom/fallback/url.png")}"
diff = data.select{|k,v|k =~ /avatar_img/}.size - orig_size
diff.should > 0
expect(diff).to be > 0
@user.update_attribute(:avatar_image, {'type' => 'attachment', 'url' => '/images/thumbnails/foo.gif'})
data.select{|k,v|k =~ /avatar_img/}.size.should == orig_size
expect(data.select{|k,v|k =~ /avatar_img/}.size).to eq orig_size
get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}"
response.should redirect_to "http://someschool.instructure.com/images/thumbnails/foo.gif"
expect(response).to redirect_to "http://someschool.instructure.com/images/thumbnails/foo.gif"
get "http://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI::escape("https://test.domain/my/custom/fallback/url.png")}"
response.should redirect_to "http://otherschool.instructure.com/images/thumbnails/foo.gif"
data.select{|k,v|k =~ /avatar_img/}.size.should == orig_size + diff
expect(response).to redirect_to "http://otherschool.instructure.com/images/thumbnails/foo.gif"
expect(data.select{|k,v|k =~ /avatar_img/}.size).to eq orig_size + diff
end
end
end
@ -266,9 +266,9 @@ describe UsersController do
get grades_url
student_grades = Nokogiri::HTML(response.body).css('.student_grades tr')
student_grades.length.should == 2
student_grades.text.should match /#{@first_course.name}/
student_grades.text.should match /#{@course.name}/
expect(student_grades.length).to eq 2
expect(student_grades.text).to match /#{@first_course.name}/
expect(student_grades.text).to match /#{@course.name}/
end
end
@ -281,21 +281,21 @@ describe UsersController do
user_session(@admin)
get user_admin_merge_url(@user, :pending_user_id => @admin.id)
response.should be_success
assigns['pending_other_user'].should == @admin
assigns['other_user'].should be_nil
expect(response).to be_success
expect(assigns['pending_other_user']).to eq @admin
expect(assigns['other_user']).to be_nil
get user_admin_merge_url(@user, :new_user_id => @admin.id)
response.should be_success
assigns['pending_other_user'].should be_nil
assigns['other_user'].should == @admin
expect(response).to be_success
expect(assigns['pending_other_user']).to be_nil
expect(assigns['other_user']).to eq @admin
post user_merge_url(@user, :new_user_id => @admin.id)
response.should redirect_to(user_profile_url(@admin))
expect(response).to redirect_to(user_profile_url(@admin))
@user.reload.should be_deleted
@admin.reload.should be_registered
@admin.pseudonyms.count.should == 2
expect(@user.reload).to be_deleted
expect(@admin.reload).to be_registered
expect(@admin.pseudonyms.count).to eq 2
end
end
end

View File

@ -25,21 +25,21 @@ describe "varied due dates" do
def assert_coming_up_due_date(response, expected)
doc = Nokogiri::HTML(response.body)
doc.at_css("#right-side .coming_up .event a .tooltip_text").text.should include(
expect(doc.at_css("#right-side .coming_up .event a .tooltip_text").text).to include(
expected.is_a?(String) ? expected : datetime_string(expected)
)
end
def assert_todo_due_date(response, expected)
doc = Nokogiri::HTML(response.body)
doc.at_css("#right-side .to-do-list").text.should include(
expect(doc.at_css("#right-side .to-do-list").text).to include(
expected.is_a?(String) ? expected : datetime_string(expected)
)
end
def assert_recent_feedback_due_date(response, expected)
doc = Nokogiri::HTML(response.body)
doc.at_css("#right-side .recent_feedback .event a .tooltip_text").text.should include(
expect(doc.at_css("#right-side .recent_feedback .event a .tooltip_text").text).to include(
expected.is_a?(String) ? expected : datetime_string(expected)
)
end
@ -214,7 +214,7 @@ describe "varied due dates" do
context "with overrides" do
it "shows multiple due dates" do
get course_assignments_path(@course)
response.body.should include multiple_due_dates
expect(response.body).to include multiple_due_dates
end
end
@ -222,7 +222,7 @@ describe "varied due dates" do
it "shows the course due date" do
AssignmentOverride.delete_all
get course_assignments_path(@course)
response.body.should include formatted_date(@course_due_date)
expect(response.body).to include formatted_date(@course_due_date)
end
end
end

View File

@ -34,7 +34,7 @@ describe WikiPagesController do
:body => "this is the content of the wikipage body asdfasdf"
@wiki_page.destroy
get course_wiki_page_url(@course, @wiki_page)
response.body.should_not include(@wiki_page.body)
expect(response.body).not_to include(@wiki_page.body)
end
it "should link correctly in the breadcrumbs for group wikis" do
@ -45,13 +45,13 @@ describe WikiPagesController do
def test_page(url)
get url
response.should be_success
expect(response).to be_success
html = Nokogiri::HTML(response.body)
html.css('#breadcrumbs a').each do |link|
href = link.attr('href')
next if href == "/"
href.should =~ %r{/groups/#{@group.id}}
expect(href).to match %r{/groups/#{@group.id}}
end
end
@ -76,34 +76,34 @@ describe WikiPagesController do
@course.wiki.has_no_front_page = true
@course.wiki.save!
get @base_url + "wiki"
response.should redirect_to(course_pages_url(@course))
expect(response).to redirect_to(course_pages_url(@course))
end
it "should forward /wiki to /pages/front-page" do
@front.save!
@front.set_as_front_page!
get @base_url + "wiki"
response.should redirect_to(course_named_page_url(@course, "front-page"))
expect(response).to redirect_to(course_named_page_url(@course, "front-page"))
end
it "should forward /wiki/name to /pages/name" do
get @base_url + "wiki/a-page"
response.should redirect_to(course_named_page_url(@course, "a-page"))
expect(response).to redirect_to(course_named_page_url(@course, "a-page"))
end
it "should forward module_item_id parameter" do
get @base_url + "wiki/a-page?module_item_id=123"
response.should redirect_to(course_named_page_url(@course, "a-page") + "?module_item_id=123")
expect(response).to redirect_to(course_named_page_url(@course, "a-page") + "?module_item_id=123")
end
it "should forward /wiki/name/revisions to /pages/name/revisions" do
get @base_url + "wiki/a-page/revisions"
response.should redirect_to(course_named_page_revisions_url(@course, "a-page"))
expect(response).to redirect_to(course_named_page_revisions_url(@course, "a-page"))
end
it "should forward /wiki/name/revisions/revision to /pages/name/revisions" do
get @base_url + "wiki/a-page/revisions/42"
response.should redirect_to(course_named_page_revisions_url(@course, "a-page"))
expect(response).to redirect_to(course_named_page_revisions_url(@course, "a-page"))
end
end