Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: TL3 can convert their post to a wiki #25023

Merged
merged 1 commit into from Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/guardian/post_guardian.rb
Expand Up @@ -330,7 +330,7 @@ def can_change_post_timestamps?

def can_wiki?(post)
return false unless authenticated?
return true if is_staff? || @user.in_any_groups?(SiteSetting.edit_wiki_post_allowed_groups_map)
return true if is_staff? || @user.has_trust_level?(TrustLevel[4])

if @user.has_trust_level?(SiteSetting.min_trust_to_allow_self_wiki) && is_my_own?(post)
return false if post.hidden?
Expand Down
2 changes: 0 additions & 2 deletions spec/lib/guardian_spec.rb
Expand Up @@ -3639,8 +3639,6 @@
describe "can_wiki?" do
let(:post) { Fabricate(:post, created_at: 1.minute.ago) }

before { SiteSetting.edit_wiki_post_allowed_groups = "14" }

it "returns false for regular user" do
expect(Guardian.new(coding_horror).can_wiki?(post)).to be_falsey
end
Expand Down
1 change: 0 additions & 1 deletion spec/requests/posts_controller_spec.rb
Expand Up @@ -709,7 +709,6 @@
end

it "raises an error if the user doesn't have permission to wiki the post" do
SiteSetting.edit_wiki_post_allowed_groups = "14"
put "/posts/#{post.id}/wiki.json", params: { wiki: "true" }
expect(response).to be_forbidden
end
Expand Down