[Git][noosfero/noosfero][master] 4 commits: Refactoring article content visualization

Rodrigo Souto gitlab at gitlab.com
Wed Jun 17 15:19:42 BRT 2015


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
5ee24034 by André Bernardes at 2015-06-17T15:19:06Z
Refactoring article content visualization

  - Added image label
  - Added image to article body
  - Changed some minor positioning

Signed-off-by: André Bernardes <andrebsguedes at gmail.com>
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Fábio Teixeira <fabio1079 at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at gmail.com>

- - - - -
ac65bb0e by Gabriela Navarro at 2015-06-17T15:19:06Z
Update schema

- - - - -
5ddb93d8 by André Bernardes at 2015-06-17T15:19:06Z
Improved event display layout

Signed-off-by: André Bernardes <andrebsguedes at gmail.com>
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Fabio Teixeira <fabio1079 at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at gmail.com>

- - - - -
53c76729 by Rodrigo Souto at 2015-06-17T15:19:07Z
content-viewer: use lead instead of straight abstract

- - - - -


24 changed files:

- app/controllers/my_profile/cms_controller.rb
- app/helpers/comment_helper.rb
- app/helpers/content_viewer_helper.rb
- app/models/article.rb
- app/models/event.rb
- app/models/image.rb
- + app/views/content_viewer/_article_title.html.erb
- app/views/content_viewer/_article_toolbar.html.erb
- app/views/content_viewer/_display_compact_format.html.erb
- + app/views/content_viewer/_publishing_info.html.erb
- + app/views/content_viewer/event_page.html.erb
- app/views/content_viewer/view_page.html.erb
- app/views/shared/_change_image.html.erb
- + db/migrate/20150603182105_add_label_to_image.rb
- db/schema.rb
- features/events.feature
- public/designs/themes/base/style.css
- + public/images/calendar_date_select/calendar-icon.png
- + public/images/globe-icon.png
- + public/images/icone_pin.png
- public/stylesheets/application.css
- test/functional/cms_controller_test.rb
- test/functional/content_viewer_controller_test.rb
- test/unit/event_test.rb


Changes:

=====================================
app/controllers/my_profile/cms_controller.rb
=====================================
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -101,6 +101,11 @@ class CmsController < MyProfileController
     record_coming
     if request.post?
       @article.image = nil if params[:remove_image] == 'true'
+      if @article.image.present? && params[:article][:image_builder] &&
+        params[:article][:image_builder][:label]
+        @article.image.label = params[:article][:image_builder][:label]
+        @article.image.save!
+      end
       @article.last_changed_by = user
       if @article.update_attributes(params[:article])
         if !continue


=====================================
app/helpers/comment_helper.rb
=====================================
--- a/app/helpers/comment_helper.rb
+++ b/app/helpers/comment_helper.rb
@@ -16,7 +16,7 @@ module CommentHelper
         content_tag('span', show_date(article.published_at), :class => 'date') +
         content_tag('span', [_(", by %s") % link_to(article.author_name, article.author_url)], :class => 'author') +
         content_tag('span', comments, :class => 'comments'),
-        :class => 'created-at'
+        :class => 'publishing-info'
       )
     end
     title


=====================================
app/helpers/content_viewer_helper.rb
=====================================
--- a/app/helpers/content_viewer_helper.rb
+++ b/app/helpers/content_viewer_helper.rb
@@ -30,7 +30,7 @@ module ContentViewerHelper
         date_format +
         content_tag('span', _(", by %s") % (article.author ? link_to(article.author_name, article.author_url) : article.author_name), :class => 'author') +
         content_tag('span', comments, :class => 'comments'),
-        :class => 'created-at'
+        :class => 'publishing-info'
       )
     end
     title


=====================================
app/models/article.rb
=====================================
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -724,8 +724,9 @@ class Article < ActiveRecord::Base
     paragraphs.empty? ? '' : paragraphs.first.to_html
   end
 
