Skip to content

A platform for community discussion. Free, open, simple.

FIX: Don't hide/close topics if they don't meet minimum visibility

Robin Wardf1b3e725818b
diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index 7558dec431c..af23f150e25 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -188,7 +188,7 @@ class Reviewable < ActiveRecord::Base
end
end
- def self.sensitivity_score(sensitivity, scale: 1.0)
+ def self.sensitivity_score_value(sensitivity, scale)
return Float::MAX if sensitivity == 0
ratio = sensitivity / Reviewable.sensitivity[:low].to_f
@@ -199,6 +199,13 @@ class Reviewable < ActiveRecord::Base
(high.to_f * ratio) * scale
end
+ def self.sensitivity_score(sensitivity, scale: 1.0)
+ # If the score is less than the default visibility, bring it up to that level.
+ # Otherwise we have the confusing situation where a post might be hidden and
+ # moderators would never see it!
+ [sensitivity_score_value(sensitivity, scale), min_score_for_priority].max
+ end
+
def self.score_to_auto_close_topic
sensitivity_score(SiteSetting.auto_close_topic_sensitivity, scale: 2.5)
end
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index 3cc85cf55a8..0de5a61d7bf 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -302,6 +302,13 @@ RSpec.describe Reviewable, type: :model do
end
context ".score_required_to_hide_post" do
+
+ it "will return the default visibility if it's higher" do
+ Reviewable.set_priorities(low: 40.0, high: 100.0)
+ SiteSetting.hide_post_sensitivity = Reviewable.sensitivity[:high]
+ expect(Reviewable.score_required_to_hide_post).to eq(40.0)
+ end
+
it "returns 10 if we can't calculated any percentiles" do
SiteSetting.hide_post_sensitivity = Reviewable.sensitivity[:low]
expect(Reviewable.score_required_to_hide_post).to eq(10.0)
@@ -346,6 +353,7 @@ RSpec.describe Reviewable, type: :model do
end
context ".score_to_auto_close_topic" do
+
it "returns 25 if we can't calculated any percentiles" do
SiteSetting.auto_close_topic_sensitivity = Reviewable.sensitivity[:low]
expect(Reviewable.score_to_auto_close_topic).to eq(25.0)