Skip to content

Commit

Permalink
spec: enable avatars in some test for coverage
Browse files Browse the repository at this point in the history
closes: GRADE-1563

Change-Id: I0c5c71a9807006156969a8baa70739b00fd0b681
Reviewed-on: https://gerrit.instructure.com/166639
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <[email protected]>
QA-Review: Jeremy Neander <[email protected]>
Product-Review: Derek Bender <[email protected]>
  • Loading branch information
djbender committed Oct 4, 2018
1 parent 3ec3170 commit 911d9e9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/apis/v1/anonymous_provisional_grades_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
describe 'status' do
before(:once) do
course_with_teacher(active_all: true)
@course.account.enable_service(:avatars)
ta_in_course(active_all: true)
@student = student_in_course(active_all: true).user
@assignment = @course.assignments.create!(moderated_grading: true, grader_count: 1)
Expand Down
11 changes: 10 additions & 1 deletion spec/apis/v1/provisional_grades_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
it_behaves_like 'a provisional grades status action', :provisional_grades

describe "bulk_select" do
let_once(:course) { course_factory }
let_once(:course) do
course = course_factory
course.account.enable_service(:avatars)
course
end

let_once(:teacher) { teacher_in_course(active_all: true, course: course).user }
let_once(:ta_1) { ta_in_course(active_all: true, course: course).user }
let_once(:ta_2) { ta_in_course(active_all: true, course: course).user }
Expand Down Expand Up @@ -197,6 +202,7 @@ def selected_grades
describe "select" do
before(:once) do
course_with_student :active_all => true
@course.account.enable_service(:avatars)
ta_in_course :active_all => true
@assignment = @course.assignments.build
@assignment.grader_count = 1
Expand Down Expand Up @@ -250,6 +256,7 @@ def selected_grades
describe "copy_to_final_mark" do
before(:once) do
course_with_student :active_all => true
@course.account.enable_service(:avatars)
ta_in_course :active_all => true
@assignment = @course.assignments.create!(
submission_types: 'online_text_entry',
Expand Down Expand Up @@ -301,6 +308,7 @@ def selected_grades
describe "publish" do
before :once do
course_with_student :active_all => true
@course.account.enable_service(:avatars)
course_with_ta :course => @course, :active_all => true
@assignment = @course.assignments.create!
@path = "/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/provisional_grades/publish"
Expand Down Expand Up @@ -419,6 +427,7 @@ def selected_grades
context "with one provisional grade" do
it "publishes the only provisional grade if none have been explicitly selected" do
course_with_user("TaEnrollment", course: @course, active_all: true)
@course.account.enable_service(:avatars)
@submission = @assignment.submit_homework(@student, body: "hello")
@assignment.grade_student(@student, grader: @ta, score: 72, provisional: true)

Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/anonymous_submissions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
describe "GET show" do
before do
course_with_student_and_submitted_homework
@course.account.enable_service(:avatars)
@context = @course
@assignment.update!(anonymous_grading: true)
@submission.update!(score: 10)
Expand Down Expand Up @@ -107,6 +108,7 @@

it "should show rubric assessments to peer reviewers" do
course_with_student(active_all: true)
@course.account.enable_service(:avatars)
@assessor = @student
outcome_with_rubric
@association = @rubric.associate_with @assignment, @context, :purpose => 'grading'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
describe 'GET :show' do
before do
course_with_student_and_submitted_homework
@course.account.enable_service(:avatars)
@context = @course
user_session(@student)
end
Expand Down Expand Up @@ -103,6 +104,7 @@
@original_context = @context
@original_student = @student
course_with_student(active_all:true)
@course.account.enable_service(:avatars)
submission_comment_model
@attachment = attachment_model(context: @assignment)
@submission_comment.attachments = [@attachment]
Expand Down Expand Up @@ -132,6 +134,7 @@
it "should redirect download requests with the download_frd parameter" do
# This is because the files controller looks for download_frd to indicate a forced download
course_with_teacher_logged_in
@course.account.enable_service(:avatars)
assignment = assignment_model(course: @course)
student_in_course
att = attachment_model(:uploaded_data => stub_file_data('test.txt', 'asdf', 'text/plain'), :context => @student)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
describe 'GET :show' do
before do
course_with_student_and_submitted_homework
@course.account.enable_service(:avatars)
@context = @course
user_session(@student)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

let(:course) do
course_with_student
@course.account.enable_service(:avatars)
@course
end

Expand Down Expand Up @@ -68,6 +69,7 @@
context "when the assignment is not a quiz" do
before :once do
course_with_student
@course.account.enable_service(:avatars)
assignment = @course.assignments.create!
submission = Timecop.freeze(2.hours.ago) do
assignment.submit_homework(@student, { body: 'hello' })
Expand Down
27 changes: 27 additions & 0 deletions spec/controllers/submissions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
describe "POST create" do
it "should require authorization" do
course_with_student(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_url", :url => "url"}}
assert_unauthorized
end

it "should allow submitting homework" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_url", :url => "url"}}
expect(response).to be_redirect
Expand All @@ -45,12 +47,14 @@
expect(Canvas::LiveEvents).to receive(:submission_created).once
expect(Canvas::LiveEvents).not_to receive(:submission_updated)
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_url", :url => "url"}}
end

it "should not double-send notifications to a teacher" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@teacher = user_with_pseudonym(username: '[email protected]', active_all: 1)
teacher_in_course(course: @course, user: @teacher, active_all: 1)
n = Notification.create!(name: 'Assignment Submitted', category: 'TestImmediately')
Expand All @@ -64,6 +68,7 @@

it "should allow submitting homework as attachments" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_upload")
att = attachment_model(:context => @user, :uploaded_data => stub_file_data('test.txt', 'asdf', 'text/plain'))
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_upload", :attachment_ids => att.id}, :attachments => { "0" => { :uploaded_data => "" }, "-1" => { :uploaded_data => "" } }}
Expand All @@ -81,6 +86,7 @@

it "accepts 'eula_agreement_timestamp' params and persists it in the 'turnitin_data'" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => submission_type)
a1 = attachment_model(:context => @user)
post 'create',
Expand Down Expand Up @@ -128,6 +134,7 @@

it "should copy attachments to the submissions folder if that feature is enabled" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_upload")
att = attachment_model(:context => @user, :uploaded_data => stub_file_data('test.txt', 'asdf', 'text/plain'))
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_upload", :attachment_ids => att.id}, :attachments => { "0" => { :uploaded_data => "" }, "-1" => { :uploaded_data => "" } }}
Expand All @@ -142,6 +149,7 @@

it "should reject illegal file extensions from submission" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "an additional assignment", :submission_types => "online_upload", :allowed_extensions => ['txt'])
att = attachment_model(:context => @student, :uploaded_data => stub_file_data('test.m4v', 'asdf', 'video/mp4'))
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_upload", :attachment_ids => att.id}, :attachments => { "0" => { :uploaded_data => "" }, "-1" => { :uploaded_data => "" } }}
Expand All @@ -153,6 +161,7 @@

