preserve discussion dates when locked state is unchanged

editing a discussion topic would clear the lock dates because
the view passes the current lock state to the controller
action. so we don't want to clear the dates unconditionally
when the lock state is passed in, only if it's changed.

fixes CNVS-6841

test plan:
 - create a discussion with available from and until dates in
   the future.
 - edit the discussion and change the body, but do not change
   the dates.
 - click edit again and make sure the available from and until
   daates have not been cleared
 - make sure CNVS-6762 is still fixed

Change-Id: Ic83fec7d65223c94ee6c99da630c9ae41b4b4393
Reviewed-on: https://gerrit.instructure.com/22274
Reviewed-by: Mark Ericksen <marke@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
This commit is contained in:
Jon Willesen 2013-07-12 09:56:25 -06:00
parent 5d7ee18164
commit 8dbbb0a622
2 changed files with 18 additions and 7 deletions

View File

@ -487,13 +487,15 @@ class DiscussionTopicsController < ApplicationController
# Handle locking/unlocking (overrides workflow state if provided). It appears that the locked param as a hash # Handle locking/unlocking (overrides workflow state if provided). It appears that the locked param as a hash
# is from old code and is not being used. Verification requested. # is from old code and is not being used. Verification requested.
elsif params.has_key?(:locked) && !params[:locked].is_a?(Hash) elsif params.has_key?(:locked) && !params[:locked].is_a?(Hash)
discussion_topic_hash[:delayed_post_at] = nil should_lock = value_to_boolean(params[:locked])
discussion_topic_hash[:lock_at] = nil if should_lock != @topic.locked?
if should_lock
if value_to_boolean(params[:locked]) @topic.lock
@topic.lock else
else discussion_topic_hash[:delayed_post_at] = nil
@topic.unlock discussion_topic_hash[:lock_at] = nil
@topic.unlock
end
end end
end end

View File

@ -321,6 +321,15 @@ describe DiscussionTopicsController do
locked: false) locked: false)
@topic.reload.should_not be_locked @topic.reload.should_not be_locked
@topic.lock_at.should be_nil
end
it "should not clear lock_at if lock state hasn't changed" do
put('update', course_id: @course.id, topic_id: @topic.id,
title: 'Updated Topic', format: 'json', lock_at: @topic.lock_at,
locked: true)
@topic.reload.should be_locked
@topic.lock_at.should_not be_nil
end end
end end
end end