Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix observer enrollment impacting section privileges of teacher #2246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ def update_from(other, skip_broadcasts = false)
self.root_account_id = other.root_account_id
self.sis_batch_id = other.sis_batch_id unless sis_batch_id.nil?
self.skip_touch_user = other.skip_touch_user
self.limit_privileges_to_course_section = other.limit_privileges_to_course_section
if skip_broadcasts
save_without_broadcasting!
else
Expand Down
11 changes: 11 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,17 @@ def make_date_completed
expect(@course.course_section_visibility(limited_teacher)).to eq [@section2.id]
end

it "correctly limits visibilities for a limited teacher observing a student in different section" do
limited_teacher = user_with_pseudonym(name: "Limited Teacher")
@course.enroll_teacher(limited_teacher,
limit_privileges_to_course_section: true,
section: @section2)
student = user_with_pseudonym
@course.enroll_student(student, enrollment_state: "active", section: @section1, limit_privileges_to_course_section: true)
add_linked_observer(student, limited_teacher)
expect(@course.course_section_visibility(limited_teacher)).to eq [@section1.id, @section2.id]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test fails and returns :all before change

end

it "unlimited teachers can see everything" do
unlimited_teacher = User.create(name: "Unlimited Teacher")
@course.enroll_teacher(unlimited_teacher, section: @section2)
Expand Down