From 9db861ec5bc416ff9fd5bea7165b429b4d1d15ed Mon Sep 17 00:00:00 2001 From: Splines Date: Fri, 23 Aug 2024 00:46:49 +0200 Subject: [PATCH] Remove unnecessary `with_teacher_by_id` trait --- spec/cypress/e2e/annotations_overview_spec.cy.js | 6 +++--- spec/cypress/e2e/lectures_spec.cy.js | 2 +- spec/factories/lectures.rb | 7 ------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/spec/cypress/e2e/annotations_overview_spec.cy.js b/spec/cypress/e2e/annotations_overview_spec.cy.js index f4c2f9561..2dea3b189 100644 --- a/spec/cypress/e2e/annotations_overview_spec.cy.js +++ b/spec/cypress/e2e/annotations_overview_spec.cy.js @@ -23,9 +23,9 @@ function createAnnotationScenario(context, userRole = "student") { cy.then(() => { // a user is considered a teacher only iff they have given any lecture const teacherUser = userRole === "teacher" ? context.user : context.teacherUser; - FactoryBot.create("lecture_with_sparse_toc", "with_title", "with_teacher_by_id", + FactoryBot.create("lecture_with_sparse_toc", "with_title", { title: LECTURE_TITLE_1, teacher_id: teacherUser.id }).as("lectureSage"); - FactoryBot.create("lecture_with_sparse_toc", "with_title", "with_teacher_by_id", + FactoryBot.create("lecture_with_sparse_toc", "with_title", { title: LECTURE_TITLE_2, teacher_id: teacherUser.id }).as("lectureLean"); }); @@ -80,7 +80,7 @@ describe("Annotation section", () => { cy.createUserAndLogin("teacher").as("teacher"); cy.then(() => { // a user is considered a teacher only iff they have given any lecture - FactoryBot.create("lecture", "with_teacher_by_id", { teacher_id: this.teacher.id }); + FactoryBot.create("lecture", { teacher_id: this.teacher.id }); }); cy.i18n("admin.annotation.your_annotations").as("yourAnnotations"); diff --git a/spec/cypress/e2e/lectures_spec.cy.js b/spec/cypress/e2e/lectures_spec.cy.js index 96d3994ee..59b59cbb2 100644 --- a/spec/cypress/e2e/lectures_spec.cy.js +++ b/spec/cypress/e2e/lectures_spec.cy.js @@ -3,7 +3,7 @@ import FactoryBot from "../support/factorybot"; describe("Lecture edit page", () => { it("shows content tab button", function () { cy.createUserAndLogin("teacher").then((teacher) => { - FactoryBot.create("lecture", "with_teacher_by_id", + FactoryBot.create("lecture", { teacher_id: teacher.id }).as("lecture"); }); diff --git a/spec/factories/lectures.rb b/spec/factories/lectures.rb index ae0274c8c..c47b26b49 100644 --- a/spec/factories/lectures.rb +++ b/spec/factories/lectures.rb @@ -62,13 +62,6 @@ course { association :course, title: title } end - trait :with_teacher_by_id do - transient do - teacher_id { nil } - end - teacher { User.find(teacher_id) } - end - # NOTE: that you can give the chapter_count here as parameter as well factory :lecture_with_toc, traits: [:with_toc]