Skip to content

Commit e4b170a

Browse files
authored
Merge branch 'main' into update-scratch-controller-before-actions
2 parents cfe3aab + b0a6ce3 commit e4b170a

4 files changed

Lines changed: 41 additions & 16 deletions

File tree

Gemfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ GEM
118118
aws-eventstream (~> 1, >= 1.0.2)
119119
base64 (0.3.0)
120120
bigdecimal (4.1.2)
121-
bootsnap (1.24.5)
121+
bootsnap (1.24.6)
122122
msgpack (~> 1.2)
123123
builder (3.3.0)
124-
bullet (8.1.2)
124+
bullet (8.1.3)
125125
activesupport (>= 3.0.0)
126126
uniform_notifier (~> 1.11)
127127
byebug (13.0.0)
@@ -140,7 +140,7 @@ GEM
140140
choice (0.2.0)
141141
climate_control (1.2.0)
142142
coderay (1.1.3)
143-
concurrent-ruby (1.3.6)
143+
concurrent-ruby (1.3.7)
144144
connection_pool (3.0.2)
145145
countries (8.1.0)
146146
unaccent (~> 0.3)
@@ -177,11 +177,11 @@ GEM
177177
railties (>= 6.1.0)
178178
faker (3.8.0)
179179
i18n (>= 1.8.11, < 2)
180-
faraday (2.14.2)
180+
faraday (2.14.3)
181181
faraday-net_http (>= 2.0, < 3.5)
182182
json
183183
logger
184-
faraday-net_http (3.4.2)
184+
faraday-net_http (3.4.4)
185185
net-http (~> 0.5)
186186
ffi (1.17.4-aarch64-linux-gnu)
187187
ffi (1.17.4-arm64-darwin)
@@ -244,7 +244,7 @@ GEM
244244
actionview (>= 7.0.0)
245245
activesupport (>= 7.0.0)
246246
jmespath (1.6.2)
247-
json (2.19.8)
247+
json (2.19.9)
248248
jwt (2.10.3)
249249
base64
250250
kaminari (1.2.2)
@@ -278,7 +278,7 @@ GEM
278278
minitest (6.0.6)
279279
drb (~> 2.0)
280280
prism (~> 1.5)
281-
msgpack (1.8.1)
281+
msgpack (1.8.2)
282282
multi_xml (0.8.1)
283283
bigdecimal (>= 3.1, < 5)
284284
net-http (0.9.1)
@@ -293,11 +293,11 @@ GEM
293293
net-smtp (0.5.1)
294294
net-protocol
295295
nio4r (2.7.5)
296-
nokogiri (1.19.3-aarch64-linux-gnu)
296+
nokogiri (1.19.4-aarch64-linux-gnu)
297297
racc (~> 1.4)
298-
nokogiri (1.19.3-arm64-darwin)
298+
nokogiri (1.19.4-arm64-darwin)
299299
racc (~> 1.4)
300-
nokogiri (1.19.3-x86_64-linux-gnu)
300+
nokogiri (1.19.4-x86_64-linux-gnu)
301301
racc (~> 1.4)
302302
oauth2 (2.0.18)
303303
faraday (>= 0.17.3, < 4.0)
@@ -478,13 +478,13 @@ GEM
478478
lint_roller (~> 1.1)
479479
rubocop (>= 1.75.0, < 2.0)
480480
rubocop-ast (>= 1.47.1, < 2.0)
481-
rubocop-rails (2.35.3)
481+
rubocop-rails (2.35.4)
482482
activesupport (>= 4.2.0)
483483
lint_roller (~> 1.1)
484484
rack (>= 1.1)
485485
rubocop (>= 1.75.0, < 2.0)
486486
rubocop-ast (>= 1.44.0, < 2.0)
487-
rubocop-rspec (3.10.0)
487+
rubocop-rspec (3.10.2)
488488
lint_roller (~> 1.1)
489489
regexp_parser (>= 2.0)
490490
rubocop (~> 1.86, >= 1.86.2)

app/models/ability.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def define_school_student_abilities(user:, school:)
115115
can(%i[read], SchoolClass, school: { id: school.id }, students: { student_id: user.id })
116116
# Ensure no access to ClassMember resources, relationships otherwise allow access in some circumstances.
117117
can(%i[read], Lesson, school_id: school.id, visibility: 'students', school_class: { students: { student_id: user.id } })
118-
can(%i[read create update], Project, school_id: school.id, user_id: user.id, lesson_id: nil, remixed_from_id: visible_lesson_project_ids)
118+
can(%i[read create update show_context], Project, school_id: school.id, user_id: user.id, lesson_id: nil, remixed_from_id: visible_lesson_project_ids)
119119
can(%i[read show_context], Project, lesson: { school_id: school.id, visibility: 'students', school_class: { students: { student_id: user.id } } })
120120
can(%i[read set_read], Feedback, school_project: { project: { school_id: school.id, user_id: user.id, lesson_id: nil, remixed_from_id: visible_lesson_project_ids } })
121121
can(%i[show_finished set_finished show_status unsubmit submit], SchoolProject, project: { user_id: user.id, lesson_id: nil }, school_id: school.id)
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# frozen_string_literal: true
22

3+
source_lesson = @project.lesson || @project.parent&.lesson
4+
35
json.call(
46
@project,
57
:identifier,
68
:project_type,
7-
:school_id,
8-
:lesson_id
9+
:school_id
910
)
1011

11-
json.class_id(@project.lesson.school_class_id)
12+
json.lesson_id source_lesson&.id
13+
json.class_id source_lesson&.school_class_id

spec/requests/projects/show_context_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@
136136
end
137137
end
138138

139+
context 'when loading context of a remixed project that is visible to students' do
140+
let!(:student_remix) { create(:project, school:, user_id: student.id, remixed_from_id: project.id, locale: nil) }
141+
let(:expected_context_json) do
142+
{
143+
identifier: student_remix.identifier,
144+
project_type: project.project_type,
145+
school_id: school.id,
146+
lesson_id: lesson.id,
147+
class_id: school_class.id
148+
}.to_json
149+
end
150+
151+
it 'returns success response' do
152+
get("/api/projects/#{student_remix.identifier}/context", headers:)
153+
expect(response).to have_http_status(:ok)
154+
end
155+
156+
it 'returns the remix project context json' do
157+
get("/api/projects/#{student_remix.identifier}/context", headers:)
158+
expect(response.body).to eq(expected_context_json)
159+
end
160+
end
161+
139162
context 'when loading context of a lesson project that is not visible to students' do
140163
before do
141164
project.lesson.update(visibility: 'teachers')

0 commit comments

Comments
 (0)