Guest User

Untitled

a guest
May 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. test "should not sign up more than 5 users" do
  2. get "signup"
  3. assert_response :success
  4. assert_difference('User.count',5) do
  5. for i in 0..10 do
  6. puts "Signup user"
  7. post_via_redirect "/signup",
  8. :first_name => "Petter",
  9. :last_name => "Smart",
  10. :email => "petter.smart<%=i%>@prayalot.com",
  11. :password => '123456',
  12. :password_confirmation => '123456'
  13. assert_equal '/sentmail', path
  14. end
  15. end
  16. end
  17.  
  18. post_via_redirect "/signup",
  19.  
  20. :email => "petter.smart<%=i%>@prayalot.com",
  21.  
  22. assert_equal '/sentmail', path
  23.  
  24. test "should not sign up more than 10 users from same IP" do
  25. get "signup"
  26. assert_response :success
  27. assert_difference('User.count',10) do
  28. for i in 1..10 do
  29. post "users", :user => {
  30. :first_name => "Petter",
  31. :last_name => "Smart",
  32. :email => "petter.smart#{i}@prayalot.com",
  33. :password => '123456',
  34. :password_confirmation => '123456'}
  35. assert_redirected_to sentmail_path
  36. end
  37.  
  38. for i in 11..20 do
  39. post "users", :user => {
  40. :first_name => "Petter",
  41. :last_name => "Smart",
  42. :email => "petter.smart#{i}@prayalot.com",
  43. :password => '123456',
  44. :password_confirmation => '123456'}
  45. assert_redirected_to error_path
  46. end
  47. end
  48. end
Add Comment
Please, Sign In to add comment