Skip to content

Commit f32d72b

Browse files
committed
chore: add school id post review
1 parent e9afed4 commit f32d72b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

app/models/ability.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def define_school_teacher_abilities(user:, school:)
9898
school_class_id: ClassTeacher.where(teacher_id: user.id).select(:school_class_id)
9999
)
100100
).pluck(:id)
101-
can(%i[read show_context], Project, remixed_from_id: teacher_project_ids)
102-
can(%i[show_status unsubmit return complete], SchoolProject, project: { remixed_from_id: teacher_project_ids })
103-
can(%i[read create destroy], Feedback, school_project: { project: { remixed_from_id: teacher_project_ids } })
101+
can(%i[read show_context], Project, school_id: school.id, remixed_from_id: teacher_project_ids)
102+
can(%i[show_status unsubmit return complete], SchoolProject, project: { school_id: school.id, remixed_from_id: teacher_project_ids })
103+
can(%i[read create destroy], Feedback, school_project: { project: { school_id: school.id, remixed_from_id: teacher_project_ids } })
104104
can(%i[exchange_code], :google_auth)
105105
end
106106

spec/models/ability_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,19 @@
372372
it { is_expected.to be_able_to(:complete, remixed_project.school_project) }
373373
end
374374

375+
context 'when remix school_id does not match the parent lesson project school' do
376+
let(:other_school) { create(:school) }
377+
let(:other_student) { create(:student, school: other_school) }
378+
let!(:cross_school_remix) do
379+
create(:project, school: other_school, user_id: other_student.id, remixed_from_id: original_project.id)
380+
end
381+
let(:user) { teacher }
382+
383+
it { is_expected.not_to be_able_to(:read, cross_school_remix) }
384+
it { is_expected.not_to be_able_to(:show_context, cross_school_remix) }
385+
it { is_expected.not_to be_able_to(:return, cross_school_remix.school_project) }
386+
end
387+
375388
context 'when user is another teacher of the class' do
376389
let(:user) { another_teacher }
377390

0 commit comments

Comments
 (0)