Don't allow editing of title and category of an archived topic

This commit is contained in:
Neil Lalonde 2013-07-09 16:48:26 -04:00
parent b7327942af
commit 7977deb3bf
2 changed files with 17 additions and 5 deletions

View file

@ -259,7 +259,7 @@ class Guardian
end
def can_edit_topic?(topic)
is_staff? || is_my_own?(topic)
!topic.archived && (is_staff? || is_my_own?(topic))
end
# Deleting Methods

View file

@ -456,6 +456,7 @@ describe Guardian do
Guardian.new(coding_horror).can_edit?(topic).should be_false
end
context 'not archived' do
it 'returns true as a moderator' do
Guardian.new(moderator).can_edit?(topic).should be_true
end
@ -465,6 +466,17 @@ describe Guardian do
end
end
context 'archived' do
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
describe 'a Category' do
let(:category) { Fabricate(:category) }