-  def lead
-    abstract.blank? ? first_paragraph.html_safe : abstract.html_safe
+  def lead(length = nil)
+    content = abstract.blank? ? first_paragraph.html_safe : abstract.html_safe
+    length.present? ? content.truncate(length) : content
   end
 
   def short_lead


=====================================
app/models/event.rb
=====================================
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -98,47 +98,19 @@ class Event < Article
     start_date..(end_date||start_date)
   end
 
-  # FIXME this shouldn't be needed
-  include ActionView::Helpers::TagHelper
-  include ActionView::Helpers::UrlHelper
-  include DatesHelper
+  def first_paragraph
+    paragraphs = Nokogiri::HTML.fragment(self.body).css('p')
+    paragraphs.empty? ? '' : paragraphs.first.to_html
+  end
 
   def to_html(options = {})
+    event = self
+    format = options[:format]
 
-    result = ''
-    html = ::Builder::XmlMarkup.new(:target => result)
-
-    html.div(:class => 'event-info' ) {
-      html.ul(:class => 'event-data' ) {
-        html.li(:class => 'event-dates' ) {
-          html.span _('When:')
-          html.text! show_period(start_date, end_date)
-        } if start_date.present? || end_date.present?
-        html.li {
-          html.span _('URL:')
-          html.a(self.link || "", 'href' => self.link || "")
-        } if self.link.present?
-        html.li {
-          html.span _('Address:')
-          html.text! self.address || ""
-        } if self.address.present?
-      }
-
-      # TODO: some good soul, please clean this ugly hack:
-      if self.body
-        html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description')
-      end
-    }
-
-    if self.body
-      if options[:format] == 'short'
-        result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', display_short_format(self))
-      else
-        result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.body)
-      end
+    proc do
+      render :file => 'content_viewer/event_page', :locals => { :event => event,
+        :format => format }
     end
-
-    result
   end
 
   def duration


=====================================
app/models/image.rb
=====================================
--- a/app/models/image.rb
+++ b/app/models/image.rb
@@ -23,7 +23,7 @@ class Image < ActiveRecord::Base
 
   postgresql_attachment_fu
 
-  attr_accessible :uploaded_data
+  attr_accessible :uploaded_data, :label
 
   def current_data
     File.file?(full_filename) ? File.read(full_filename) : nil


=====================================
app/views/content_viewer/_article_title.html.erb
=====================================
--- /dev/null
+++ b/app/views/content_viewer/_article_title.html.erb
@@ -0,0 +1,20 @@
+<% if @page.belongs_to_blog? || @page.belongs_to_forum?%>
+  <h1 class="title">
+    <% if no_link %>
+      <%= h(@page.title) %>
+    <% else %>
+      <%= link_to(@page.name, @page.url) %>
+    <% end %>
+  </h1>
+  <%= render :partial => "publishing_info" %>
+  <% unless @page.abstract.blank? %>
+    <div class="preview">
+      <%= @page.lead %>
+    </div>
+  <% end %>
+<% else %>
+  <h1 class="title">
+    <%= h(@page.title) %>
+  </h1>
+  <%= render :partial => "publishing_info" %>
+<% end %>


