diff --git a/app/models/post_action.rb b/app/models/post_action.rb index 24354ca34..a77805769 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -174,6 +174,8 @@ class PostAction < ActiveRecord::Base title = I18n.t("post_action_types.#{post_action_type}.email_title", title: post.topic.title) body = I18n.t("post_action_types.#{post_action_type}.email_body", message: opts[:message], link: "#{Discourse.base_url}#{post.url}") + title = title.truncate(255, separator: /\s/) + opts = { archetype: Archetype.private_message, title: title, diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb index f32b39198..c2277e5f0 100644 --- a/spec/models/post_action_spec.rb +++ b/spec/models/post_action_spec.rb @@ -17,6 +17,12 @@ describe PostAction do describe "messaging" do + it "doesn't generate title longer than 255 characters" do + topic = create_topic(title: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet rutrum neque. Pellentesque suscipit vehicula facilisis. Phasellus lacus sapien, aliquam nec convallis sit amet, vestibulum laoreet ante. Curabitur et pellentesque tortor. Donec non.") + post = create_post(topic: topic) + -> { PostAction.act(admin, post, PostActionType.types[:notify_user], message: "WAT") }.should_not raise_error + end + it "notify moderators integration test" do post = create_post mod = moderator