From c30996129f31e9ac702c830bb9501d2f0ed25b5b Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Wed, 2 Jan 2019 16:57:05 +0100 Subject: [PATCH] FEATURE: Allow TL4 users to reset bump date --- .../discourse/widgets/topic-admin-menu.js.es6 | 16 +++++++--------- lib/guardian/topic_guardian.rb | 2 +- spec/requests/topics_controller_spec.rb | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 index b029650af9f..b73cdf52d3b 100644 --- a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 @@ -211,15 +211,13 @@ export default createWidget("topic-admin-menu", { }); } - if (this.currentUser.get("staff")) { - buttons.push({ - className: "topic-admin-reset-bump-date", - buttonClass: "btn-default", - action: "resetBumpDate", - icon: "anchor", - label: "actions.reset_bump_date" - }); - } + buttons.push({ + className: "topic-admin-reset-bump-date", + buttonClass: "btn-default", + action: "resetBumpDate", + icon: "anchor", + label: "actions.reset_bump_date" + }); if (!isPrivateMessage) { buttons.push({ diff --git a/lib/guardian/topic_guardian.rb b/lib/guardian/topic_guardian.rb index 8a7fd9d1172..d11c877ff59 100644 --- a/lib/guardian/topic_guardian.rb +++ b/lib/guardian/topic_guardian.rb @@ -148,6 +148,6 @@ module TopicGuardian end def can_update_bumped_at? - is_staff? + is_staff? || @user.has_trust_level?(TrustLevel[4]) end end diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb index f225b3c5ece..c7851de9003 100644 --- a/spec/requests/topics_controller_spec.rb +++ b/spec/requests/topics_controller_spec.rb @@ -2620,7 +2620,7 @@ RSpec.describe TopicsController do expect(response.status).to eq(403) end - [:user, :trust_level_4].each do |user| + [:user].each do |user| it "denies access for #{user}" do sign_in(Fabricate(user)) put "/t/#{topic.id}/reset-bump-date.json" @@ -2635,7 +2635,7 @@ RSpec.describe TopicsController do end end - [:admin, :moderator].each do |user| + [:admin, :moderator, :trust_level_4].each do |user| it "should reset bumped_at as #{user}" do sign_in(Fabricate(user)) topic = Fabricate(:topic, bumped_at: 1.hour.ago)