Fix module cache on discussion section change
Test Plan: - Change `config.action_controller.perform_caching` from false to true in config/environments/development.rb - Create a course with two sections - Create a student in the course that belongs to one of the sections - Create a non-graded discussion in the course, that can be viewed by all sections - Create a module in the course, then add the discussion to that module - As the student, visit the module, and verify you can see the discussion - As a teacher, modify the discussion so that it is restricted to the section that the student is not in - Refresh the module page as the student, and notice that you no longer see the discussion - Change `config.action_controller.perform_caching` in step 1 back to false fixes COMMS-2045 flag = none Change-Id: I230444533c3f446cf996a632275f60f3bab301a8 Reviewed-on: https://gerrit.instructure.com/211575 Tested-by: Jenkins QA-Review: Landon Gilbert-Bland <lbland@instructure.com> Reviewed-by: Ryan Norton <rnorton@instructure.com> Product-Review: Landon Gilbert-Bland <lbland@instructure.com>
This commit is contained in:
parent
88eaabeed6
commit
6317bb670e
|
@ -204,7 +204,10 @@ class DiscussionTopic < ActiveRecord::Base
|
||||||
return unless self.is_section_specific? ? @sections_changed : self.is_section_specific_before_last_save
|
return unless self.is_section_specific? ? @sections_changed : self.is_section_specific_before_last_save
|
||||||
self.class.connection.after_transaction_commit do
|
self.class.connection.after_transaction_commit do
|
||||||
if self.context_module_tags.preload(:context_module).exists?
|
if self.context_module_tags.preload(:context_module).exists?
|
||||||
self.context_module_tags.map(&:context_module).uniq.each(&:invalidate_progressions)
|
self.context_module_tags.map(&:context_module).uniq.each do |cm|
|
||||||
|
cm.invalidate_progressions
|
||||||
|
cm.touch
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,6 +36,7 @@ describe DiscussionTopic do
|
||||||
opts.reverse_merge!({
|
opts.reverse_merge!({
|
||||||
:workflow_state => "active"
|
:workflow_state => "active"
|
||||||
})
|
})
|
||||||
|
topic.sections_changed = true
|
||||||
topic.is_section_specific = true
|
topic.is_section_specific = true
|
||||||
topic.discussion_topic_section_visibilities <<
|
topic.discussion_topic_section_visibilities <<
|
||||||
DiscussionTopicSectionVisibility.new(
|
DiscussionTopicSectionVisibility.new(
|
||||||
|
@ -300,6 +301,18 @@ describe DiscussionTopic do
|
||||||
expect(@topic.visible_for?(@student)).to be_truthy
|
expect(@topic.visible_for?(@student)).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should clear the context modules cache on section change' do
|
||||||
|
context_module = @course.context_modules.create!(name: 'some module')
|
||||||
|
context_module.add_item(type: 'discussion_topic', id: @topic.id)
|
||||||
|
context_module.updated_at = 1.day.ago
|
||||||
|
context_module.save!
|
||||||
|
last_updated_at = context_module.updated_at
|
||||||
|
add_section_to_topic(@topic, @course.course_sections.create!)
|
||||||
|
@topic.save!
|
||||||
|
context_module.reload
|
||||||
|
expect(last_updated_at).not_to eq context_module.updated_at
|
||||||
|
end
|
||||||
|
|
||||||
it "should be visible to students when topic delayed_post_at is in the future" do
|
it "should be visible to students when topic delayed_post_at is in the future" do
|
||||||
@topic.delayed_post_at = 5.days.from_now
|
@topic.delayed_post_at = 5.days.from_now
|
||||||
@topic.save!
|
@topic.save!
|
||||||
|
|
Loading…
Reference in New Issue