Use hidden trait in specs
We were using it in most places, but there were a few where we still used `hidden_at: Time.current`.
This commit is contained in:
@@ -30,6 +30,10 @@ FactoryBot.define do
|
|||||||
trait :published do
|
trait :published do
|
||||||
published { true }
|
published { true }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :hidden do
|
||||||
|
hidden_at { Time.current }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :poll_question, class: "Poll::Question" do
|
factory :poll_question, class: "Poll::Question" do
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ describe "Stats" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Do not count hidden users" do
|
scenario "Do not count hidden users" do
|
||||||
1.times { create(:user, :level_three, hidden_at: Time.current) }
|
1.times { create(:user, :hidden, :level_three) }
|
||||||
2.times { create(:user, :level_two, hidden_at: Time.current) }
|
2.times { create(:user, :hidden, :level_two) }
|
||||||
3.times { create(:user, hidden_at: Time.current) }
|
3.times { create(:user, :hidden) }
|
||||||
|
|
||||||
visit admin_stats_path
|
visit admin_stats_path
|
||||||
|
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include hidden comments" do
|
it "does not include hidden comments" do
|
||||||
visible_comment = create(:comment)
|
visible_comment = create(:comment)
|
||||||
hidden_comment = create(:comment, hidden_at: Time.current)
|
hidden_comment = create(:comment, :hidden)
|
||||||
|
|
||||||
response = execute("{ comments { edges { node { body } } } }")
|
response = execute("{ comments { edges { node { body } } } }")
|
||||||
received_comments = extract_fields(response, "comments", "body")
|
received_comments = extract_fields(response, "comments", "body")
|
||||||
@@ -315,7 +315,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include comments from hidden proposals" do
|
it "does not include comments from hidden proposals" do
|
||||||
visible_proposal = create(:proposal)
|
visible_proposal = create(:proposal)
|
||||||
hidden_proposal = create(:proposal, hidden_at: Time.current)
|
hidden_proposal = create(:proposal, :hidden)
|
||||||
|
|
||||||
visible_proposal_comment = create(:comment, commentable: visible_proposal)
|
visible_proposal_comment = create(:comment, commentable: visible_proposal)
|
||||||
hidden_proposal_comment = create(:comment, commentable: hidden_proposal)
|
hidden_proposal_comment = create(:comment, commentable: hidden_proposal)
|
||||||
@@ -328,7 +328,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include comments from hidden debates" do
|
it "does not include comments from hidden debates" do
|
||||||
visible_debate = create(:debate)
|
visible_debate = create(:debate)
|
||||||
hidden_debate = create(:debate, hidden_at: Time.current)
|
hidden_debate = create(:debate, :hidden)
|
||||||
|
|
||||||
visible_debate_comment = create(:comment, commentable: visible_debate)
|
visible_debate_comment = create(:comment, commentable: visible_debate)
|
||||||
hidden_debate_comment = create(:comment, commentable: hidden_debate)
|
hidden_debate_comment = create(:comment, commentable: hidden_debate)
|
||||||
@@ -341,7 +341,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include comments from hidden polls" do
|
it "does not include comments from hidden polls" do
|
||||||
visible_poll = create(:poll)
|
visible_poll = create(:poll)
|
||||||
hidden_poll = create(:poll, hidden_at: Time.current)
|
hidden_poll = create(:poll, :hidden)
|
||||||
|
|
||||||
visible_poll_comment = create(:comment, commentable: visible_poll)
|
visible_poll_comment = create(:comment, commentable: visible_poll)
|
||||||
hidden_poll_comment = create(:comment, commentable: hidden_poll)
|
hidden_poll_comment = create(:comment, commentable: hidden_poll)
|
||||||
@@ -575,7 +575,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include votes of hidden proposals" do
|
it "does not include votes of hidden proposals" do
|
||||||
visible_proposal = create(:proposal)
|
visible_proposal = create(:proposal)
|
||||||
hidden_proposal = create(:proposal, hidden_at: Time.current)
|
hidden_proposal = create(:proposal, :hidden)
|
||||||
|
|
||||||
visible_proposal_vote = create(:vote, votable: visible_proposal)
|
visible_proposal_vote = create(:vote, votable: visible_proposal)
|
||||||
hidden_proposal_vote = create(:vote, votable: hidden_proposal)
|
hidden_proposal_vote = create(:vote, votable: hidden_proposal)
|
||||||
@@ -588,7 +588,7 @@ describe "Consul Schema" do
|
|||||||
|
|
||||||
it "does not include votes of hidden comments" do
|
it "does not include votes of hidden comments" do
|
||||||
visible_comment = create(:comment)
|
visible_comment = create(:comment)
|
||||||
hidden_comment = create(:comment, hidden_at: Time.current)
|
hidden_comment = create(:comment, :hidden)
|
||||||
|
|
||||||
visible_comment_vote = create(:vote, votable: visible_comment)
|
visible_comment_vote = create(:vote, votable: visible_comment)
|
||||||
hidden_comment_vote = create(:vote, votable: hidden_comment)
|
hidden_comment_vote = create(:vote, votable: hidden_comment)
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ describe Budget::Stats do
|
|||||||
|
|
||||||
describe "#participants" do
|
describe "#participants" do
|
||||||
let(:author) { investment.author }
|
let(:author) { investment.author }
|
||||||
let(:author_and_voter) { create(:user, hidden_at: Time.current) }
|
let(:author_and_voter) { create(:user, :hidden) }
|
||||||
let(:voter) { create(:user) }
|
let(:voter) { create(:user) }
|
||||||
let(:voter_and_balloter) { create(:user) }
|
let(:voter_and_balloter) { create(:user) }
|
||||||
let(:balloter) { create(:user, hidden_at: Time.current) }
|
let(:balloter) { create(:user, :hidden) }
|
||||||
let(:poll_balloter) { create(:user, :level_two) }
|
let(:poll_balloter) { create(:user, :level_two) }
|
||||||
let(:non_participant) { create(:user, :level_two) }
|
let(:non_participant) { create(:user, :level_two) }
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe Poll::Stats do
|
|||||||
describe "#participants" do
|
describe "#participants" do
|
||||||
it "includes hidden users" do
|
it "includes hidden users" do
|
||||||
create(:poll_voter, poll: poll)
|
create(:poll_voter, poll: poll)
|
||||||
create(:poll_voter, poll: poll, user: create(:user, :level_two, hidden_at: Time.current))
|
create(:poll_voter, poll: poll, user: create(:user, :level_two, :hidden))
|
||||||
|
|
||||||
expect(stats.participants.count).to eq(2)
|
expect(stats.participants.count).to eq(2)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user