mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Don't swallow errors when failing to create message for post action.
This commit is contained in:
parent
b39d3a863d
commit
30ddc1f222
@ -255,7 +255,7 @@ SQL
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PostCreator.new(user, opts).create.try(:id)
|
PostCreator.new(user, opts).create!&.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.limit_action!(user, post, post_action_type_id)
|
def self.limit_action!(user, post, post_action_type_id)
|
||||||
|
@ -515,7 +515,7 @@ describe PostAction do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#create_message_for_post_action" do
|
describe ".create_message_for_post_action" do
|
||||||
it "does not create a message when there is no message" do
|
it "does not create a message when there is no message" do
|
||||||
message_id = PostAction.create_message_for_post_action(Discourse.system_user, post, PostActionType.types[:spam], {})
|
message_id = PostAction.create_message_for_post_action(Discourse.system_user, post, PostActionType.types[:spam], {})
|
||||||
expect(message_id).to be_nil
|
expect(message_id).to be_nil
|
||||||
@ -528,6 +528,25 @@ describe PostAction do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should raise the right errors when it fails to create a post" do
|
||||||
|
begin
|
||||||
|
group = Group[:moderators]
|
||||||
|
messageable_level = group.messageable_level
|
||||||
|
group.update!(messageable_level: Group::ALIAS_LEVELS[:nobody])
|
||||||
|
|
||||||
|
expect do
|
||||||
|
PostAction.create_message_for_post_action(
|
||||||
|
Fabricate(:user),
|
||||||
|
post,
|
||||||
|
PostActionType.types[:notify_moderators],
|
||||||
|
message: 'testing',
|
||||||
|
)
|
||||||
|
end.to raise_error(ActiveRecord::RecordNotSaved)
|
||||||
|
ensure
|
||||||
|
group.update!(messageable_level: messageable_level)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".lookup_for" do
|
describe ".lookup_for" do
|
||||||
|
Loading…
Reference in New Issue
Block a user