=====================================
app/views/content_viewer/_article_toolbar.html.erb
=====================================
--- a/app/views/content_viewer/_article_toolbar.html.erb
+++ b/app/views/content_viewer/_article_toolbar.html.erb
@@ -64,7 +64,7 @@
     <% end %>
     <%= link_to(image_tag('/images/icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %>
     <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %>
-    <%= article_title(@page, :no_link => true) %>
+    <%= render :partial => 'article_title', :locals => {:no_link => true} %>
     <%= article_translations(@page) %>
   </div>
 </div>


=====================================
app/views/content_viewer/_display_compact_format.html.erb
=====================================
--- a/app/views/content_viewer/_display_compact_format.html.erb
+++ b/app/views/content_viewer/_display_compact_format.html.erb
@@ -16,6 +16,6 @@
     </div>
   <% end %>
   <div class = <%= className %> >
-      <%= article.abstract.truncate(400) %>
+      <%= article.lead(400) %>
   </div>
 </div>


=====================================
app/views/content_viewer/_publishing_info.html.erb
=====================================
--- /dev/null
+++ b/app/views/content_viewer/_publishing_info.html.erb
@@ -0,0 +1,29 @@
+<span class="publishing-info">
+  <span class="date">
+    <%= show_date(@page.published_at) %>
+  </span>
+  <span class="author">
+    <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %>
+  </span>
+<% unless @no_comments %>
+  <span class="comments">
+    <%= (" - %s") % link_to_comments(@page)%>
+  </span>
+<% end %>
+</span>
+
+<% if @page.display_hits? || @page.license.present? %>
+  <div id='article-sub-header'>
+    <% if @page.display_hits? %>
+      <div id="article-hits">
+        <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %>
+      </div>
+    <% end %>
+
+    <% if @page.license.present? %>
+      <div id="article-license">
+        <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %>
+      </div>
+    <% end %>
+  </div>
+<% end %>


=====================================
app/views/content_viewer/event_page.html.erb
=====================================
--- /dev/null
+++ b/app/views/content_viewer/event_page.html.erb
@@ -0,0 +1,41 @@
+<div class="event-card">
+  <div class="event-image">
+    <% if event.image %>
+      <%= image_tag(event.image.public_filename(:big)) %>
+    <% end %>
+  </div>
+  <div class="about-event">
+    <% if event.start_date.present? || event.end_date.present? %>
+      <span class="event-date">
+        <%= show_period(event.start_date, event.end_date) %>
+      </span>
+    <% end %>
+    <% if event.link.present? %>
+      <span class="event-link">
+        <%= link_to event.link, event.link %>
+      </span>
+    <% end %>
+    <% if event.address.present? %>
+      <span class="event-address">
+        <span>
+          <%= event.address %>
+        </span>
+      </span>
+    <% end %>
+  </div>
+</div>
+
+<div class="event-body">
+  <% if format == 'short' %>
+    <%= display_short_format event, :comments_link => false, :read_more_link => false %>
+  <% else %>
+    <% unless event.abstract.blank? %>
+      <div class="event-lead">
+        <%= event.article_lead %>
+      </div>
+    <% end %>
+    <div class="event-content">
+      <%= event.body %>
+    </div>
+  <% end %>
+</div>


=====================================
app/views/content_viewer/view_page.html.erb
=====================================
--- a/app/views/content_viewer/view_page.html.erb
+++ b/app/views/content_viewer/view_page.html.erb
@@ -24,22 +24,6 @@
   <%= render :partial => 'article_toolbar' %>
 </div>
 
-<% if @page.display_hits? || @page.license.present? %>
-  <div id='article-sub-header'>
-    <% if @page.display_hits? %>
-      <div id="article-hits">
-        <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %>
-      </div>
-    <% end %>
-
-    <% if @page.license.present? %>
-      <div id="article-license">
-        <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %>
-      </div>
-    <% end %>
-  </div>
-<% end %>
-
 <% if NOOSFERO_CONF['addthis_enabled'] %>
   <%= render :partial => 'addthis' %>
 <% end %>
@@ -47,6 +31,12 @@
 <% cache(@page.cache_key(params, user, language)) do %>
   <div class="<%="article-body article-body-" + @page.css_class_name %>">
     <% options = @page.image? ? {:gallery_view => true} : {} %>
+    <% if @page.image.present? && !@page.event? %>
+      <div class="article-body-img">
+        <%= image_tag(@page.image.public_filename) %>
+        <p><%= @page.image.label%></p>
+      </div>
+    <% end %>
     <%= article_to_html(@page, options) %>
     <br style="clear:both" />
   </div> <!-- end class="article-body" -->


=====================================
app/views/shared/_change_image.html.erb
=====================================
--- a/app/views/shared/_change_image.html.erb
+++ b/app/views/shared/_change_image.html.erb
@@ -1,2 +1,3 @@
-  <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %>
-  <%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%>
+<%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %>
+<%= labelled_form_field(_("Image Label:"), i.text_field(:label)) %>
+<%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%>


=====================================
db/migrate/20150603182105_add_label_to_image.rb
=====================================
--- /dev/null
+++ b/db/migrate/20150603182105_add_label_to_image.rb
@@ -0,0 +1,8 @@
+class AddLabelToImage < ActiveRecord::Migration
+  def up
+    add_column :images, :label, :string, :default => ""
+  end
+  def down
+    remove_column :images, :label
+  end
+end


=====================================
db/schema.rb
=====================================
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20150602142030) do
+ActiveRecord::Schema.define(:version => 20150603182105) do
 
   create_table "abuse_reports", :force => true do |t|
     t.integer  "reporter_id"
@@ -376,6 +376,7 @@ ActiveRecord::Schema.define(:version => 20150602142030) do
     t.integer "width"
     t.integer "height"
     t.boolean "thumbnails_processed", :default => false
+    t.string  "label",                :default => ""
   end
 
   add_index "images", ["parent_id"], :name => "index_images_on_parent_id"


=====================================
features/events.feature
=====================================
--- a/features/events.feature
+++ b/features/events.feature
@@ -160,6 +160,7 @@ Feature: events
     When I am on /search/events
     Then I should see "Colivre.net's Events"
 
+
   @selenium
   Scenario: published events should be listed in the agenda too
     Given the following community


=====================================
public/designs/themes/base/style.css
=====================================
--- a/public/designs/themes/base/style.css
+++ b/public/designs/themes/base/style.css
@@ -1061,15 +1061,18 @@ hr.pre-posts, hr.sep-posts {
   text-decoration: none;
 }
 
-#content .main-block .created-at {
+#content .main-block .publishing-info {
   text-align: left;
   color: #AAA;
+  font-size: 11px;
+  /*padding-top: 20px;*/
+  margin-bottom:15px;
 }
