mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Don't allow editing of title and category of an archived topic
This commit is contained in:
parent
b7327942af
commit
7977deb3bf
2 changed files with 17 additions and 5 deletions
|
@ -259,7 +259,7 @@ class Guardian
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_edit_topic?(topic)
|
def can_edit_topic?(topic)
|
||||||
is_staff? || is_my_own?(topic)
|
!topic.archived && (is_staff? || is_my_own?(topic))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deleting Methods
|
# Deleting Methods
|
||||||
|
|
|
@ -456,12 +456,24 @@ describe Guardian do
|
||||||
Guardian.new(coding_horror).can_edit?(topic).should be_false
|
Guardian.new(coding_horror).can_edit?(topic).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true as a moderator' do
|
context 'not archived' do
|
||||||
Guardian.new(moderator).can_edit?(topic).should be_true
|
it 'returns true as a moderator' do
|
||||||
|
Guardian.new(moderator).can_edit?(topic).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true as an admin' do
|
||||||
|
Guardian.new(admin).can_edit?(topic).should be_true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true as an admin' do
|
context 'archived' do
|
||||||
Guardian.new(admin).can_edit?(topic).should be_true
|
it 'returns false as a moderator' do
|
||||||
|
Guardian.new(moderator).can_edit?(build(:topic, user: user, archived: true)).should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false as an admin' do
|
||||||
|
Guardian.new(admin).can_edit?(build(:topic, user: user, archived: true)).should be_false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue