make atom feed respect differentiated assignments
test plan: - ensure the /courses/X/public_feed and /users/X/public_feed endpoints exclude assignments (and graded discussions) not visible to the user due to overrides fixes ADMIN-2572 Change-Id: Ib59a7486e8382f20eae8d0e9a094d98bd2382c6b Reviewed-on: https://gerrit.instructure.com/188527 Tested-by: Jenkins Reviewed-by: Rex Fleischer <rfleischer@instructure.com> QA-Review: Rex Fleischer <rfleischer@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
6338a9f9bd
commit
4c7408098c
|
@ -2679,13 +2679,14 @@ class CoursesController < ApplicationController
|
|||
f.updated = Time.now
|
||||
f.id = course_url(@context)
|
||||
end
|
||||
|
||||
@entries = []
|
||||
@entries.concat @context.assignments.published
|
||||
@entries.concat Assignments::ScopedToUser.new(@context, @current_user, @context.assignments.published).scope
|
||||
@entries.concat @context.calendar_events.active
|
||||
@entries.concat(@context.discussion_topics.published.select{ |dt|
|
||||
@entries.concat DiscussionTopic::ScopedToUser.new(@context, @current_user, @context.discussion_topics.published).scope.select{ |dt|
|
||||
!dt.locked_for?(@current_user, :check_policies => true)
|
||||
})
|
||||
@entries.concat @context.wiki_pages.published
|
||||
}
|
||||
@entries.concat WikiPages::ScopedToUser.new(@context, @current_user, @context.wiki_pages.published).scope
|
||||
@entries = @entries.sort_by{|e| e.updated_at}
|
||||
@entries.each do |entry|
|
||||
feed.entries << entry.to_atom(:context => @context)
|
||||
|
|
|
@ -760,8 +760,10 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
@entries = []
|
||||
@entries.concat @context.calendar_events.active
|
||||
@entries.concat @context.discussion_topics.published
|
||||
@entries.concat @context.wiki_pages.published
|
||||
@entries.concat DiscussionTopic::ScopedToUser.new(@context, @current_user, @context.discussion_topics.published).scope.select{ |dt|
|
||||
!dt.locked_for?(@current_user, :check_policies => true)
|
||||
}
|
||||
@entries.concat WikiPages::ScopedToUser.new(@context, @current_user, @context.wiki_pages.published).scope
|
||||
@entries = @entries.sort_by{|e| e.updated_at}
|
||||
@entries.each do |entry|
|
||||
feed.entries << entry.to_atom(:context => @context)
|
||||
|
|
|
@ -2064,10 +2064,12 @@ class UsersController < ApplicationController
|
|||
@entries = []
|
||||
cutoff = 1.week.ago
|
||||
@context.courses.each do |context|
|
||||
@entries.concat context.assignments.published.where("updated_at>?", cutoff)
|
||||
@entries.concat Assignments::ScopedToUser.new(context, @current_user, context.assignments.published.where("assignments.updated_at>?", cutoff)).scope
|
||||
@entries.concat context.calendar_events.active.where("updated_at>?", cutoff)
|
||||
@entries.concat context.discussion_topics.published.where("updated_at>?", cutoff)
|
||||
@entries.concat context.wiki_pages.published.where("updated_at>?", cutoff)
|
||||
@entries.concat DiscussionTopic::ScopedToUser.new(context, @current_user, context.discussion_topics.published.where("discussion_topics.updated_at>?", cutoff)).scope.select { |dt|
|
||||
!dt.locked_for?(@current_user, :check_policies => true)
|
||||
}
|
||||
@entries.concat WikiPages::ScopedToUser.new(context, @current_user, context.wiki_pages.published.where("wiki_pages.updated_at>?", cutoff)).scope
|
||||
end
|
||||
@entries.each do |entry|
|
||||
feed.entries << entry.to_atom(:include_context => true, :context => @context)
|
||||
|
|
|
@ -2227,6 +2227,28 @@ describe CoursesController do
|
|||
expect(feed).not_to be_nil
|
||||
expect(feed.entries).to be_empty
|
||||
end
|
||||
|
||||
it "respects assignment overrides" do
|
||||
@assignment.update_attribute :only_visible_to_overrides, true
|
||||
@a0 = @assignment
|
||||
graded_discussion_topic(context: @course)
|
||||
@topic.assignment.update_attribute :only_visible_to_overrides, true
|
||||
|
||||
get 'public_feed', params: {:feed_code => @enrollment.feed_code}, :format => 'atom'
|
||||
feed = Atom::Feed.load_feed(response.body) rescue nil
|
||||
expect(feed).not_to be_nil
|
||||
expect(feed.entries.map(&:id).join(" ")).not_to include @a0.asset_string
|
||||
expect(feed.entries.map(&:id).join(" ")).not_to include @topic.asset_string
|
||||
|
||||
assignment_override_model :assignment => @a0, :set => @enrollment.course_section
|
||||
assignment_override_model :assignment => @topic.assignment, :set => @enrollment.course_section
|
||||
|
||||
get 'public_feed', params: {:feed_code => @enrollment.feed_code}, :format => 'atom'
|
||||
feed = Atom::Feed.load_feed(response.body) rescue nil
|
||||
expect(feed).not_to be_nil
|
||||
expect(feed.entries.map(&:id).join(" ")).to include @a0.asset_string
|
||||
expect(feed.entries.map(&:id).join(" ")).to include @topic.asset_string
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST 'reset_content'" do
|
||||
|
|
|
@ -1620,6 +1620,26 @@ describe UsersController do
|
|||
feed = Atom::Feed.load_feed(response.body) rescue nil
|
||||
expect(feed.entries.size).to eq 0
|
||||
end
|
||||
|
||||
it "respects overrides" do
|
||||
@other_section = @course.course_sections.create! :name => 'other section'
|
||||
@as2 = assignment_model(:title => 'not for you', :course => @course, :only_visible_to_overrides => true)
|
||||
create_section_override_for_assignment(@as2, {course_section: @other_section})
|
||||
graded_discussion_topic(context: @course)
|
||||
create_section_override_for_assignment(@topic.assignment, {course_section: @other_section})
|
||||
@topic.assignment.update_attribute :only_visible_to_overrides, true
|
||||
|
||||
get 'public_feed', params: {:feed_code => @user.feed_code}, format: 'atom'
|
||||
feed = Atom::Feed.load_feed(response.body) rescue nil
|
||||
expect(feed.entries.map(&:id).join(" ")).not_to include @as2.asset_string
|
||||
expect(feed.entries.map(&:id).join(" ")).not_to include @topic.asset_string
|
||||
|
||||
@course.enroll_student(@student, section: @other_section, enrollment_state: 'active', allow_multiple_enrollments: true)
|
||||
get 'public_feed', params: {:feed_code => @user.feed_code}, format: 'atom'
|
||||
feed = Atom::Feed.load_feed(response.body) rescue nil
|
||||
expect(feed.entries.map(&:id).join(" ")).to include @as2.asset_string
|
||||
expect(feed.entries.map(&:id).join(" ")).to include @topic.asset_string
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'admin_merge'" do
|
||||
|
|
|
@ -91,4 +91,13 @@ module Factories
|
|||
opts[:group_category] = @group_category
|
||||
@group_topic = @context.discussion_topics.create!(valid_discussion_topic_attributes.merge(opts))
|
||||
end
|
||||
|
||||
def graded_discussion_topic(opts = {})
|
||||
@topic = discussion_topic_model(opts)
|
||||
@assignment = @topic.context.assignments.build(:submission_types => 'discussion_topic', :title => @topic.title)
|
||||
@assignment.infer_times
|
||||
@assignment.saved_by = :discussion_topic
|
||||
@topic.assignment = @assignment
|
||||
@topic.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,15 +21,6 @@ describe ContentMigration do
|
|||
context "course copy discussions" do
|
||||
include_examples "course copy"
|
||||
|
||||
def graded_discussion_topic
|
||||
@topic = @copy_from.discussion_topics.build(:title => "topic")
|
||||
@assignment = @copy_from.assignments.build(:submission_types => 'discussion_topic', :title => @topic.title)
|
||||
@assignment.infer_times
|
||||
@assignment.saved_by = :discussion_topic
|
||||
@topic.assignment = @assignment
|
||||
@topic.save
|
||||
end
|
||||
|
||||
it "should copy discussion topic attributes" do
|
||||
topic = @copy_from.discussion_topics.create!(:title => "topic", :message => "<p>bloop</p>",
|
||||
:pinned => true, :discussion_type => "threaded",
|
||||
|
@ -108,7 +99,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should copy a discussion topic when assignment is selected" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
|
||||
# Should not fail if the destination has a group
|
||||
@copy_to.groups.create!(:name => 'some random group of people')
|
||||
|
@ -225,7 +216,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not copy deleted assignment attached to topic" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
@assignment.workflow_state = 'deleted'
|
||||
@assignment.save!
|
||||
|
||||
|
@ -239,7 +230,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should copy the assignment group and grading standard in complete copy" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
gs = make_grading_standard(@copy_from, title: 'One')
|
||||
group = @copy_from.assignment_groups.create!(:name => "new group")
|
||||
@assignment.assignment_group = group
|
||||
|
@ -253,7 +244,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should copy the grading standard (but not assignment group) in selective copy" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
gs = make_grading_standard(@copy_from, title: 'One')
|
||||
group = @copy_from.assignment_groups.create!(:name => "new group")
|
||||
@assignment.assignment_group = group
|
||||
|
@ -268,7 +259,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not copy the assignment group and grading standard in selective export" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
gs = make_grading_standard(@copy_from, title: 'One')
|
||||
group = @copy_from.assignment_groups.create!(:name => "new group")
|
||||
@assignment.assignment_group = group
|
||||
|
@ -314,7 +305,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not copy lock_at directly when on assignment" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
@assignment.update_attribute(:lock_at, 3.days.from_now)
|
||||
|
||||
run_course_copy
|
||||
|
@ -325,7 +316,7 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not apply the late policy right away if shifting dates to the future" do
|
||||
graded_discussion_topic
|
||||
graded_discussion_topic(context: @copy_from)
|
||||
@assignment.update_attributes(:due_at => 3.days.ago, :points_possible => 4)
|
||||
|
||||
[@copy_from, @copy_to].each do |course|
|
||||
|
|
Loading…
Reference in New Issue