-#content .main-block .created-at a {
+#content .main-block .publishing-info a {
   color: #AAA;
   text-decoration: none;
 }
-#content .main-block .created-at a:hover {
+#content .main-block .publishing-info a:hover {
   color: #555;
   text-decoration: underline;
 }
@@ -1415,3 +1418,116 @@ table#recaptcha_table tr:hover td {
   color:#333;
 }
 
+/************************* Article Page *****************************/
+
+#article-header .preview {
+  font-size: 15px;
+}
+
+.article-body-img {
+  float: left;
+  margin-right: 20px;
+  margin-top: 5px;
+}
+
+#content #article .article-body .article-body-img img {
+  height: auto;
+  width: auto;
+  min-height: 120px;
+  max-height: 180px;
+  max-width: 250px;
+  background-position: center center;
+  background-repeat: no-repeat;
+}
+
+#content #article .article-body .article-body-img p {
+  margin-bottom: 10px;
+  font-size: 10px;
+  min-height: 20px;
+  text-align:
+}
+/* Noosfero Events */
+
+.event-card {
+  float: left;
+  padding-top: 25px;
+  width: 494px;
+  height: 116px;
+  background-repeat: no-repeat;
+  margin-bottom: 30px;
+}
+
+.event-image {
+  position: relative;
+  float: left;
+  padding-right: 22px;
+  max-width: 130px;
+  height: 130px;
+}
+
+#content #article .article-body img{
+  max-height: 100%;
+}
+
+.about-event {
+  position: relative;
+  float: left;
+  height: 160px;
+  width: 300px;
+  max-width: 300px;
+}
+
+.about-event > span {
+  display: block;
+  max-width: inherit;
+  margin-left: 20px;
+  padding-left: 21px;
+  line-height: 13px;
+  margin-right: 11px;
+}
+
+.about-event .event-date {
+  margin-top: 3px;
+}
+
+.about-event .event-address {
+  margin-top: 19px;
+}
+
+.about-event .event-address span {
+  display: block;
+  margin-left: 0px;
+  margin-top: 4.4px;
+  line-height: 14px;
+}
+
+.event-date {
+  background: url('/images/calendar_date_select/calendar-icon.png') no-repeat left center;
+  padding: 5px;
+}
+
+.event-link {
+  background: url('/images/globe-icon.png') no-repeat left center;
+  margin-top: 18px;
+}
+
+.event-link a {
+}
+
+.event-address {
+  background: url('/images/icone_pin.png') no-repeat left top;
+}
+
+.event-body {
+  float: left;
+}
+
+.event-body .event-lead {
+  font-size: 15px;
+}
+
+.event-body .event-content p {
+  margin-top: 20px;
+  width: 494px;
+  padding-left: 2px;
+}


=====================================
public/images/calendar_date_select/calendar-icon.png
=====================================
Binary files /dev/null and b/public/images/calendar_date_select/calendar-icon.png differ


=====================================
public/images/globe-icon.png
=====================================
Binary files /dev/null and b/public/images/globe-icon.png differ


=====================================
public/images/icone_pin.png
=====================================
Binary files /dev/null and b/public/images/icone_pin.png differ


=====================================
public/stylesheets/application.css
=====================================
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1052,6 +1052,11 @@ code input {
   margin-top: 10px;
   display: none;
 }
+
+#change-image {
+  display: table-caption;
+}
+
 .zoomable-image {
   position: relative;
   display: inline-block;
@@ -1518,13 +1523,13 @@ a.comment-picture {
   text-align: right;
   color: gray;
 }
-#content .created-at {
+#content .publishing-info {
   color: gray;
   font-size: 12px;
   display: block;
   text-align: right;
 }
-#content .blog-post .created-at {
+#content .blog-post .publishing-info {
   text-align: left;
 }
 #content #article .pagination .prev_page {
@@ -1596,7 +1601,7 @@ div.article-body p img {
 .blog-post.not-published a {
   text-decoration: none;
 }
-#content .blog-post.not-published .created-at {
+#content .blog-post.not-published .publishing-info {
   text-align: left;
 }
 .blog-post.not-published .metadata {


=====================================
test/functional/cms_controller_test.rb
=====================================
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -223,6 +223,20 @@ class CmsControllerTest < ActionController::TestCase
     assert_equal profile, a.last_changed_by
   end
 
+  should 'be able to set label to article image' do
+    login_as(profile.identifier)
+    post :new, :type => TextileArticle.name, :profile => profile.identifier,
+         :article => {
+           :name => 'adding-image-label',
+           :image_builder => {
+             :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'),
+             :label => 'test-label'
+           }
+         }
+     a = Article.last
+     assert_equal a.image.label, 'test-label'
+  end
+
   should 'edit by using the correct template to display the editor depending on the mime-type' do
     a = profile.articles.build(:name => 'test document')
     a.save!
@@ -318,6 +332,20 @@ class CmsControllerTest < ActionController::TestCase
     end
   end
 
+  should 'be able to edit an image label' do
+    image = fast_create(Image, :content_type => 'image/png', :filename => 'event-image.png', :label => 'test_label', :size => 1014)
+    article = fast_create(Article, :profile_id => profile.id, :name => 'test_label_article', :body => 'test_content')
+    article.image = image
+    article.save
+    assert_not_nil article
+    assert_not_nil article.image
+    assert_equal 'test_label', article.image.label
+
+    post :edit, :profile => profile.identifier, :id => article.id, :article => {:image_builder => { :label => 'test_label_modified'}}
+    article.reload
+    assert_equal 'test_label_modified', article.image.label
+  end
+
    should 'be able to upload more than one file at once' do
     assert_difference 'UploadedFile.count', 2 do
       post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), fixture_file_upload('/files/rails.png', 'text/plain')]


