Skip to content

Commit

Permalink
allow admin to delete comments
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderpantsGnome committed Jan 5, 2011
1 parent 46d02d3 commit 426d2e3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def create
end
end

def destroy
comment.destroy
redirect_to entry_path(entry), :notice => 'Comment was deleted'
end

private

def entry
Expand Down
5 changes: 5 additions & 0 deletions app/stylesheets/jabe.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ h1#site-tagline {
.comment {
clear:both;

.delete {
float:right;
padding-top:2px;
}

.gravatar {
margin:10px 10px 10px 0;
float:left;
Expand Down
6 changes: 6 additions & 0 deletions app/views/entries/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
- if entry.comments.any?
- entry.comments.each do |comment|
.comment
- if admin_signed_in?
.delete
= link_to image_tag('delete.png'),
entry_comment_path(entry, comment),
:confirm => 'Are you sure?',
:method => :delete
- if comment.respond_to?(:gravatar_url)
.gravatar
= image_tag comment.gravatar_url(:default => default_gravatar_url)
Expand Down
Binary file added public/images/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/dummy/features/entries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ Feature: Interacting with entries
Then I should see "Michael"
And I should see "Cool post"
And the entry should have 1 comment
And the page should not contain "Are you sure"
And "[email protected]" should receive an email
When I open the email
Then I should see "Michael" in the email body
Then I should see "[email protected]" in the email body
Then I should see "foo.example.com" in the email body
Then I should see "Cool post" in the email body
When a logged in admin
And I am on the home page
And I follow the title of the entry
Then the page should contain "Are you sure"

Scenario: A bot submits a comment
When I fill in "comment_name" with "v1@gr@"
Expand Down
8 changes: 8 additions & 0 deletions test/dummy/features/step_definitions/support_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
debugger
true
end

Then /^the page should contain "([^"]*)"$/ do |string|
page.body.match(/#{string}/).should_not be_nil
end

Then /^the page should not contain "([^"]*)"$/ do |string|
page.body.match(/#{string}/).should be_nil
end

0 comments on commit 426d2e3

Please sign in to comment.