it "should use the appropriate group based on the assignment's category and the current user" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
group_category = @course.group_categories.create(:name => "Category")
@group = @course.groups.create(:name => "Group", :group_category => group_category)
@group.add_user(@user)
Expand All @@ -166,6 +175,7 @@

it "should not use a group if the assignment has no category" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
group_category = @course.group_categories.create(:name => "Category")
@group = @course.groups.create(:name => "Group", :group_category => group_category)
@group.add_user(@user)
Expand All @@ -178,6 +188,7 @@

it "should allow attaching multiple files to the submission" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
att1 = attachment_model(:context => @user, :uploaded_data => fixture_file_upload("docs/doc.doc", "application/msword", true))
att2 = attachment_model(:context => @user, :uploaded_data => fixture_file_upload("docs/txt.txt", "application/vnd.ms-excel", true))
Expand All @@ -197,6 +208,7 @@

it "should fail but not raise when the submission is invalid" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url")
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_url", :url => ""}} # blank url not allowed
expect(response).to be_redirect
Expand All @@ -206,6 +218,7 @@

it "should strip leading/trailing whitespace off url submissions" do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url")
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_url", :url => " http://www.google.com "}}
expect(response).to be_redirect
Expand All @@ -215,6 +228,7 @@

it 'must accept a basic_lti_launch url when any online submission type is allowed' do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(:title => 'some assignment', :submission_types => 'online_url')
request.path = "/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/submissions"
post 'create', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => 'basic_lti_launch', :url => 'http://www.google.com'}}
Expand All @@ -227,6 +241,7 @@
it 'accepts eula agreement timestamp when api submission' do
timestamp = Time.zone.now.to_i.to_s
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
attachment = attachment_model(context: @student)
@assignment = @course.assignments.create!(:title => 'some assignment', :submission_types => 'online_upload')
request.path = "/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/submissions"
Expand All @@ -248,6 +263,7 @@
now = Time.now.utc
Timecop.freeze(now) do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(
:title => "some assignment",
:submission_types => "online_url",
Expand Down Expand Up @@ -280,6 +296,7 @@
before do
Setting.set('enable_page_views', 'db')
course_with_student_logged_in :active_all => true
@course.account.enable_service(:avatars)
post 'create', params: {:course_id => @course.id, :assignment_id => assignment.id, :submission => submission_params}
end

Expand Down Expand Up @@ -315,6 +332,7 @@

it 'rejects an empty text response' do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
assignment = @course.assignments.create!(
:title => 'some assignment',
:submission_types => 'online_text_entry'
Expand All @@ -333,6 +351,7 @@
context "group comments" do
before do
course_with_student_logged_in(:active_all => true)
@course.account.enable_service(:avatars)
@u1 = @user
student_in_course(:course => @course)
@u2 = @user
Expand Down Expand Up @@ -425,6 +444,7 @@
context "google doc" do
before(:each) do
course_with_student_logged_in(active_all: true)
@course.account.enable_service(:avatars)
@assignment = @course.assignments.create!(title: 'some assignment', submission_types: 'online_upload')
end

Expand Down Expand Up @@ -468,6 +488,7 @@
it "should zip and download" do
local_storage!
course_with_student_and_submitted_homework
@course.account.enable_service(:avatars)

get 'index', params: {:course_id => @course.id, :assignment_id => @assignment.id, :zip => '1'}, format: 'json'
expect(response).to be_successful
Expand All @@ -490,6 +511,7 @@
describe "GET show" do
before do
course_with_student_and_submitted_homework
@course.account.enable_service(:avatars)
@context = @course
@submission.update!(score: 10)
end
Expand Down Expand Up @@ -615,6 +637,7 @@
context "with user id not present in course" do
before(:once) do
course_with_student(active_all: true)
@course.account.enable_service(:avatars)
end

it "sets flash error" do
Expand All @@ -630,6 +653,7 @@

it "should show rubric assessments to peer reviewers" do
course_with_student(active_all: true)
@course.account.enable_service(:avatars)
@assessor = @student
outcome_with_rubric
@association = @rubric.associate_with @assignment, @context, :purpose => 'grading'
Expand All @@ -650,6 +674,7 @@
context 'originality report' do
let(:test_course) do
test_course = course_factory(active_course: true)
test_course.account.enable_service(:avatars)
test_course.enroll_teacher(test_teacher, enrollment_state: 'active')
test_course.enroll_student(test_student, enrollment_state: 'active')
test_course
Expand Down Expand Up @@ -747,6 +772,7 @@
describe "GET audit_events" do
before(:once) do
@course = Course.create!
@course.account.enable_service(:avatars)
first_student = course_with_user("StudentEnrollment", course: @course, name: "First", active_all: true).user
second_student = course_with_user("StudentEnrollment", course: @course, name: "Second", active_all: true).user
@teacher = course_with_user("TeacherEnrollment", course: @course, name: "Teacher", active_all: true).user
Expand Down Expand Up @@ -817,6 +843,7 @@
describe "copy_attachments_to_submissions_folder" do
before(:once) do
course_with_student
@course.account.enable_service(:avatars)
attachment_model(context: @student)
end

Expand Down

0 comments on commit 911d9e9

Please sign in to comment.