Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 1497b2d4c316dc60053659673dd6f017135615b0 1 parent f589d4c
@sebjacobs sebjacobs authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.