From 5494235237c47ae58ef2d9753316f59bf4736e12 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Fri, 20 Apr 2012 19:19:06 -0300 Subject: [PATCH] Fixing tests --- app/models/forum.rb | 1 + features/profile_activities.feature | 12 +++++++----- test/functional/profile_controller_test.rb | 6 +++--- test/unit/forum_test.rb | 11 +++++++++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/models/forum.rb b/app/models/forum.rb index 600741a..51ed1af 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -30,6 +30,7 @@ class Forum < Folder end def first_paragraph + return '' if body.blank? paragraphs = Hpricot(body).search('p') paragraphs.empty? ? '' : paragraphs.first.to_html end diff --git a/features/profile_activities.feature b/features/profile_activities.feature index c2ffc4d..38ea67d 100644 --- a/features/profile_activities.feature +++ b/features/profile_activities.feature @@ -7,15 +7,17 @@ Feature: list activities of a profile | login | name | | joaosilva | Joao Silva | And the following articles - | owner | name | body | - | booking | article to comment | first paragraph | + | owner | name | body | + | joaosilva | article to comment | first paragraph | And the following comments - | article | author | title | body | - | article with comment | booking | hi | how are you? | + | article | author | title | body | + | article to comment | joaosilva | hi | how are you? | Scenario: see the activity of a profile Given I am logged in as "joaosilva" - When I go to Jose Silva's homepage + When I go to Joao Silva's homepage +#Não tá rodando o delayed job :( +Then I should see "dkjfhv" Then I should see "first paragraph" within ".profile-activity-item" And I should see "how are you?" within ".profile-wall-activities-comments" diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 579f8e3..0bed02d 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -1306,7 +1306,7 @@ class ProfileControllerTest < ActionController::TestCase count = activity.comments.count assert_equal 0, count - post :leave_comment_on_activity, :profile => profile.identifier, :comment => {:body => 'something', :source_id => activity.id} + post :leave_comment_on_activity, :profile => profile.identifier, :comment => {:body => 'something'}, :source_id => activity.id assert_equal count + 1, activity.comments.count assert_response :success assert_equal "Comment successfully added.", assigns(:message) @@ -1318,9 +1318,9 @@ class ProfileControllerTest < ActionController::TestCase TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software') activity = ActionTracker::Record.last count = activity.comments.count - +puts activity.inspect assert_equal 0, count - post :leave_comment_on_activity, :profile => another_person.identifier, :comment => {:body => 'something', :source_id => activity.id} + post :leave_comment_on_activity, :profile => another_person.identifier, :comment => {:body => 'something'}, :source_id => activity.id assert_equal count + 1, activity.comments.count assert_response :success assert_equal "Comment successfully added.", assigns(:message) diff --git a/test/unit/forum_test.rb b/test/unit/forum_test.rb index fed6053..496801f 100644 --- a/test/unit/forum_test.rb +++ b/test/unit/forum_test.rb @@ -122,4 +122,15 @@ class ForumTest < ActiveSupport::TestCase f = fast_create(Forum, :body => 'Nothing to do here') assert_equal '', f.first_paragraph end + + should 'provide first_paragraph even if body was not given' do + f = fast_create(Forum) + assert_equal '', f.first_paragraph + end + + should 'provide first_paragraph even if body is nil' do + f = fast_create(Forum, :body => nil) + assert_equal '', f.first_paragraph + end + end -- libgit2 0.21.2