Skip to content

Commit b90e5d2

Browse files
committed
lots of test fixing
1 parent b118883 commit b90e5d2

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

app/controllers/api/lessons_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def create_from_project
6161
def update
6262
# TODO: Consider removing user_id from the lesson_params for update so users can update other users' lessons without changing ownership
6363
# OR consider dropping user_id on lessons and using teacher id/ids on the class instead
64-
result = Lesson::Update.call(lesson: @lesson, lesson_params:)
64+
result = Lesson::Update.call(lesson: @lesson, lesson_params: base_params)
6565

6666
if result.success?
6767
@lesson_with_user = result[:lesson].with_user

spec/factories/lesson.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
sequence(:name) { |n| "Lesson #{n}" }
77
description { 'Description' }
88
visibility { 'teachers' }
9-
project { create(:project, user_id:, name:, school: school || school_class&.school) }
9+
project { create(:project, user_id:, name:, school_id: school_id || school&.id || school_class&.school&.id) }
1010

1111
trait :with_project_components do
1212
transient do

spec/features/lesson/archiving_a_lesson_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
end
4545

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

4949
delete("/api/lessons/#{lesson.id}", headers:)
5050
expect(response).to have_http_status(:forbidden)

spec/features/lesson/updating_a_lesson_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
end
1414
let!(:lesson) { create(:lesson, name: 'Test Lesson', user_id: owner.id) }
15+
let(:teacher_lesson) { create(:lesson, name: 'Test Teacher Lesson', user_id: teacher.id) }
1516
let(:teacher) { create(:teacher, school:) }
1617
let(:school) { create(:verified_school) }
1718
let(:owner) { create(:owner, school:, name: 'School Owner') }
@@ -51,9 +52,7 @@
5152
end
5253

5354
it "responds 403 Forbidden when the user is not the lesson's owner" do
54-
lesson.update!(user_id: SecureRandom.uuid)
55-
56-
put("/api/lessons/#{lesson.id}", headers:, params:)
55+
put("/api/lessons/#{teacher_lesson.id}", headers:, params:)
5756
expect(response).to have_http_status(:forbidden)
5857
end
5958

0 commit comments

Comments
 (0)