Commit bb6ca315 authored by dgt's avatar dgt

Merge branch '260-truncate-text-for-page_histories-details-error-500-for-long-titles' into 'master'

Resolve "Truncate text for page_histories > details - Error 500 for long titles"

Closes #260

See merge request !233
parents 425a39d9 cd553124
......@@ -114,8 +114,8 @@ class Page::History::ChangeTitle < Page::History
def details_from_page
{
from: page.previous_changes['title'].first,
to: page.title
from: page.previous_changes['title'].first.try.truncate(100, separator: ' '),
to: page.title.try.truncate(100, separator: ' ')
}
end
end
......
......@@ -73,6 +73,15 @@ class Page::HistoryTest < ActiveSupport::TestCase
assert_equal 'Nice title', page_history.details[:to]
end
def test_change_title_saves_old_and_new_value
page = FactoryBot.create(:page, title: 'Bad title')
page.update_attribute :title, 'Nice title which is far too long and has to be truncated to be saved. We had to truncate the title, because there were titles which did not fit into the database'
Tracking::Action.track :update_title, user: @user, page: page
page_history = Page::History::ChangeTitle.where(page_id: page).first
assert_equal 'Bad title', page_history.details[:from]
assert_equal 'Nice title which is far too long and has to be truncated to be saved. We had to truncate the...', page_history.details[:to]
end
def test_recipients_for_single_notifications
user = FactoryBot.create(:user, receive_notifications: nil)
user_a = FactoryBot.create(:user, receive_notifications: 'Digest')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment