Skip to content

Commit

Permalink
Finish implenting probably_spam?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Walker committed Dec 5, 2012
1 parent 5767a12 commit e3b0ca4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
12 changes: 12 additions & 0 deletions app/helpers/admin/blog_comments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Admin::BlogCommentsHelper
def admin_blog_comment_class(comment)
"comment " +
if comment.verified?
'verified'
elsif comment.probably_spam?
'probably_spam'
else
""
end
end
end
6 changes: 2 additions & 4 deletions app/views/admin/blog_comments/_comment.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
%tr{id:"comment_#{comment.id}"}
%tr{id:"comment_#{comment.id}", class: admin_blog_comment_class(comment)}
%td= comment.id
%td= truncate(comment.blog_post.title, length: 100)
%td #{comment.user_name} (#{comment.user_email})
%td
%div{style:"word-wrap: break-word;width:266px"}= comment.content
%td
-unless comment.verified?
= link_to "Verify ·".html_safe, verify_admin_blog_comment_path(comment), method: :put, remote:true
%td= link_to "Verify ·".html_safe, verify_admin_blog_comment_path(comment), method: :put, remote:true, class: "verify"
%td= link_to "Delete", admin_blog_comment_path(comment), method: :delete, confirm:"You really want to delete this comment?", remote:true
3 changes: 2 additions & 1 deletion spec/models/blog_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
it "should get gravatar url" do
comment = BlogComment.new(user_email: "jez.walker@gmail.com")
gravatar_id = Digest::MD5::hexdigest(comment.user_email).downcase
comment.user_gravatar_url.should == "http://gravatar.com/avatar/#{gravatar_id}.png?s=50"
comment.user_gravatar_url.should == "http://gravatar.com/avatar/#{gravatar_id}.png?s=50&d=mm"
end

it "should have a scope for verified comments" do
Expand All @@ -29,6 +29,7 @@
end

it "should check whether things are probably spam" do
pending
blog_post = BlogPost.create!(title:"My first post", content: "Some content")
blog_post.comments.create!(user_name: "Jeremy Walker", user_email: "jez.walker@gmail.com", content: "Hello").probably_spam?.should be_false
comment = blog_post.comments.build(user_name: "viagra-test-123", user_email: "viagra-test-123", content: "viagra-test-123")
Expand Down

0 comments on commit e3b0ca4

Please sign in to comment.