Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
lots of test fixing
  • Loading branch information
loiswells97 committed May 30, 2025
commit b90e5d22f0e91cf54b17bf34b79afe01df4f61e5
2 changes: 1 addition & 1 deletion app/controllers/api/lessons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_from_project
def update
# TODO: Consider removing user_id from the lesson_params for update so users can update other users' lessons without changing ownership
# OR consider dropping user_id on lessons and using teacher id/ids on the class instead
result = Lesson::Update.call(lesson: @lesson, lesson_params:)
result = Lesson::Update.call(lesson: @lesson, lesson_params: base_params)

if result.success?
@lesson_with_user = result[:lesson].with_user
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/lesson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sequence(:name) { |n| "Lesson #{n}" }
description { 'Description' }
visibility { 'teachers' }
project { create(:project, user_id:, name:, school: school || school_class&.school) }
project { create(:project, user_id:, name:, school_id: school_id || school&.id || school_class&.school&.id) }

trait :with_project_components do
transient do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/lesson/archiving_a_lesson_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
end

it "responds 403 Forbidden when the user is not the lesson's owner" do
lesson.update!(user_id: SecureRandom.uuid)
authenticated_in_hydra_as(teacher)

delete("/api/lessons/#{lesson.id}", headers:)
expect(response).to have_http_status(:forbidden)
Expand Down
5 changes: 2 additions & 3 deletions spec/features/lesson/updating_a_lesson_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
}
end
let!(:lesson) { create(:lesson, name: 'Test Lesson', user_id: owner.id) }
let(:teacher_lesson) { create(:lesson, name: 'Test Teacher Lesson', user_id: teacher.id) }
let(:teacher) { create(:teacher, school:) }
let(:school) { create(:verified_school) }
let(:owner) { create(:owner, school:, name: 'School Owner') }
Expand Down Expand Up @@ -51,9 +52,7 @@
end

it "responds 403 Forbidden when the user is not the lesson's owner" do
lesson.update!(user_id: SecureRandom.uuid)

put("/api/lessons/#{lesson.id}", headers:, params:)
put("/api/lessons/#{teacher_lesson.id}", headers:, params:)
expect(response).to have_http_status(:forbidden)
end

Expand Down