restore ssa and discussions using undelete
fixes COMMS-1048 Test Plan: - Delete a section specific announcement - go to http://localhost:3000/courses/:id/undelete - see the deleted section specific announcement - click restore - refresh the page - notice its no longer on the undelete page - go to the announcements page - notice it has shown back up Change-Id: Ief3a2d4356b85759e6d45021143bd9b68717ac35 Reviewed-on: https://gerrit.instructure.com/147142 Reviewed-by: Aaron Kc Hsu <ahsu@instructure.com> Tested-by: Jenkins QA-Review: Venk Natarajan <vnatarajan@instructure.com> Product-Review: Steven Burnett <sburnett@instructure.com>
This commit is contained in:
parent
87c5d43b83
commit
05d4ade0c9
|
@ -952,6 +952,12 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def restore(from=nil)
|
||||
if self.is_section_specific?
|
||||
DiscussionTopicSectionVisibility.where(discussion_topic_id: self.id).to_a.uniq(&:course_section_id).each do |dtsv|
|
||||
dtsv.workflow_state = 'active'
|
||||
dtsv.save
|
||||
end
|
||||
end
|
||||
self.workflow_state = can_unpublish? ? 'unpublished' : 'active'
|
||||
self.save
|
||||
|
||||
|
|
|
@ -1957,6 +1957,24 @@ describe DiscussionTopic do
|
|||
expect(ann.reload).to be_active
|
||||
end
|
||||
|
||||
it "should restore an announcement to active state with sections" do
|
||||
section = @course.course_sections.create!
|
||||
@course.save!
|
||||
announcement = Announcement.create!(
|
||||
:title => "some topic",
|
||||
:message => "I announce that i am lying",
|
||||
:user => @teacher,
|
||||
:context => @course,
|
||||
:workflow_state => "published"
|
||||
)
|
||||
add_section_to_topic(announcement, section)
|
||||
announcement.save!
|
||||
announcement.destroy
|
||||
|
||||
announcement.restore
|
||||
expect(announcement.reload).to be_active
|
||||
end
|
||||
|
||||
it "should restore a topic with submissions to active state" do
|
||||
discussion_topic_model(:context => @course)
|
||||
@topic.reply_from(user: @student, text: "huttah!")
|
||||
|
|
Loading…
Reference in New Issue