spec: various non-selenium draft-state spec fixes
Change-Id: I936864c61f54a2b06209c53417d3c5935c895da7 Reviewed-on: https://gerrit.instructure.com/43267 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
639ca7075f
commit
873ea7c4ed
|
@ -264,11 +264,6 @@ describe AssignmentsApiController, type: :request do
|
|||
@assignment.save!
|
||||
end
|
||||
|
||||
it "should exclude published flag for accounts that do not have enabled_draft" do
|
||||
@json = api_get_assignment_in_course(@assignment, @course)
|
||||
expect(@json.has_key?('published')).to be_falsey
|
||||
end
|
||||
|
||||
it "should include published flag for accounts that do have enabled_draft" do
|
||||
@course.account.enable_feature!(:draft_state)
|
||||
|
||||
|
@ -814,7 +809,7 @@ describe AssignmentsApiController, type: :request do
|
|||
@override_due_at = Time.parse('2002 Jun 22 12:00:00')
|
||||
|
||||
@user = @teacher
|
||||
api_call(:post,
|
||||
json = api_call(:post,
|
||||
"/api/v1/courses/#{@course.id}/assignments.json",
|
||||
{
|
||||
:controller => 'assignments_api',
|
||||
|
@ -830,6 +825,9 @@ describe AssignmentsApiController, type: :request do
|
|||
}
|
||||
}
|
||||
})
|
||||
assignment = Assignment.find(json['id'])
|
||||
assignment.publish if assignment.unpublished?
|
||||
|
||||
expect(@student.messages.detect{|m| m.notification_id == notification.id}.body).
|
||||
to be_include 'Jun 22'
|
||||
expect(@ta.messages.detect{|m| m.notification_id == notification.id}.body).
|
||||
|
|
|
@ -124,6 +124,7 @@ describe DiscussionTopicsController, type: :request do
|
|||
end
|
||||
|
||||
it "should make a basic topic" do
|
||||
set_course_draft_state
|
||||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>" })
|
||||
|
@ -131,7 +132,7 @@ describe DiscussionTopicsController, type: :request do
|
|||
expect(@topic.title).to eq "test title"
|
||||
expect(@topic.message).to eq "test <b>message</b>"
|
||||
expect(@topic.threaded?).to be_falsey
|
||||
expect(@topic.published?).to be_truthy
|
||||
expect(@topic.published?).to be_falsey
|
||||
expect(@topic.post_delayed?).to be_falsey
|
||||
expect(@topic.podcast_enabled?).to be_falsey
|
||||
expect(@topic.podcast_has_student_posts?).to be_falsey
|
||||
|
@ -159,18 +160,19 @@ describe DiscussionTopicsController, type: :request do
|
|||
end
|
||||
|
||||
it "should create a topic with all the bells and whistles" do
|
||||
set_course_draft_state
|
||||
post_at = 1.month.from_now
|
||||
lock_at = 2.months.from_now
|
||||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>", :discussion_type => "threaded",
|
||||
{ :title => "test title", :message => "test <b>message</b>", :discussion_type => "threaded", :published => true,
|
||||
:delayed_post_at => post_at.as_json, :lock_at => lock_at.as_json, :podcast_has_student_posts => '1', :require_initial_post => '1' })
|
||||
@topic = @course.discussion_topics.order(:id).last
|
||||
expect(@topic.title).to eq "test title"
|
||||
expect(@topic.message).to eq "test <b>message</b>"
|
||||
expect(@topic.threaded?).to eq true
|
||||
expect(@topic.post_delayed?).to eq true
|
||||
expect(@topic.published?).to @topic.draft_state_enabled? ? be_truthy : be_falsey
|
||||
expect(@topic.published?).to be_truthy
|
||||
expect(@topic.delayed_post_at.to_i).to eq post_at.to_i
|
||||
expect(@topic.lock_at.to_i).to eq lock_at.to_i
|
||||
expect(@topic.podcast_enabled?).to eq true
|
||||
|
@ -1979,6 +1981,7 @@ describe DiscussionTopicsController, type: :request do
|
|||
it "should hold when the user isn't in a group set" do
|
||||
teacher_in_course(:active_all => true)
|
||||
group_discussion_assignment
|
||||
@topic.publish if @topic.unpublished?
|
||||
json = api_call(:get, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "index", :format => "json", :course_id => @course.id.to_s })
|
||||
expect(json[0]['subscription_hold']).to eql('not_in_group_set')
|
||||
|
@ -1987,6 +1990,7 @@ describe DiscussionTopicsController, type: :request do
|
|||
it "should hold when the user isn't in a group" do
|
||||
teacher_in_course(:active_all => true)
|
||||
group_discussion_assignment
|
||||
@topic.publish if @topic.unpublished?
|
||||
child = @topic.child_topics.first
|
||||
group = child.context
|
||||
json = api_call(:get, "/api/v1/groups/#{group.id}/discussion_topics",
|
||||
|
@ -2310,6 +2314,7 @@ def create_topic(context, opts={})
|
|||
topic = context.discussion_topics.build(opts)
|
||||
topic.attachment = attachment if attachment
|
||||
topic.save!
|
||||
topic.publish if topic.unpublished?
|
||||
topic
|
||||
end
|
||||
|
||||
|
|
|
@ -227,13 +227,15 @@ describe "Pages API", type: :request do
|
|||
end
|
||||
|
||||
it "should retrieve page content and attributes" do
|
||||
set_course_draft_state
|
||||
@hidden_page.publish
|
||||
json = api_call(:get, "/api/v1/courses/#{@course.id}/pages/#{@hidden_page.url}",
|
||||
:controller=>"wiki_pages_api", :action=>"show", :format=>"json", :course_id=>"#{@course.id}", :url=>@hidden_page.url)
|
||||
expected = { "hide_from_students" => true,
|
||||
expected = { "hide_from_students" => false,
|
||||
"editing_roles" => "teachers",
|
||||
"last_edited_by" => user_display_json(@teacher, @course).stringify_keys!,
|
||||
"url" => @hidden_page.url,
|
||||
"html_url" => "http://www.example.com/courses/#{@course.id}/wiki/#{@hidden_page.url}",
|
||||
"html_url" => "http://www.example.com/courses/#{@course.id}/#{@course.wiki.path}/#{@hidden_page.url}",
|
||||
"created_at" => @hidden_page.created_at.as_json,
|
||||
"updated_at" => @hidden_page.updated_at.as_json,
|
||||
"title" => @hidden_page.title,
|
||||
|
@ -256,7 +258,7 @@ describe "Pages API", type: :request do
|
|||
expected = { "hide_from_students" => false,
|
||||
"editing_roles" => "teachers",
|
||||
"url" => page.url,
|
||||
"html_url" => "http://www.example.com/courses/#{@course.id}/wiki/#{page.url}",
|
||||
"html_url" => "http://www.example.com/courses/#{@course.id}/#{@course.wiki.path}/#{page.url}",
|
||||
"created_at" => page.created_at.as_json,
|
||||
"updated_at" => page.updated_at.as_json,
|
||||
"title" => page.title,
|
||||
|
@ -269,31 +271,6 @@ describe "Pages API", type: :request do
|
|||
expect(json).to eq expected
|
||||
end
|
||||
|
||||
it "should implicitly find the 'front-page' if no front page is set" do
|
||||
@wiki.reload
|
||||
@wiki.front_page_url = nil
|
||||
@wiki.has_no_front_page = nil
|
||||
@wiki.save!
|
||||
|
||||
json = api_call(:get, "/api/v1/courses/#{@course.id}/front_page",
|
||||
:controller=>"wiki_pages_api", :action=>"show_front_page", :format=>"json", :course_id=>"#{@course.id}")
|
||||
|
||||
expected = { "hide_from_students" => false,
|
||||
"editing_roles" => "teachers",
|
||||
"url" => @front_page.url,
|
||||
"html_url" => "http://www.example.com/courses/#{@course.id}/wiki/#{@front_page.url}",
|
||||
"created_at" => @front_page.created_at.as_json,
|
||||
"updated_at" => @front_page.updated_at.as_json,
|
||||
"title" => @front_page.title,
|
||||
"body" => @front_page.body,
|
||||
"published" => true,
|
||||
"front_page" => true,
|
||||
"locked_for_user" => false,
|
||||
"page_id" => @front_page.id
|
||||
}
|
||||
expect(json).to eq expected
|
||||
end
|
||||
|
||||
it "should give a meaningful error if there is no front page" do
|
||||
@front_page.workflow_state = 'deleted'
|
||||
@front_page.save!
|
||||
|
@ -563,21 +540,22 @@ describe "Pages API", type: :request do
|
|||
|
||||
describe "update" do
|
||||
it "should update page content and attributes" do
|
||||
set_course_draft_state
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@hidden_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @hidden_page.url },
|
||||
{ :wiki_page => { :title => 'No Longer Hidden Page', :hide_from_students => false,
|
||||
{ :wiki_page => { :title => 'No Longer Hidden Page',
|
||||
:body => 'Information wants to be free' }})
|
||||
@hidden_page.reload
|
||||
expect(@hidden_page).to be_active
|
||||
expect(@hidden_page.hide_from_students).to be_falsey
|
||||
expect(@hidden_page.title).to eq 'No Longer Hidden Page'
|
||||
expect(@hidden_page.body).to eq 'Information wants to be free'
|
||||
expect(@hidden_page.user_id).to eq @teacher.id
|
||||
end
|
||||
|
||||
it "should update front_page" do
|
||||
set_course_draft_state true
|
||||
page = @course.wiki.wiki_pages.create!(:title => "hrup", :body => "blooop")
|
||||
page.publish
|
||||
page.set_as_front_page!
|
||||
|
||||
new_title = 'blah blah blah'
|
||||
|
@ -591,6 +569,7 @@ describe "Pages API", type: :request do
|
|||
end
|
||||
|
||||
it "should set as front page" do
|
||||
set_course_draft_state true
|
||||
wiki = @course.wiki
|
||||
expect(wiki.unset_front_page!).to eq true
|
||||
|
||||
|
@ -598,7 +577,7 @@ describe "Pages API", type: :request do
|
|||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @hidden_page.url },
|
||||
{ :wiki_page => { :title => 'No Longer Hidden Page', :hide_from_students => false,
|
||||
:body => 'Information wants to be free', :front_page => true }})
|
||||
:body => 'Information wants to be free', :front_page => true, :published => true}})
|
||||
no_longer_hidden_page = @hidden_page
|
||||
no_longer_hidden_page.reload
|
||||
expect(no_longer_hidden_page.is_front_page?).to be_truthy
|
||||
|
@ -610,6 +589,7 @@ describe "Pages API", type: :request do
|
|||
end
|
||||
|
||||
it "should un-set as front page" do
|
||||
set_course_draft_state true
|
||||
wiki = @course.wiki
|
||||
wiki.reload
|
||||
expect(wiki.has_front_page?).to be_truthy
|
||||
|
@ -627,7 +607,6 @@ describe "Pages API", type: :request do
|
|||
|
||||
wiki.reload
|
||||
expect(wiki.has_front_page?).to be_falsey
|
||||
expect(wiki.front_page).to be_new_record
|
||||
|
||||
expect(json['front_page']).to eq false
|
||||
end
|
||||
|
@ -694,48 +673,6 @@ describe "Pages API", type: :request do
|
|||
@test_page.save!
|
||||
end
|
||||
|
||||
context 'without draft state' do
|
||||
before :once do
|
||||
set_course_draft_state false
|
||||
end
|
||||
|
||||
it 'should accept hide_from_students' do
|
||||
json = api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@test_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param, :url => @test_page.url },
|
||||
{ :wiki_page => {'hide_from_students' => 'true'} })
|
||||
expect(json['published']).to be_truthy
|
||||
expect(json['hide_from_students']).to be_truthy
|
||||
|
||||
@test_page.reload
|
||||
expect(@test_page).to be_unpublished
|
||||
expect(@test_page.hide_from_students).to be_truthy
|
||||
end
|
||||
|
||||
it 'should not set hide_from_students to nil' do
|
||||
json = api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@test_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param, :url => @test_page.url },
|
||||
{ :wiki_page => {'hide_from_students' => nil} })
|
||||
expect(json['published']).to be_truthy
|
||||
expect(json['hide_from_students']).to be_falsey
|
||||
|
||||
@test_page.reload
|
||||
expect(@test_page).to be_active
|
||||
expect(@test_page.hide_from_students).to be_falsey
|
||||
end
|
||||
|
||||
it 'should ignore published' do
|
||||
json = api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@test_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param, :url => @test_page.url },
|
||||
{ :wiki_page => {'published' => 'false'} })
|
||||
expect(json['published']).to be_truthy
|
||||
expect(json['hide_from_students']).to be_falsey
|
||||
|
||||
@test_page.reload
|
||||
expect(@test_page).to be_active
|
||||
expect(@test_page.hide_from_students).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context 'with draft state' do
|
||||
before :once do
|
||||
set_course_draft_state true
|
||||
|
@ -1060,37 +997,6 @@ describe "Pages API", type: :request do
|
|||
expect(@editable_page.body).to eq '?!?!'
|
||||
expect(@editable_page.user_id).to eq @student.id
|
||||
end
|
||||
|
||||
it "should not allow editing attributes" do
|
||||
set_course_draft_state false
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@editable_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @editable_page.url },
|
||||
{ :wiki_page => { :hide_from_students => true }},
|
||||
{}, {:expected_status => 401})
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@editable_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @editable_page.url },
|
||||
{ :wiki_page => { :title => 'Broken Links' }},
|
||||
{}, {:expected_status => 401})
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@editable_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @editable_page.url },
|
||||
{ :wiki_page => { :editing_roles => 'teachers' }},
|
||||
{}, {:expected_status => 401})
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{@editable_page.url}",
|
||||
{ :controller => 'wiki_pages_api', :action => 'update', :format => 'json', :course_id => @course.to_param,
|
||||
:url => @editable_page.url },
|
||||
{ :wiki_page => { :editing_roles => 'teachers,students,public' }},
|
||||
{}, {:expected_status => 401})
|
||||
|
||||
@editable_page.reload
|
||||
expect(@editable_page).to be_active
|
||||
expect(@editable_page.hide_from_students).to be_falsey
|
||||
expect(@editable_page.title).to eq 'Editable Page'
|
||||
expect(@editable_page.user_id).not_to eq @student.id
|
||||
expect(@editable_page.editing_roles).to eq 'students'
|
||||
end
|
||||
|
||||
it 'should not allow editing attributes (with draft state)' do
|
||||
set_course_draft_state
|
||||
|
|
|
@ -54,33 +54,6 @@ describe AssignmentsController do
|
|||
expect(flash[:notice]).to match(/That page has been disabled/)
|
||||
end
|
||||
|
||||
it "should assign variables" do
|
||||
user_session(@student)
|
||||
|
||||
get 'index', :course_id => @course.id
|
||||
expect(assigns[:assignments]).not_to be_nil
|
||||
expect(assigns[:assignment_groups]).not_to be_nil
|
||||
end
|
||||
|
||||
it "should retrieve course assignments if they exist" do
|
||||
user_session(@student)
|
||||
|
||||
get 'index', :course_id => @course.id
|
||||
expect(assigns[:assignment_groups]).not_to be_nil
|
||||
expect(assigns[:assignment_groups]).not_to be_empty
|
||||
expect(assigns[:assignments]).not_to be_nil
|
||||
expect(assigns[:assignments]).not_to be_empty
|
||||
expect(assigns[:assignments][0]).to eql(@assignment)
|
||||
end
|
||||
|
||||
it "should create a default group if none exist" do
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
|
||||
get 'index', :course_id => @course.id
|
||||
|
||||
expect(assigns[:assignment_groups][0].name).to eql("Assignments")
|
||||
end
|
||||
|
||||
context "draft state" do
|
||||
before :once do
|
||||
@course.root_account.enable_feature!(:draft_state)
|
||||
|
|
|
@ -186,9 +186,11 @@ describe ContextModulesController do
|
|||
|
||||
tag1 = @module.add_item :type => 'context_external_tool', :id => @tool1.id, :url => @tool1.url
|
||||
expect(tag1.content_id).to eq @tool1.id
|
||||
tag1.publish if tag1.unpublished?
|
||||
tag2 = @module.add_item :type => 'context_external_tool', :id => @tool2.id, :url => @tool2.url
|
||||
expect(tag2.content_id).to eq @tool2.id
|
||||
|
||||
tag2.publish if tag2.unpublished?
|
||||
|
||||
get 'item_redirect', :course_id => @course.id, :id => tag1.id
|
||||
expect(response).not_to be_redirect
|
||||
expect(assigns[:tool]).to eq @tool1
|
||||
|
@ -205,6 +207,7 @@ describe ContextModulesController do
|
|||
@tool1 = @course.context_external_tools.create!(:name => "a", :url => "http://www.google.com", :consumer_key => '12345', :shared_secret => 'secret')
|
||||
|
||||
tag1 = @module.add_item :type => 'context_external_tool', :id => @tool1.id, :url => @tool1.url
|
||||
tag1.publish if tag1.unpublished?
|
||||
@tool1.update_attribute(:url, 'http://www.example.com')
|
||||
|
||||
get 'item_redirect', :course_id => @course.id, :id => tag1.id
|
||||
|
@ -247,7 +250,8 @@ describe ContextModulesController do
|
|||
quiz.publish!
|
||||
|
||||
tag = @module.add_item :type => 'quiz', :id => quiz.id
|
||||
|
||||
tag.publish if tag.unpublished?
|
||||
|
||||
get 'item_redirect', :course_id => @course.id, :id => tag.id
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to course_quiz_url(@course, quiz, :module_item_id => tag.id)
|
||||
|
@ -257,6 +261,7 @@ describe ContextModulesController do
|
|||
user_session(@student)
|
||||
@module = @course.context_modules.create!
|
||||
tag = @module.add_item :type => 'external_url', :url => 'http://lolcats', :title => 'lol'
|
||||
tag.publish if tag.unpublished?
|
||||
@module.completion_requirements = { tag.id => { :type => 'must_view' }}
|
||||
@module.save!
|
||||
expect(@module.evaluate_for(@user)).to be_unlocked
|
||||
|
|
|
@ -475,6 +475,7 @@ describe CoursesController do
|
|||
@enrollment.start_at = 2.days.from_now
|
||||
@enrollment.end_at = 4.days.from_now
|
||||
@enrollment.save!
|
||||
controller.instance_variable_set(:@js_env, nil)
|
||||
get 'show', :id => @course.id
|
||||
assert_status(401)
|
||||
expect(assigns[:unauthorized_reason]).to eq :unpublished
|
||||
|
@ -523,6 +524,7 @@ describe CoursesController do
|
|||
a.save!
|
||||
|
||||
controller.instance_variable_set(:@context_all_permissions, nil)
|
||||
controller.instance_variable_set(:@js_env, nil)
|
||||
|
||||
get 'show', :id => @course.id
|
||||
expect(response).to be_success
|
||||
|
@ -672,6 +674,7 @@ describe CoursesController do
|
|||
@course.workflow_state = 'claimed'
|
||||
@course.save!
|
||||
|
||||
controller.instance_variable_set(:@js_env, nil)
|
||||
get 'show', :id => @course.id, :invitation => @enrollment.uuid
|
||||
assert_status(401)
|
||||
expect(assigns[:unauthorized_message]).not_to be_nil
|
||||
|
@ -739,6 +742,7 @@ describe CoursesController do
|
|||
@enrollment.reload
|
||||
expect(@enrollment).to be_invited
|
||||
|
||||
controller.instance_variable_set(:@js_env, nil)
|
||||
get 'show', :id => @course.id # invitation should be in the session now
|
||||
expect(response).to be_success
|
||||
expect(assigns[:pending_enrollment]).to eq @enrollment
|
||||
|
@ -780,6 +784,7 @@ describe CoursesController do
|
|||
permissions_key = session[:permissions_key]
|
||||
|
||||
controller.instance_variable_set(:@pending_enrollment, nil)
|
||||
controller.instance_variable_set(:@js_env, nil)
|
||||
get 'show', :id => @course2.id
|
||||
expect(response).to be_success
|
||||
expect(assigns[:pending_enrollment]).to eq @enrollment2
|
||||
|
|
|
@ -480,11 +480,6 @@ describe GradebooksController do
|
|||
expect(response).not_to be_redirect
|
||||
end
|
||||
|
||||
it "does not redirect if draft state isn't enabled" do
|
||||
get 'speed_grader', course_id: @course, assignment_id: @assign.id
|
||||
expect(response).not_to be_redirect
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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)
|
||||
expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).not_to be_nil
|
||||
expect(doc.at_css('.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)
|
||||
expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).to be_nil
|
||||
expect(doc.at_css('.add_module_link')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -196,36 +196,4 @@ describe "varied due dates" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "on the assignments page" do
|
||||
|
||||
def formatted_date(string)
|
||||
TextHelper.date_string(string)
|
||||
end
|
||||
|
||||
context "an assignment that has a course due date and a section due date" do
|
||||
|
||||
describe "as an account admin, accessing the course assignments page" do
|
||||
before do
|
||||
account_admin_user(active_all: true)
|
||||
user_session(@admin)
|
||||
end
|
||||
|
||||
context "with overrides" do
|
||||
it "shows multiple due dates" do
|
||||
get course_assignments_path(@course)
|
||||
expect(response.body).to include multiple_due_dates
|
||||
end
|
||||
end
|
||||
|
||||
context "with no overrides" do
|
||||
it "shows the course due date" do
|
||||
AssignmentOverride.delete_all
|
||||
get course_assignments_path(@course)
|
||||
expect(response.body).to include formatted_date(@course_due_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -595,6 +595,7 @@ describe AssignmentOverrideApplicator do
|
|||
context "without draft states" do
|
||||
it "skips versions of the override that have nil for an assignment version" do
|
||||
student_in_course
|
||||
set_course_draft_state
|
||||
expected_time = Time.zone.now
|
||||
quiz = @course.quizzes.create! :title => "VDD Quiz", :quiz_type => 'assignment'
|
||||
section = @course.course_sections.create! :name => "title"
|
||||
|
@ -613,9 +614,8 @@ describe AssignmentOverrideApplicator do
|
|||
override.save!
|
||||
quiz.publish!
|
||||
override = quiz.reload.assignment.assignment_overrides.first
|
||||
expect(override.versions.length).to eq 2
|
||||
expect(override.versions.length).to eq 1
|
||||
expect(override.versions[0].model.assignment_version).not_to be_nil
|
||||
expect(override.versions[1].model.assignment_version).to be_nil
|
||||
# Assert that it won't call the "<=" method on nil
|
||||
expect do
|
||||
overrides = AssignmentOverrideApplicator.
|
||||
|
|
|
@ -185,10 +185,13 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
|
|||
@wiki.destroy
|
||||
@announcement.destroy
|
||||
@topic.destroy
|
||||
assignment_model.destroy
|
||||
quiz_model.destroy
|
||||
calendar_event_model.destroy
|
||||
rubric_model.destroy
|
||||
|
||||
@course.require_assignment_group
|
||||
@course.assignments.create!(:name => "blah").destroy
|
||||
@course.assignment_groups.create!(:name => "blah").destroy
|
||||
@course.quizzes.create!(:name => "blah").destroy
|
||||
@course.calendar_events.create!(:name => "blah").destroy
|
||||
@course.rubrics.create!(:name => "blah").destroy
|
||||
end
|
||||
|
||||
it "should ignore in top-level list" do
|
||||
|
@ -202,7 +205,10 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
|
|||
expect(@formatter.get_content_list('attachments').length).to eq 0
|
||||
expect(@formatter.get_content_list('discussion_topics').length).to eq 0
|
||||
expect(@formatter.get_content_list('announcements').length).to eq 0
|
||||
expect(@formatter.get_content_list('assignments').length).to eq 0
|
||||
|
||||
expect(@formatter.get_content_list('assignments').length).to eq 1 # the default assignment group
|
||||
expect(@formatter.get_content_list('assignments').first[:sub_items]).to be_blank
|
||||
|
||||
expect(@formatter.get_content_list('quizzes').length).to eq 0
|
||||
expect(@formatter.get_content_list('calendar_events').length).to eq 0
|
||||
expect(@formatter.get_content_list('rubrics').length).to eq 0
|
||||
|
|
|
@ -602,7 +602,7 @@ describe "Canvas Cartridge importing" do
|
|||
body_with_link = %{<p>Watup? <strong>eh?</strong>
|
||||
<a href=\"/courses/%s/assignments\">Assignments</a>
|
||||
<a href=\"/courses/%s/file_contents/course%%20files/tbe_banner.jpg\">Some file</a>
|
||||
<a href=\"/courses/%s/wiki/assignments\">Assignments wiki link</a>
|
||||
<a href=\"/courses/%s/#{@copy_to.wiki.path}/assignments\">Assignments wiki link</a>
|
||||
<a href=\"/courses/%s/modules\">Modules</a>
|
||||
<a href=\"/courses/%s/modules/%s\">some module</a>
|
||||
<img src="/courses/%s/files/%s/preview" alt="picture.png" /></p>
|
||||
|
|
|
@ -286,15 +286,16 @@ describe GradeCalculator do
|
|||
expect(@user.enrollments.first.computed_current_score).to eql(60.0)
|
||||
expect(@user.enrollments.first.computed_final_score).to eql(60.0)
|
||||
end
|
||||
|
||||
|
||||
it "should recalculate all cached grades when an assignment is deleted/restored" do
|
||||
two_graded_assignments
|
||||
@assignment2.destroy
|
||||
@user.reload
|
||||
expect(@user.enrollments.first.computed_current_score).to eql(40.0) # 2/5
|
||||
expect(@user.enrollments.first.computed_final_score).to eql(40.0)
|
||||
|
||||
|
||||
@assignment2.restore
|
||||
@assignment2.publish if @assignment2.unpublished?
|
||||
@user.reload
|
||||
expect(@user.enrollments.first.computed_current_score).to eql(60.0)
|
||||
expect(@user.enrollments.first.computed_final_score).to eql(60.0)
|
||||
|
|
Loading…
Reference in New Issue