From 3013d13b381ac219ebf6d50b879d4736345f2642 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Mon, 26 Oct 2015 01:25:53 +0100 Subject: [PATCH 1/2] Add paragraphs to comments Fix #600 --- app/helpers/text_with_links_helper.rb | 2 +- app/views/comments/_comment.html.erb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/text_with_links_helper.rb b/app/helpers/text_with_links_helper.rb index ca07daf39..fe726c51e 100644 --- a/app/helpers/text_with_links_helper.rb +++ b/app/helpers/text_with_links_helper.rb @@ -2,7 +2,7 @@ module TextWithLinksHelper def text_with_links(text) return unless text - sanitized = sanitize text, tags: [], attributes: [] + sanitized = sanitize(text, tags: [], attributes: []) Rinku.auto_link(sanitized, :all, 'target="_blank" rel="nofollow"').html_safe end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index ac61483fc..e2ce326aa 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -63,17 +63,17 @@ <% if comment.as_administrator? %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% elsif comment.as_moderator? %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% elsif comment.user.official? && comment.user_id == @commentable.author_id %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% elsif comment.user.official? %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% elsif comment.user_id == @commentable.author_id %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% else %> -

<%= text_with_links comment.body %>

+
<%= simple_format text_with_links comment.body %>
<% end %> <%= render 'comments/votes', comment: comment %> From fe55c0bdc2cfefe71a4dae780ad55ae7fca57b56 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Mon, 26 Oct 2015 01:35:21 +0100 Subject: [PATCH 2/2] Fix feature tests --- spec/features/comments/debates_spec.rb | 8 ++++---- spec/features/comments/proposals_spec.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index 34c0bb98b..cafc5ff40 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -219,7 +219,7 @@ feature 'Commenting debates' do within "#comments" do expect(page).to have_content "I am moderating!" expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "p.is-moderator" + expect(page).to have_css "div.is-moderator" expect(page).to have_css "img.moderator-avatar" end end @@ -244,7 +244,7 @@ feature 'Commenting debates' do within "#comment_#{comment.id}" do expect(page).to have_content "I am moderating!" expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "p.is-moderator" + expect(page).to have_css "div.is-moderator" expect(page).to have_css "img.moderator-avatar" end @@ -275,7 +275,7 @@ feature 'Commenting debates' do within "#comments" do expect(page).to have_content "I am your Admin!" expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "p.is-admin" + expect(page).to have_css "div.is-admin" expect(page).to have_css "img.admin-avatar" end end @@ -300,7 +300,7 @@ feature 'Commenting debates' do within "#comment_#{comment.id}" do expect(page).to have_content "Top of the world!" expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "p.is-admin" + expect(page).to have_css "div.is-admin" expect(page).to have_css "img.admin-avatar" end diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index ad3c26be9..28f4f0d2d 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -219,7 +219,7 @@ feature 'Commenting proposals' do within "#comments" do expect(page).to have_content "I am moderating!" expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "p.is-moderator" + expect(page).to have_css "div.is-moderator" expect(page).to have_css "img.moderator-avatar" end end @@ -244,7 +244,7 @@ feature 'Commenting proposals' do within "#comment_#{comment.id}" do expect(page).to have_content "I am moderating!" expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "p.is-moderator" + expect(page).to have_css "div.is-moderator" expect(page).to have_css "img.moderator-avatar" end @@ -275,7 +275,7 @@ feature 'Commenting proposals' do within "#comments" do expect(page).to have_content "I am your Admin!" expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "p.is-admin" + expect(page).to have_css "div.is-admin" expect(page).to have_css "img.admin-avatar" end end @@ -300,7 +300,7 @@ feature 'Commenting proposals' do within "#comment_#{comment.id}" do expect(page).to have_content "Top of the world!" expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "p.is-admin" + expect(page).to have_css "div.is-admin" expect(page).to have_css "img.admin-avatar" end