Post by Peter Cooper on June 18th, 2006
How to force and test POST vs GET methods for dangerous actions in Rails

- Specify Rails Response Type via the URL
- Test Driven RJS with “ARTS: Another RJS Testing System”
- Write functional tests in Rails using CSS selectors


mly from caboo.se looks at how to quickly protect certain controller actions from GET requests in Rails, and presents a couple of useful test helpers to make testing for POST vs GET compliance simple. His code lets you then do a simple test like so:
def test_update__with_get assert_method_not_allowed(:update, {:good => :post, :bad => :get}) end
This test ensures that 'update' will only accept a POST request and not a GET.

Click here to add on del.icio.us








