Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
AuthenticityTokenBug strikes again
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Murray committed Aug 7, 2008
1 parent c4787d1 commit 3ccaea1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/views/admin/product/remove.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</tbody>
</table>

<form method="post" action="">
<% form_tag '' do %>
<p class="buttons"><%= submit_tag "Delete Product", :class => 'button' %>
or <%= link_to 'Cancel', product_index_path %></p>
</form>
<% end %>
27 changes: 24 additions & 3 deletions spec/views/admin/product/remove.rhtml_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
require File.dirname(__FILE__) + '/../../../spec_helper'

describe 'admin/product/remove' do
it 'should render' do
assigns[:product] = Product.new
describe 'admin/product/remove' do
def render_remove
render 'admin/product/remove'
end

before(:each) do
assigns[:product] = Product.new
end

it 'should render' do
render_remove
end

it 'should include the authenticity token in a hidden input' do
template.stub!(:form_authenticity_token).and_return('MY SUPER SECRET TOKEN')
render_remove

response.should have_tag("form") do
with_tag("input[type='hidden'][name='authenticity_token'][value=?]", 'MY SUPER SECRET TOKEN')
end
end

it 'should post the form' do
render_remove
response.should have_tag("form[method='post']", :count => 1)
end
end

0 comments on commit 3ccaea1

Please sign in to comment.