FIX: staff should be able to edit topics that have been archived
This commit is contained in:
parent
f7b0c31418
commit
2f32af3941
|
@ -27,10 +27,10 @@ module TopicGuardian
|
|||
|
||||
# Editing Method
|
||||
def can_edit_topic?(topic)
|
||||
return false if topic.archived
|
||||
return true if is_my_own?(topic)
|
||||
return false if Discourse.static_doc_topic_ids.include?(topic.id) && !is_admin?
|
||||
is_staff? || user.has_trust_level?(:leader)
|
||||
return true if is_staff? || user.has_trust_level?(:leader)
|
||||
return false if topic.archived
|
||||
is_my_own?(topic)
|
||||
end
|
||||
|
||||
# Recovery Method
|
||||
|
|
|
@ -550,7 +550,7 @@ describe Guardian do
|
|||
Guardian.new(coding_horror).can_create?(Post, topic).should be_false
|
||||
end
|
||||
|
||||
it 'allows editing of posts' do
|
||||
it 'does not allow editing of posts' do
|
||||
Guardian.new(coding_horror).can_edit?(post).should be_false
|
||||
end
|
||||
end
|
||||
|
@ -854,16 +854,20 @@ describe Guardian do
|
|||
end
|
||||
|
||||
context 'archived' do
|
||||
it 'returns false as a moderator' do
|
||||
Guardian.new(moderator).can_edit?(build(:topic, user: user, archived: true)).should == false
|
||||
it 'returns true as a moderator' do
|
||||
Guardian.new(moderator).can_edit?(build(:topic, user: user, archived: true)).should == true
|
||||
end
|
||||
|
||||
it 'returns false as an admin' do
|
||||
Guardian.new(admin).can_edit?(build(:topic, user: user, archived: true)).should == false
|
||||
it 'returns true as an admin' do
|
||||
Guardian.new(admin).can_edit?(build(:topic, user: user, archived: true)).should == true
|
||||
end
|
||||
|
||||
it 'returns false at trust level 3' do
|
||||
Guardian.new(leader).can_edit?(build(:topic, user: user, archived: true)).should == false
|
||||
it 'returns true at trust level 3' do
|
||||
Guardian.new(leader).can_edit?(build(:topic, user: user, archived: true)).should == true
|
||||
end
|
||||
|
||||
it 'returns false as a topic creator' do
|
||||
Guardian.new(user).can_edit?(build(:topic, user: user, archived: true)).should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue