Commit 5494235237c47ae58ef2d9753316f59bf4736e12
1 parent
c97dfe83
Exists in
master
and in
28 other branches
Fixing tests
Showing
4 changed files
with
22 additions
and
8 deletions
Show diff stats
app/models/forum.rb
| @@ -30,6 +30,7 @@ class Forum < Folder | @@ -30,6 +30,7 @@ class Forum < Folder | ||
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | def first_paragraph | 32 | def first_paragraph |
| 33 | + return '' if body.blank? | ||
| 33 | paragraphs = Hpricot(body).search('p') | 34 | paragraphs = Hpricot(body).search('p') |
| 34 | paragraphs.empty? ? '' : paragraphs.first.to_html | 35 | paragraphs.empty? ? '' : paragraphs.first.to_html |
| 35 | end | 36 | end |
features/profile_activities.feature
| @@ -7,15 +7,17 @@ Feature: list activities of a profile | @@ -7,15 +7,17 @@ Feature: list activities of a profile | ||
| 7 | | login | name | | 7 | | login | name | |
| 8 | | joaosilva | Joao Silva | | 8 | | joaosilva | Joao Silva | |
| 9 | And the following articles | 9 | And the following articles |
| 10 | - | owner | name | body | | ||
| 11 | - | booking | article to comment | first paragraph | | 10 | + | owner | name | body | |
| 11 | + | joaosilva | article to comment | first paragraph | | ||
| 12 | And the following comments | 12 | And the following comments |
| 13 | - | article | author | title | body | | ||
| 14 | - | article with comment | booking | hi | how are you? | | 13 | + | article | author | title | body | |
| 14 | + | article to comment | joaosilva | hi | how are you? | | ||
| 15 | 15 | ||
| 16 | Scenario: see the activity of a profile | 16 | Scenario: see the activity of a profile |
| 17 | Given I am logged in as "joaosilva" | 17 | Given I am logged in as "joaosilva" |
| 18 | - When I go to Jose Silva's homepage | 18 | + When I go to Joao Silva's homepage |
| 19 | +#Não tá rodando o delayed job :( | ||
| 20 | +Then I should see "dkjfhv" | ||
| 19 | Then I should see "first paragraph" within ".profile-activity-item" | 21 | Then I should see "first paragraph" within ".profile-activity-item" |
| 20 | And I should see "how are you?" within ".profile-wall-activities-comments" | 22 | And I should see "how are you?" within ".profile-wall-activities-comments" |
| 21 | 23 |
test/functional/profile_controller_test.rb
| @@ -1306,7 +1306,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1306,7 +1306,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
| 1306 | count = activity.comments.count | 1306 | count = activity.comments.count |
| 1307 | 1307 | ||
| 1308 | assert_equal 0, count | 1308 | assert_equal 0, count |
| 1309 | - post :leave_comment_on_activity, :profile => profile.identifier, :comment => {:body => 'something', :source_id => activity.id} | 1309 | + post :leave_comment_on_activity, :profile => profile.identifier, :comment => {:body => 'something'}, :source_id => activity.id |
| 1310 | assert_equal count + 1, activity.comments.count | 1310 | assert_equal count + 1, activity.comments.count |
| 1311 | assert_response :success | 1311 | assert_response :success |
| 1312 | assert_equal "Comment successfully added.", assigns(:message) | 1312 | assert_equal "Comment successfully added.", assigns(:message) |
| @@ -1318,9 +1318,9 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1318,9 +1318,9 @@ class ProfileControllerTest < ActionController::TestCase | ||
| 1318 | TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software') | 1318 | TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software') |
| 1319 | activity = ActionTracker::Record.last | 1319 | activity = ActionTracker::Record.last |
| 1320 | count = activity.comments.count | 1320 | count = activity.comments.count |
| 1321 | - | 1321 | +puts activity.inspect |
| 1322 | assert_equal 0, count | 1322 | assert_equal 0, count |
| 1323 | - post :leave_comment_on_activity, :profile => another_person.identifier, :comment => {:body => 'something', :source_id => activity.id} | 1323 | + post :leave_comment_on_activity, :profile => another_person.identifier, :comment => {:body => 'something'}, :source_id => activity.id |
| 1324 | assert_equal count + 1, activity.comments.count | 1324 | assert_equal count + 1, activity.comments.count |
| 1325 | assert_response :success | 1325 | assert_response :success |
| 1326 | assert_equal "Comment successfully added.", assigns(:message) | 1326 | assert_equal "Comment successfully added.", assigns(:message) |
test/unit/forum_test.rb
| @@ -122,4 +122,15 @@ class ForumTest < ActiveSupport::TestCase | @@ -122,4 +122,15 @@ class ForumTest < ActiveSupport::TestCase | ||
| 122 | f = fast_create(Forum, :body => 'Nothing to do here') | 122 | f = fast_create(Forum, :body => 'Nothing to do here') |
| 123 | assert_equal '', f.first_paragraph | 123 | assert_equal '', f.first_paragraph |
| 124 | end | 124 | end |
| 125 | + | ||
| 126 | + should 'provide first_paragraph even if body was not given' do | ||
| 127 | + f = fast_create(Forum) | ||
| 128 | + assert_equal '', f.first_paragraph | ||
| 129 | + end | ||
| 130 | + | ||
| 131 | + should 'provide first_paragraph even if body is nil' do | ||
| 132 | + f = fast_create(Forum, :body => nil) | ||
| 133 | + assert_equal '', f.first_paragraph | ||
| 134 | + end | ||
| 135 | + | ||
| 125 | end | 136 | end |