Use factory bot blocks to create complex data
Having two questions, each of them with two comments, made the code hard to follow. Grouping the comments inside the block creating the questions makes it easier to know which comment belongs to which question, even if the code is still not 100% readable. We also remove instance variables, which by the way used the same variable name for two different things.
This commit is contained in:
@@ -64,12 +64,16 @@ describe "Legislation" do
|
||||
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@debate = create(:legislation_question, process: process, title: "Question 1")
|
||||
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(:comment, user: user, commentable: @debate, body: "Answer 3")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 4")
|
||||
|
||||
create(:legislation_question, process: process, title: "Question 1") do |question|
|
||||
create(:comment, user: user, commentable: question, body: "Answer 1")
|
||||
create(:comment, user: user, commentable: question, body: "Answer 2")
|
||||
end
|
||||
|
||||
create(:legislation_question, process: process, title: "Question 2") do |question|
|
||||
create(:comment, user: user, commentable: question, body: "Answer 3")
|
||||
create(:comment, user: user, commentable: question, body: "Answer 4")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "show debates list" do
|
||||
|
||||
Reference in New Issue
Block a user