diff --git a/app/models/concerns/post_validations.rb b/app/models/concerns/post_validations.rb index 9b8fa745a..1deaa0e51 100644 --- a/app/models/concerns/post_validations.rb +++ b/app/models/concerns/post_validations.rb @@ -3,8 +3,8 @@ module PostValidations extend ActiveSupport::Concern included do - normalizes :body_markdown, with: lambda { |body_markdown| - body_markdown.encode(body_markdown.encoding, universal_newline: true) + normalizes :body_markdown, with: lambda { |text| + text.encode(text.encoding, universal_newline: true) } validate :tags_in_tag_set, if: -> { post_type.has_tags } diff --git a/app/models/post_history.rb b/app/models/post_history.rb index 4e1fdfd6b..2190ac642 100644 --- a/app/models/post_history.rb +++ b/app/models/post_history.rb @@ -11,6 +11,12 @@ class PostHistory < ApplicationRecord scope :of_type, ->(name) { joins(:post_history_type).where(post_history_types: { name: name }) } scope :on_undeleted, -> { joins(:post).where(posts: { deleted: false }) } + normalize_newlines = lambda { |text| + text.encode(text.encoding, universal_newline: true) + } + normalizes :before_state, with: normalize_newlines + normalizes :after_state, with: normalize_newlines + def before_tags tags.where(post_history_tags: { relationship: 'before' }) end diff --git a/app/views/post_history/_diff.html.erb b/app/views/post_history/_diff.html.erb index e63be8418..77eb63d7b 100644 --- a/app/views/post_history/_diff.html.erb +++ b/app/views/post_history/_diff.html.erb @@ -1,7 +1,7 @@