Fix conflictive debates with no votes
We originally added the `cached_votes_up > 0` in commit 4ce95e273
because back then `cached_votes_up` was used in the denominator. That's
no longer the case, and it doesn't make sense to mark a debate with 1
vote and 10 flags as conflictive but not doing it when the debate has no
votes and 1000 flags.
We're fixing the bug right now because we're about to change the
affected line in order to apply a new rubocop rule.
This commit is contained in:
@@ -2,7 +2,7 @@ module Conflictable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def conflictive?
|
||||
return false unless flags_count > 0 && cached_votes_up > 0
|
||||
return false unless flags_count > 0
|
||||
|
||||
cached_votes_up / flags_count.to_f < 5
|
||||
end
|
||||
|
||||
@@ -452,10 +452,15 @@ describe Debate do
|
||||
expect(debate).not_to be_conflictive
|
||||
end
|
||||
|
||||
it "returns false when it has not votes up" do
|
||||
debate.update!(cached_votes_up: 0)
|
||||
it "returns false when it has no flags and no votes up" do
|
||||
debate.update!(flags_count: 0, cached_votes_up: 0)
|
||||
expect(debate).not_to be_conflictive
|
||||
end
|
||||
|
||||
it "returns true when it has flags and no votes up" do
|
||||
debate.update!(cached_votes_up: 0, flags_count: 10)
|
||||
expect(debate).to be_conflictive
|
||||
end
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
|
||||
Reference in New Issue
Block a user