FIX: custom flags not possible on very long topic titles

This commit is contained in:
Régis Hanol 2014-12-11 19:34:52 +01:00
parent e6e7948617
commit 1353557575
2 changed files with 8 additions and 0 deletions

View File

@ -174,6 +174,8 @@ class PostAction < ActiveRecord::Base
title = I18n.t("post_action_types.#{post_action_type}.email_title", title: post.topic.title) 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}") 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 = { opts = {
archetype: Archetype.private_message, archetype: Archetype.private_message,
title: title, title: title,

View File

@ -17,6 +17,12 @@ describe PostAction do
describe "messaging" 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 it "notify moderators integration test" do
post = create_post post = create_post
mod = moderator mod = moderator