From f426b25fe53b57483ebb522c779110491108ff52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 29 Sep 2019 16:07:18 +0200 Subject: [PATCH] Remove unneeded factories These factories were only used in one place and they even declared ID attributes. Using the comment factory with the `commentable` attribute does the same thing. --- spec/factories/legislations.rb | 23 ----------------------- spec/features/legislation/resume_spec.rb | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/spec/factories/legislations.rb b/spec/factories/legislations.rb index 0da50299a..bfb1e7948 100644 --- a/spec/factories/legislations.rb +++ b/spec/factories/legislations.rb @@ -184,29 +184,6 @@ LOREM_IPSUM author factory: :user end - factory :debate_comment, class: "Comment" do - commentable_id { "10" } - commentable_type { Legislation::Question } - body { "This is a comment" } - user_id { "1" } - cached_votes_down { "0" } - cached_votes_total { "0" } - cached_votes_up { "0" } - confidence_score { "0" } - end - - factory :text_comment, class: "Comment" do - commentable_id { "10" } - commentable_type { Legislation::Annotation } - body { "This is a comment" } - user_id { "1" } - cached_votes_down { "0" } - cached_votes_total { "0" } - cached_votes_up { "0" } - confidence_score { "0" } - ancestry { nil } - end - factory :legislation_people_proposal, class: "Legislation::PeopleProposal" do sequence(:title) { |n| "People and group #{n} for a legislation" } summary { "This law should be implemented by..." } diff --git a/spec/features/legislation/resume_spec.rb b/spec/features/legislation/resume_spec.rb index 643fe17c7..216e921e1 100644 --- a/spec/features/legislation/resume_spec.rb +++ b/spec/features/legislation/resume_spec.rb @@ -69,12 +69,13 @@ describe "Legislation" do before do user = create(:user, :level_two) @process = create(:legislation_process, end_date: Date.current - 1.day) + @debate = create(:legislation_question, process: @process, title: "Question 1") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 1") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 2") + create(:comment, user: user, commentable: @debate, body: "Answer 1") + create(:comment, user: user, commentable: @debate, body: "Answer 2") @debate = create(:legislation_question, process: @process, title: "Question 2") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 3") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 4") + create(:comment, user: user, commentable: @debate, body: "Answer 3") + create(:comment, user: user, commentable: @debate, body: "Answer 4") end scenario "show debates list" do @@ -187,10 +188,11 @@ describe "Legislation" do annotation2 = create(:legislation_annotation, draft_version: draft_version_2, ranges: [{ "start" => "/p[1]", "startOffset" => 12, "end" => "/p[1]", "endOffset" => 19 }]) - create(:text_comment, user: user, commentable_id: annotation0.id, body: "Comment 0") - create(:text_comment, user: user, commentable_id: annotation1.id, body: "Comment 1") - create(:text_comment, user: user, commentable_id: annotation2.id, body: "Comment 2") - create(:text_comment, user: user, commentable_id: annotation2.id, body: "Comment 3") + + create(:comment, user: user, commentable: annotation0, body: "Comment 0") + create(:comment, user: user, commentable: annotation1, body: "Comment 1") + create(:comment, user: user, commentable: annotation2, body: "Comment 2") + create(:comment, user: user, commentable: annotation2, body: "Comment 3") end scenario "debates empty" do @@ -233,8 +235,8 @@ describe "Legislation" do user = create(:user, :level_two) @process = create(:legislation_process, end_date: Date.current - 1.day) @debate = create(:legislation_question, process: @process, title: "Question 1") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 1") - create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 2") + create(:comment, user: user, commentable: @debate, body: "Answer 1") + create(:comment, user: user, commentable: @debate, body: "Answer 2") end it "download execl file test" do