Skip to content

Instantly share code, notes, and snippets.

@plukevdh
Created November 5, 2009 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plukevdh/227106 to your computer and use it in GitHub Desktop.
Save plukevdh/227106 to your computer and use it in GitHub Desktop.
Quick unit test customer safety. This way I'm not overwriting data by accident.
def setup
@cus_save = Customer.find("####")
login
end
def teardown
cus = Customer.find "####"
cus.attributes = @cus_save.attributes
assert cus.save!
end
def login
post_via_redirect "authenticate/login", :username => @cus_save[:cus_login], :password => @cus_save[:cus_password]
assert_equal "/", path
assert_equal @cus_save.id, session[:id]
get_via_redirect "customer/update_info"
assert_equal "/customer/update_info", path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment