Skip to content
Browse files

Bug fix: fixed 500 error when creating an entity with a blank comment

  • Loading branch information...
1 parent f589d4c commit 1497b2d4c316dc60053659673dd6f017135615b0 @sebjacobs sebjacobs committed Jun 22, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/fat_free_crm/comment_extensions.rb
  2. +6 −0 spec/lib/comment_extensions_spec.rb
View
2 lib/fat_free_crm/comment_extensions.rb
@@ -14,7 +14,7 @@ def uses_comment_extensions
module InstanceMethods
def add_comment_by_user(comment_body, user)
- comments.create(:comment => comment_body, :user => user)
+ comments.create(:comment => comment_body, :user => user) if comment_body.present?
end
end
end
View
6 spec/lib/comment_extensions_spec.rb
@@ -19,5 +19,11 @@
entity.add_comment_by_user("I will handle this one", user)
entity.reload.comments.map(&:comment).should include("I will handle this one")
end
+
+ it "should not create a comment if body is blank" do
+ entity = CommentableEntity.create
+ entity.add_comment_by_user("", user)
+ entity.reload.comments.should be_empty
+ end
end
end

0 comments on commit 1497b2d

Please sign in to comment.
Something went wrong with that request. Please try again.