mirror of
https://github.com/discourse/discourse.git
synced 2025-09-04 08:47:37 +08:00
FIX: Don't allow other flag actions after notify_moderator
has happened.
https://meta.discourse.org/t/receiving-sorry-an-error-has-occurred-during-flagging-step-of-discobot-tutorial/77233/5
This commit is contained in:
parent
e997cc7b77
commit
902c5d11cf
4 changed files with 43 additions and 16 deletions
|
@ -44,7 +44,7 @@ describe Guardian do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'post_can_act?' do
|
||||
describe '#post_can_act?' do
|
||||
let(:post) { build(:post) }
|
||||
let(:user) { build(:user) }
|
||||
|
||||
|
@ -100,9 +100,11 @@ describe Guardian do
|
|||
end
|
||||
|
||||
it "returns false when you already flagged a post" do
|
||||
expect(Guardian.new(user).post_can_act?(post, :off_topic, opts: {
|
||||
taken_actions: { PostActionType.types[:spam] => 1 }
|
||||
})).to be_falsey
|
||||
PostActionType.notify_flag_types.each do |type, _id|
|
||||
expect(Guardian.new(user).post_can_act?(post, :off_topic, opts: {
|
||||
taken_actions: { PostActionType.types[type] => 1 }
|
||||
})).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
it "returns false for notify_user if private messages are disabled" do
|
||||
|
|
|
@ -659,4 +659,30 @@ describe PostAction do
|
|||
|
||||
end
|
||||
|
||||
describe '#is_flag?' do
|
||||
describe 'when post action is a flag' do
|
||||
it 'should return true' do
|
||||
PostActionType.notify_flag_types.each do |_type, id|
|
||||
post_action = PostAction.new(
|
||||
user: codinghorror,
|
||||
post_action_type_id: id
|
||||
)
|
||||
|
||||
expect(post_action.is_flag?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when post action is not a flag' do
|
||||
it 'should return false' do
|
||||
post_action = PostAction.new(
|
||||
user: codinghorror,
|
||||
post_action_type_id: 99
|
||||
)
|
||||
|
||||
expect(post_action.is_flag?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue