clear discussion availability dates with null assignment dates
test plan: * save a discussion topic with availability dates set * edit it to set it to a graded topic but leave the assignment dates blank * the original availability dates for the topic should not persist on the discussions index closes #CNVS-38362 Change-Id: I28c565cb23c7fa2da3b16449ae189f44040b88c1 Reviewed-on: https://gerrit.instructure.com/123990 Tested-by: Jenkins Reviewed-by: Dan Minkevitch <dan@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
cda3a3e6c4
commit
5228fe9bb8
|
@ -1040,8 +1040,8 @@ class DiscussionTopicsController < ApplicationController
|
|||
|
||||
def prefer_assignment_availability_dates(discussion_topic_hash)
|
||||
return unless params[:assignment]
|
||||
discussion_topic_hash['delayed_post_at'] = nil if params[:assignment][:unlock_at].present?
|
||||
discussion_topic_hash['lock_at'] = nil if params[:assignment][:lock_at].present?
|
||||
discussion_topic_hash['delayed_post_at'] = nil if params[:assignment].has_key?(:unlock_at)
|
||||
discussion_topic_hash['lock_at'] = nil if params[:assignment].has_key?(:lock_at)
|
||||
end
|
||||
|
||||
# Internal: detetermines if the delayed_post_at or lock_at dates were changed
|
||||
|
|
|
@ -804,6 +804,16 @@ describe DiscussionTopicsController, type: :request do
|
|||
expect(@topic).not_to be_locked
|
||||
expect(@topic.delayed_post_at).to be_nil
|
||||
expect(@topic.lock_at).to be_nil
|
||||
|
||||
# should work even if the assignment dates are nil
|
||||
api_call(:put, "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}",
|
||||
{:controller => "discussion_topics", :action => "update", :format => "json", :course_id => @course.to_param, :topic_id => @topic.to_param},
|
||||
{:delayed_post_at => 2.weeks.ago.as_json, :lock_at => 1.week.ago.as_json,
|
||||
:assignment => {:unlock_at => nil, :lock_at => nil}})
|
||||
expect(@topic.reload.assignment.reload.unlock_at).to be_nil
|
||||
expect(@topic.assignment.lock_at).to be_nil
|
||||
expect(@topic.delayed_post_at).to be_nil
|
||||
expect(@topic.lock_at).to be_nil
|
||||
end
|
||||
|
||||
it "should update due dates with cache enabled" do
|
||||
|
|
Loading…
Reference in New Issue