|
191 | 191 | context "differentiated assignements" do |
192 | 192 | before do |
193 | 193 | @course = course(:active_course => true) |
194 | | - discussion_topic_model(:user => @teacher) |
| 194 | + discussion_topic_model(:user => @teacher, :context => @course) |
| 195 | + @course.enroll_teacher(@teacher).accept! |
195 | 196 | @course_section = @course.course_sections.create |
196 | 197 | @student1, @student2, @student3 = create_users(3, return_type: :record) |
197 | 198 |
|
|
223 | 224 | it "should be visible to a teacher" do |
224 | 225 | @topic.visible_for?(@teacher).should be_true |
225 | 226 | end |
| 227 | + context "active_participants_with_visibility" do |
| 228 | + it "should filter participants by visibility" do |
| 229 | + [@student1, @teacher].each do |user| |
| 230 | + @topic.active_participants_with_visibility.include?(user).should be_true |
| 231 | + end |
| 232 | + @topic.active_participants_with_visibility.include?(@student2).should be_false |
| 233 | + end |
| 234 | + end |
226 | 235 | end |
227 | 236 |
|
228 | 237 | context "feature flag off" do |
|
232 | 241 | @topic.visible_for?(user).should be_true |
233 | 242 | end |
234 | 243 | end |
| 244 | + context "active_participants_with_visibility" do |
| 245 | + it "should not filter any participants" do |
| 246 | + [@student1,@student2].each do |user| |
| 247 | + @topic.active_participants_with_visibility.include?(user).should be_true |
| 248 | + end |
| 249 | + end |
| 250 | + end |
235 | 251 | end |
236 | 252 | end |
237 | 253 | end |
@@ -738,6 +754,52 @@ def delayed_discussion_topic(opts = {}) |
738 | 754 | @topic.subscribers.should_not include(@student) |
739 | 755 | @topic2.subscribers.should_not include(@student) |
740 | 756 | end |
| 757 | + |
| 758 | + context "differentiated_assignments" do |
| 759 | + before do |
| 760 | + @assignment = @course.assignments.create!(:title => "some discussion assignment",only_visible_to_overrides: true) |
| 761 | + @assignment.submission_types = 'discussion_topic' |
| 762 | + @assignment.save! |
| 763 | + @topic.assignment_id = @assignment.id |
| 764 | + @topic.save! |
| 765 | + @section = @course.course_sections.create!(name: "test section") |
| 766 | + create_section_override_for_assignment(@topic.assignment, {course_section: @section}) |
| 767 | + end |
| 768 | + context "enabled" do |
| 769 | + before{@course.enable_feature!(:differentiated_assignments)} |
| 770 | + it "should filter subscribers based on visibility" do |
| 771 | + @topic.subscribe(@student) |
| 772 | + @topic.subscribers.should_not include(@student) |
| 773 | + student_in_section(@section, user: @student) |
| 774 | + @topic.subscribers.should include(@student) |
| 775 | + end |
| 776 | + |
| 777 | + it "filters observers if their student cant see" do |
| 778 | + @observer = user(:active_all => true, :name => "Observer") |
| 779 | + observer_enrollment = @course.enroll_user(@observer, 'ObserverEnrollment', :section => @section, :enrollment_state => 'active') |
| 780 | + observer_enrollment.update_attribute(:associated_user_id, @student.id) |
| 781 | + @topic.subscribe(@observer) |
| 782 | + @topic.subscribers.include?(@observer).should be_false |
| 783 | + student_in_section(@section, user: @student) |
| 784 | + @topic.subscribers.include?(@observer).should be_true |
| 785 | + end |
| 786 | + |
| 787 | + it "doesnt filter for observers with no student" do |
| 788 | + @observer = user(:active_all => true) |
| 789 | + observer_enrollment = @course.enroll_user(@observer, 'ObserverEnrollment', :section => @section, :enrollment_state => 'active') |
| 790 | + @topic.subscribe(@observer) |
| 791 | + @topic.subscribers.should include(@observer) |
| 792 | + end |
| 793 | + |
| 794 | + end |
| 795 | + context "disabled" do |
| 796 | + before{@course.disable_feature!(:differentiated_assignments)} |
| 797 | + it "should not filter subscribers based on visibility" do |
| 798 | + @topic.subscribe(@student) |
| 799 | + @topic.subscribers.should include(@student) |
| 800 | + end |
| 801 | + end |
| 802 | + end |
741 | 803 | end |
742 | 804 |
|
743 | 805 | context "posters" do |
|
0 commit comments