Guest User

Untitled

a guest
Jun 23rd, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. ## Authentication Test
  2. require 'test_helper'
  3.  
  4. class AuthenticationTest < ActionController::IntegrationTest
  5. test "valid registration" do
  6. visit register_path
  7. fill_in "user[username]", :with => "Foobar"
  8. fill_in "user[email]", :with => "foo@example.com"
  9. fill_in "user[password]", :with => "password"
  10. fill_in "user[password_confirmation]", :with => "password"
  11. click_button "Sign Up"
  12.  
  13. assert_contain "Thank you for registering, and welcome to Project"
  14. end
  15.  
  16. test "invalid registration" do
  17. visit register_path
  18. click_button "Sign Up"
  19.  
  20. assert_contain "errors prohibited this user from being saved"
  21. end
  22.  
  23. test "valid login" do
  24. user = Factory(:user, :username => "Foobar", :email => "foo@example.com", :password => "password")
  25.  
  26. visit login_path
  27. fill_in "user_session[username]", :with => "Foobar"
  28. fill_in "Password", :with => "password"
  29. click_button "Login"
  30.  
  31. assert_contain "Welcome back Foobar."
  32. end
  33.  
  34. test "invalid login" do
  35. Factory(:user, :username => "Foobar", :email => "foo@example.com", :password => "password")
  36.  
  37. visit login_path
  38. fill_in "user_session[username]", :with => "Foobar"
  39. fill_in "Password", :with => "wrong_password"
  40. click_button "Login"
  41.  
  42. assert_contain "Wrong username and/or password."
  43. end
  44.  
  45. test "Logout login" do
  46. Factory(:user, :username => "Foobar", :email => "foo@example.com", :password => "password")
  47.  
  48. visit login_path
  49. fill_in "user_session[username]", :with => "Foobar"
  50. fill_in "Password", :with => "password"
  51. click_button "Login"
  52. click_link "Logout"
  53.  
  54. assert_contain "See you later."
  55. end
  56.  
  57. test "Forgot password (pre-reset)" do
  58. user = Factory(:user, :email => "foobar@example.com")
  59.  
  60. visit login_path
  61. click_link "Forgot Password?"
  62. fill_in "email", :with => "foobar@example.com"
  63. click_button "Reset my password"
  64.  
  65. assert_contain "Instructions to reset your password have been emailed to you. Please check your email."
  66. end
  67.  
  68. test "Reset password" do
  69. user = Factory(:user, :perishable_token => "vpPsEI1X-3eVD_1Z2hlZ")
  70.  
  71. visit edit_password_reset_path(user.perishable_token)
  72. fill_in "user[password]", :with => "password"
  73. fill_in "user[password_confirmation]", :with => "password"
  74. click_button "Update my password and log me in"
  75.  
  76. assert_contain "Password successfully updated"
  77. end
  78. end
  79.  
  80.  
  81.  
  82.  
  83. ## Error
  84. $ rake test:integration
  85. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"lib:test" "/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/integration/authentication_test.rb" "test/integration/bibliography_test.rb"
  86. /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::IntegrationTests (NameError)
  87. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
  88. from ./test/integration/bibliography_test.rb:3
  89. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:147:in `load_without_new_constant_marking'
  90. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:147:in `load'
  91. from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
  92. from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
  93. from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
  94. rake aborted!
Add Comment
Please, Sign In to add comment