From 6f15dc60a46b77d79fe9c06bb70b45235935e869 Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Tue, 7 Jun 2016 15:34:55 -0400 Subject: [PATCH] not escape HTML of link to read more article on blog index with short format --- app/helpers/application_helper.rb | 4 ++-- test/integration/safe_strings_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 51567c6..1a41fa0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -723,11 +723,11 @@ module ApplicationHelper def display_short_format(article, options={}) options[:comments_link] ||= true options[:read_more_link] ||= true + lead_links = (options[:comments_link] ? link_to_comments(article) : '') + (options[:read_more_link] ? reference_to_article( _('Read more'), article) : '') html = content_tag('div', article.lead + content_tag('div', - (options[:comments_link] ? link_to_comments(article) : '') + - (options[:read_more_link] ? reference_to_article( _('Read more'), article) : ''), + lead_links.html_safe, :class => 'read-more' ), :class => 'short-post' diff --git a/test/integration/safe_strings_test.rb b/test/integration/safe_strings_test.rb index 7fbd2dc..f1868d3 100644 --- a/test/integration/safe_strings_test.rb +++ b/test/integration/safe_strings_test.rb @@ -175,4 +175,15 @@ class SafeStringsTest < ActionDispatch::IntegrationTest assert_select '.icon-selector .icon-edit' end + should 'not escape read more link to article on display short format' do + profile = fast_create Profile + blog = fast_create Blog, :name => 'Blog', :profile_id => profile.id + fast_create(TinyMceArticle, :name => "Post Test", :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false, :body => '

Lorem ipsum dolor sit amet

') + blog.update_attribute(:visualization_format, 'short') + + get "/#{profile.identifier}/blog" + assert_tag :tag => 'div', :attributes => {:class => 'read-more'}, :child => {:tag => 'a', :content => 'Read more'} + end + + end -- libgit2 0.21.2