Commit 4ed8d8c3bbaec4e4005fd3f4657b66a128de58f7

Authored by Braulio Bhavamitra
2 parents eb631713 6f15dc60

Merge branch 'fix_escape_html_on_display_short_format_of_article' into 'master'

not escape HTML of link to read more article on blog index with short format

This commit wants to fix escape HTML on read more link on blog posts list when post not accept comments and blog is setup to display short format as image attached
![Destaques_-_Use_the_environment_-_2016-06-07_10.07.06](/uploads/762b5b8921c8cd1a657e8d1d8c87985b/Destaques_-_Use_the_environment_-_2016-06-07_10.07.06.png)

See merge request !958
app/helpers/application_helper.rb
@@ -723,11 +723,11 @@ module ApplicationHelper @@ -723,11 +723,11 @@ module ApplicationHelper
723 def display_short_format(article, options={}) 723 def display_short_format(article, options={})
724 options[:comments_link] ||= true 724 options[:comments_link] ||= true
725 options[:read_more_link] ||= true 725 options[:read_more_link] ||= true
  726 + lead_links = (options[:comments_link] ? link_to_comments(article) : '') + (options[:read_more_link] ? reference_to_article( _('Read more'), article) : '')
726 html = content_tag('div', 727 html = content_tag('div',
727 article.lead + 728 article.lead +
728 content_tag('div', 729 content_tag('div',
729 - (options[:comments_link] ? link_to_comments(article) : '') +  
730 - (options[:read_more_link] ? reference_to_article( _('Read more'), article) : ''), 730 + lead_links.html_safe,
731 :class => 'read-more' 731 :class => 'read-more'
732 ), 732 ),
733 :class => 'short-post' 733 :class => 'short-post'
test/integration/safe_strings_test.rb
@@ -175,4 +175,15 @@ class SafeStringsTest < ActionDispatch::IntegrationTest @@ -175,4 +175,15 @@ class SafeStringsTest < ActionDispatch::IntegrationTest
175 assert_select '.icon-selector .icon-edit' 175 assert_select '.icon-selector .icon-edit'
176 end 176 end
177 177
  178 + should 'not escape read more link to article on display short format' do
  179 + profile = fast_create Profile
  180 + blog = fast_create Blog, :name => 'Blog', :profile_id => profile.id
  181 + fast_create(TinyMceArticle, :name => "Post Test", :profile_id => profile.id, :parent_id => blog.id, :accept_comments => false, :body => '<p>Lorem ipsum dolor sit amet</p>')
  182 + blog.update_attribute(:visualization_format, 'short')
  183 +
  184 + get "/#{profile.identifier}/blog"
  185 + assert_tag :tag => 'div', :attributes => {:class => 'read-more'}, :child => {:tag => 'a', :content => 'Read more'}
  186 + end
  187 +
  188 +
178 end 189 end