Skip to content

Commit 61f4a55

Browse files
committed
fixing test and adding another
1 parent e27e0c7 commit 61f4a55

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

app/controllers/api/lessons_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def index
1414
remixes = ordered_scope.map do |lesson|
1515
next nil unless lesson&.project&.remixes.any?
1616
lesson.project&.remixes
17-
.where(user_id: current_user?.id)
17+
.where(user_id: current_user.id)
1818
.accessible_by(current_ability)
1919
.order(created_at: :asc)
2020
.first

spec/features/lesson/listing_lessons_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@
210210
expect(data.size).to eq(1)
211211
end
212212

213+
it "includes the remix identifier when the user has remixed the lesson's project" do
214+
student = create(:student, school:)
215+
authenticated_in_hydra_as(student)
216+
create(:class_student, school_class:, student_id: student.id)
217+
student_project = create(:project, school:, lesson:, parent: lesson.project, user_id: student.id)
218+
219+
get('/api/lessons', headers:)
220+
data = JSON.parse(response.body, symbolize_names: true)
221+
expect(data.first[:remix_identifier]).to eq(student_project.identifier)
222+
end
223+
213224
it "does not include the lesson when the user is not a school-student within the lesson's class" do
214225
student = create(:student, school:)
215226
authenticated_in_hydra_as(student)

0 commit comments

Comments
 (0)