mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Ensure topic exists before making a banner. (#7781)
This commit is contained in:
parent
3fd7cf9038
commit
557805249d
@ -174,6 +174,6 @@ module TopicGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_banner_topic?(topic)
|
def can_banner_topic?(topic)
|
||||||
authenticated? && !topic.private_message? && is_staff?
|
topic && authenticated? && !topic.private_message? && is_staff?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -776,6 +776,13 @@ describe Guardian do
|
|||||||
PostActionCreator.create(user, first_post, :off_topic)
|
PostActionCreator.create(user, first_post, :off_topic)
|
||||||
expect(Guardian.new(moderator).can_see?(private_topic)).to be_truthy
|
expect(Guardian.new(moderator).can_see?(private_topic)).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows staff to set banner topics" do
|
||||||
|
topic = Fabricate(:topic)
|
||||||
|
|
||||||
|
expect(Guardian.new(admin).can_banner_topic?(nil)).to be_falsey
|
||||||
|
expect(Guardian.new(admin).can_banner_topic?(topic)).to be_truthy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'a Post' do
|
describe 'a Post' do
|
||||||
|
Loading…
Reference in New Issue
Block a user