=====================================
test/functional/content_viewer_controller_test.rb
=====================================
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -124,6 +124,19 @@ class ContentViewerControllerTest < ActionController::TestCase
     assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :content => /This article's tags:/ }
   end
 
+  should "display image label on article image" do
+    page = TinyMceArticle.create!(
+             :profile => profile,
+             :name => 'myarticle',
+             :image_builder => {
+               :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'),
+               :label => 'test-label'
+             }
+           )
+    get :view_page, page.url
+    assert_match /test-label/, @response.body
+  end
+
   should "not display current article's tags" do
     page = profile.articles.create!(:name => 'myarticle', :body => 'test article')
 


=====================================
test/unit/event_test.rb
=====================================
--- a/test/unit/event_test.rb
+++ b/test/unit/event_test.rb
@@ -109,17 +109,20 @@ class EventTest < ActiveSupport::TestCase
   end
 
   should 'provide nice display format' do
-    e = build(Event, :start_date => Date.new(2008,1,1), :end_date => Date.new(2008,1,1), :link => 'http://www.myevent.org', :body => 'my somewhat short description')
+    event = build(Event, :start_date => Date.new(2008,1,1), :end_date => Date.new(2008,1,1), :link => 'http://www.myevent.org', :body => '<p>my somewhat short description</p>')
+    display = instance_eval(&event.to_html)
 
-    assert_tag_in_string e.to_html, :content => Regexp.new("January 1, 2008")
-    assert_tag_in_string e.to_html, :content => 'my somewhat short description'
-    assert_tag_in_string e.to_html, :tag => 'a', :attributes => { :href  => 'http://www.myevent.org' }, :content => 'http://www.myevent.org'
+    assert_tag_in_string display, :content => Regexp.new("January 1, 2008")
+    assert_tag_in_string display, :content => Regexp.new('my somewhat short description')
+    assert_tag_in_string display, :content => Regexp.new('http://www.myevent.org')
   end
 
   should 'not crash when body is blank' do
     e = Event.new
     assert_nil e.body
-    assert_no_match(/_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____/, e.to_html)
+    assert_nothing_raised  do
+      instance_eval(&e.to_html)
+    end
   end
 
   should 'add http:// to the link if not already present' do
@@ -141,10 +144,19 @@ class EventTest < ActiveSupport::TestCase
     assert_equal '', a.link
   end
 
+  should 'get the first paragraph' do
+    profile = create_user('testuser').person
+    event = create(Event, :profile => profile, :name => 'test',
+    :body => '<p>first paragraph </p><p>second paragraph </p>',
+    :link => 'www.colivre.coop.br', :start_date => Date.today)
+
+    assert_match '<p>first paragraph </p>', event.first_paragraph
+  end
+
   should 'not escape HTML in body' do
     a = build(Event, :body => '<p>a paragraph of text</p>', :link => 'www.gnu.org')
 
-    assert_match '<p>a paragraph of text</p>', a.to_html
+    assert_match '<p>a paragraph of text</p>', instance_eval(&a.to_html)
   end
 
   should 'filter HTML in body' do
@@ -324,7 +336,7 @@ class EventTest < ActiveSupport::TestCase
     environment = fast_create(Environment)
     environment.languages = nil
     profile = fast_create(Person, :environment_id => environment.id)
- 
+
     event = Event.new(:profile => profile)
 
     assert !event.translatable?
@@ -337,11 +349,11 @@ class EventTest < ActiveSupport::TestCase
     event = fast_create(Event, :profile_id => profile.id)
 
     assert !event.translatable?
- 
+
 
     environment.languages = ['en','pt','fr']
     environment.save
-    event.reload 
+    event.reload
     assert event.translatable?
   end
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/82d3ed8efd444c036791dcc219dd4d3146d7a00e...53c76729fced2e974abfafb065ac2397d7ef6faa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150617/8797b9b6/attachment-0001.html>


More information about the Noosfero-dev mailing list