Skip to content

Commit f277e95

Browse files
committed
Remove unneeded creates
1 parent 05bbeff commit f277e95

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

spec/features/lesson/listing_lessons_spec.rb

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
let!(:lesson) { create(:lesson, school_class:, name: 'Test Lesson', visibility: 'students', user_id: teacher.id) }
200200
let(:teacher) { create(:teacher, school:) }
201201

202-
let(:class_student) do
202+
let!(:class_student) do
203203
create(:class_student, school_class:, student_id: student.id)
204204
end
205205

@@ -229,8 +229,6 @@
229229

230230
it "includes the lesson when the user is a school-student within the lesson's class" do
231231
authenticated_in_hydra_as(student)
232-
create(:class_student, school_class:, student_id: student.id)
233-
234232
get('/api/lessons', headers:)
235233
data = JSON.parse(response.body, symbolize_names: true)
236234

@@ -239,17 +237,13 @@
239237

240238
it 'does not include the submitted_count when the user is a school-student within the lesson\'s class' do
241239
authenticated_in_hydra_as(student)
242-
create(:class_student, school_class:, student_id: student.id)
243-
244240
get('/api/lessons', headers:)
245241
data = JSON.parse(response.body, symbolize_names: true)
246242
expect(data.first).not_to have_key(:submitted_count)
247243
end
248244

249245
it "includes the remix identifier when the user has remixed the lesson's project" do
250-
student = create(:student, school:)
251246
authenticated_in_hydra_as(student)
252-
create(:class_student, school_class:, student_id: student.id)
253247
student_project = create(:project, school:, lesson:, parent: lesson.project, remixed_from_id: lesson.project.id, user_id: student.id)
254248

255249
get('/api/lessons', headers:)
@@ -258,7 +252,8 @@
258252
end
259253

260254
it "does not include the lesson when the user is not a school-student within the lesson's class" do
261-
authenticated_in_hydra_as(student)
255+
another_student = create(:student, school:)
256+
authenticated_in_hydra_as(another_student)
262257

263258
get('/api/lessons', headers:)
264259
data = JSON.parse(response.body, symbolize_names: true)
@@ -278,8 +273,6 @@
278273

279274
it 'includes has_unread_feedback as true when there is unread feedback' do
280275
authenticated_in_hydra_as(student)
281-
create(:class_student, school_class:, student_id: student.id)
282-
283276
create(
284277
:feedback,
285278
school_project: school_project,
@@ -304,8 +297,6 @@
304297

305298
it 'includes has_unread_feedback as false when there is no unread feedback' do
306299
authenticated_in_hydra_as(student)
307-
create(:class_student, school_class:, student_id: student.id)
308-
309300
create(
310301
:feedback,
311302
school_project: school_project,
@@ -322,8 +313,6 @@
322313

323314
it 'includes status when the user is a student' do
324315
authenticated_in_hydra_as(student)
325-
create(:class_student, school_class:, student_id: student.id)
326-
327316
school_project.transition_status_to!(:submitted, teacher.id)
328317

329318
get('/api/lessons', headers:)
@@ -335,8 +324,6 @@
335324

336325
it 'includes the default status when no transitions have happened' do
337326
authenticated_in_hydra_as(student)
338-
create(:class_student, school_class:, student_id: student.id)
339-
340327
create(
341328
:project,
342329
school:,

0 commit comments

Comments
 (0)