Remove isolated data creation useless assignments

While there are other variables in these tests, they're not part of the
setup of the test, and so these ones can be removed while keeping the
code easy to read.
This commit is contained in:
Javi Martín
2019-09-23 19:12:04 +02:00
parent 7b0771106e
commit ee0031ccb3
3 changed files with 22 additions and 22 deletions

View File

@@ -260,10 +260,10 @@ describe "Consul Schema" do
describe "Comments" do describe "Comments" do
it "only returns comments from proposals, debates and polls" do it "only returns comments from proposals, debates and polls" do
proposal_comment = create(:comment, commentable: create(:proposal)) create(:comment, commentable: create(:proposal))
debate_comment = create(:comment, commentable: create(:debate)) create(:comment, commentable: create(:debate))
poll_comment = create(:comment, commentable: create(:poll)) create(:comment, commentable: create(:poll))
budget_investment_comment = build(:comment, commentable: create(:budget_investment)).save(skip_validation: true) build(:comment, commentable: create(:budget_investment)).save(skip_validation: true)
response = execute("{ comments { edges { node { commentable_type } } } }") response = execute("{ comments { edges { node { commentable_type } } } }")
received_commentables = extract_fields(response, "comments", "commentable_type") received_commentables = extract_fields(response, "comments", "commentable_type")
@@ -461,13 +461,13 @@ describe "Consul Schema" do
describe "Tags" do describe "Tags" do
it "only display tags with kind nil or category" do it "only display tags with kind nil or category" do
tag = create(:tag, name: "Parks") create(:tag, name: "Parks")
category_tag = create(:tag, :category, name: "Health") create(:tag, :category, name: "Health")
admin_tag = create(:tag, name: "Admin tag", kind: "admin") create(:tag, name: "Admin tag", kind: "admin")
proposal = create(:proposal, tag_list: "Parks") create(:proposal, tag_list: "Parks")
proposal = create(:proposal, tag_list: "Health") create(:proposal, tag_list: "Health")
proposal = create(:proposal, tag_list: "Admin tag") create(:proposal, tag_list: "Admin tag")
response = execute("{ tags { edges { node { name } } } }") response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name") received_tags = extract_fields(response, "tags", "name")
@@ -501,8 +501,8 @@ describe "Consul Schema" do
end end
it "does not display tags for hidden proposals" do it "does not display tags for hidden proposals" do
proposal = create(:proposal, tag_list: "Health") create(:proposal, tag_list: "Health")
hidden_proposal = create(:proposal, :hidden, tag_list: "SPAM") create(:proposal, :hidden, tag_list: "SPAM")
response = execute("{ tags { edges { node { name } } } }") response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name") received_tags = extract_fields(response, "tags", "name")
@@ -511,8 +511,8 @@ describe "Consul Schema" do
end end
it "does not display tags for hidden debates" do it "does not display tags for hidden debates" do
debate = create(:debate, tag_list: "Health, Transportation") create(:debate, tag_list: "Health, Transportation")
hidden_debate = create(:debate, :hidden, tag_list: "SPAM") create(:debate, :hidden, tag_list: "SPAM")
response = execute("{ tags { edges { node { name } } } }") response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name") received_tags = extract_fields(response, "tags", "name")
@@ -521,7 +521,7 @@ describe "Consul Schema" do
end end
it "does not display tags for taggings that are not public" do it "does not display tags for taggings that are not public" do
proposal = create(:proposal, tag_list: "Health") create(:proposal, tag_list: "Health")
allow(ActsAsTaggableOn::Tag).to receive(:public_for_api).and_return([]) allow(ActsAsTaggableOn::Tag).to receive(:public_for_api).and_return([])
response = execute("{ tags { edges { node { name } } } }") response = execute("{ tags { edges { node { name } } } }")

View File

@@ -51,7 +51,7 @@ describe UserSegments do
describe "#proposal_authors" do describe "#proposal_authors" do
it "returns users that have created a proposal" do it "returns users that have created a proposal" do
proposal = create(:proposal, author: user1) create(:proposal, author: user1)
proposal_authors = UserSegments.proposal_authors proposal_authors = UserSegments.proposal_authors
expect(proposal_authors).to include user1 expect(proposal_authors).to include user1
@@ -59,8 +59,8 @@ describe UserSegments do
end end
it "does not return duplicated users" do it "does not return duplicated users" do
proposal1 = create(:proposal, author: user1) create(:proposal, author: user1)
proposal2 = create(:proposal, author: user1) create(:proposal, author: user1)
proposal_authors = UserSegments.proposal_authors proposal_authors = UserSegments.proposal_authors
expect(proposal_authors).to contain_exactly(user1) expect(proposal_authors).to contain_exactly(user1)

View File

@@ -695,28 +695,28 @@ describe Debate do
context "no results" do context "no results" do
it "no words match" do it "no words match" do
debate = create(:debate, title: "save world") create(:debate, title: "save world")
results = Debate.search("destroy planet") results = Debate.search("destroy planet")
expect(results).to eq([]) expect(results).to eq([])
end end
it "too many typos" do it "too many typos" do
debate = create(:debate, title: "fantastic") create(:debate, title: "fantastic")
results = Debate.search("frantac") results = Debate.search("frantac")
expect(results).to eq([]) expect(results).to eq([])
end end
it "too much stemming" do it "too much stemming" do
debate = create(:debate, title: "reloj") create(:debate, title: "reloj")
results = Debate.search("superrelojimetro") results = Debate.search("superrelojimetro")
expect(results).to eq([]) expect(results).to eq([])
end end
it "empty" do it "empty" do
debate = create(:debate, title: "great") create(:debate, title: "great")
results = Debate.search("") results = Debate.search("")
expect(results).to eq([]) expect(results).to eq([])