Skip to content

Commit

Permalink
Undo delete comment feature
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviershay committed Dec 21, 2008
1 parent feef785 commit 0e47ab9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/views/admin/comments/_comment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<td>
<%= link_to(image_tag('silk/pencil.png', :alt => 'edit'), admin_comment_path(comment)) %>
<% form_for(:comment, comment, :url => admin_comment_path(comment), :html => {:class => 'delete-item', :method => :delete}) do |form| -%>
<%= image_submit_tag("silk/delete.png") %>
<%= image_submit_tag("silk/delete.png", :alt => "Delete Comment") %>
<% end -%>
</td>
</tr>
18 changes: 18 additions & 0 deletions features/admin_undo.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Undo
Because I am human and make mistakes
An admin
Should be able to undo actions they make

Scenario: delete a comment, then undo it
Given I am logged in
And the following comment exists:
| body |
| Accidental Delete |
When I go to /admin
And I follow "Comments"
And I press "Delete Comment"
And I follow "Actions"
And I press "Undo"
Then a comment exists with attributes:
| body |
| Accidental Delete |
24 changes: 23 additions & 1 deletion features/steps/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@

Then /a RuntimeError is thrown when I press "(.*)"/ do |button|
lambda {
clicks_button(button)
click_button(button)
}.should raise_error
end

Then /^the comment exists$/ do
Comment.count.should == 2
end

Given /^the following comments? exists:$/ do |comment_table|
comment_table.hashes.each do |hash|
Factory(:comment, hash)
end
end

Given /^a comment exists with attributes:$/ do |comment_table|
comment_table.hashes.each do |hash|
Comment.find(:first, :conditions => hash).should_not be_nil
end
end

Given /^a comment does not exist with attributes:$/ do |comment_table|
comment_table.hashes.each do |hash|
Comment.find(:first, :conditions => hash).should be_nil
end
end
6 changes: 3 additions & 3 deletions features/steps/common_webrat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# http://github.com/brynary/webrat

When /^I press "(.*)"$/ do |button|
clicks_button(button)
click_button(button)
end

When /^I follow "(.*)"$/ do |link|
clicks_link(link)
click_link(link)
end

When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
Expand All @@ -18,7 +18,7 @@
end

When /^I go to (.*)$/ do |page|
visits case page
visit case page
when "the home page"
"/"
else
Expand Down
2 changes: 1 addition & 1 deletion features/steps/env.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'webrat'
require 'webrat/rails'
require 'cucumber/rails/world'
Cucumber::Rails.use_transactional_fixtures

Expand Down

0 comments on commit 0e47ab9

Please sign in to comment.