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:
parent
5d7ee18164
commit
8dbbb0a622
|
@ -487,15 +487,17 @@ class DiscussionTopicsController < ApplicationController
|
|||
# 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.
|
||||
elsif params.has_key?(:locked) && !params[:locked].is_a?(Hash)
|
||||
discussion_topic_hash[:delayed_post_at] = nil
|
||||
discussion_topic_hash[:lock_at] = nil
|
||||
|
||||
if value_to_boolean(params[:locked])
|
||||
should_lock = value_to_boolean(params[:locked])
|
||||
if should_lock != @topic.locked?
|
||||
if should_lock
|
||||
@topic.lock
|
||||
else
|
||||
discussion_topic_hash[:delayed_post_at] = nil
|
||||
discussion_topic_hash[:lock_at] = nil
|
||||
@topic.unlock
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @topic.update_attributes(discussion_topic_hash)
|
||||
log_asset_access(@topic, 'topics', 'topics', 'participate')
|
||||
|
|
|
@ -321,6 +321,15 @@ describe DiscussionTopicsController do
|
|||
locked: false)
|
||||
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue