Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. ERROR["test_password_resets", PasswordResetsTest, 2016-10-20 15:24:37 +0000]
  2. test_password_resets#PasswordResetsTest (1476977077.03s)
  3. NoMethodError: NoMethodError: undefined method `[]' for nil:NilClass
  4. app/controllers/password_resets_controller.rb:10:in `create'
  5. test/integration/password_resets_test.rb:14:in `block in <class:PasswordResetsTest>'
  6. app/controllers/password_resets_controller.rb:10:in `create'
  7. test/integration/password_resets_test.rb:14:in `block in <class:PasswordResetsTest>'
  8.  
  9. ERROR["test_invalid_signup_information", UsersSignupTest, 2016-10-20 15:24:37 +0000]
  10. test_invalid_signup_information#UsersSignupTest (1476977077.04s)
  11. ActionController::ParameterMissing: ActionController::ParameterMissing: param is missing or the value is empty: user
  12. app/controllers/users_controller.rb:52:in `user_params'
  13. app/controllers/users_controller.rb:25:in `create'
  14. test/integration/user_signup_test.rb:12:in `block (2 levels) in <class:UsersSignupTest>'
  15. test/integration/user_signup_test.rb:11:in `block in <class:UsersSignupTest>'
  16. app/controllers/users_controller.rb:52:in `user_params'
  17. app/controllers/users_controller.rb:25:in `create'
  18. test/integration/user_signup_test.rb:12:in `block (2 levels) in <class:UsersSignupTest>'
  19. test/integration/user_signup_test.rb:11:in `block in <class:UsersSignupTest>'
  20.  
  21. ERROR["test_valid_signup_information_with_account_activation", UsersSignupTest, 2016-10-20 15:24:37 +0000]
  22. test_valid_signup_information_with_account_activation#UsersSignupTest (1476977077.05s)
  23. ActionController::ParameterMissing: ActionController::ParameterMissing: param is missing or the value is empty: user
  24. app/controllers/users_controller.rb:52:in `user_params'
  25. app/controllers/users_controller.rb:25:in `create'
  26. test/integration/user_signup_test.rb:25:in `block (2 levels) in <class:UsersSignupTest>'
  27. test/integration/user_signup_test.rb:24:in `block in <class:UsersSignupTest>'
  28. app/controllers/users_controller.rb:52:in `user_params'
  29. app/controllers/users_controller.rb:25:in `create'
  30. test/integration/user_signup_test.rb:25:in `block (2 levels) in <class:UsersSignupTest>'
  31. test/integration/user_signup_test.rb:24:in `block in <class:UsersSignupTest>'
  32.  
  33. FAIL["test_should_get_edit", PasswordResetsControllerTest, 2016-10-20 15:24:37 +0000]
  34. test_should_get_edit#PasswordResetsControllerTest (1476977077.05s)
  35. Expected response to be a <success>, but was <302>
  36. test/controllers/password_resets_controller_test.rb:11:in `block in <class:PasswordResetsControllerTest>'
  37.  
  38. class UsersController < ApplicationController
  39. before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
  40. before_action :correct_user, only: [:edit, :update]
  41. before_action :admin_user, only: :destroy
  42.  
  43. def destroy
  44. User.find(params[:id]).destroy
  45. flash[:success] = "User deleted"
  46. redirect_to users_url
  47. end
  48.  
  49. def index
  50. @users = User.paginate(page: params[:page])
  51. end
  52.  
  53. def show
  54. @user = User.find(params[:id])
  55. end
  56.  
  57. def new
  58. @user = User.new
  59. end
  60.  
  61. def create
  62. @user = User.new(user_params)
  63. if @user.save
  64. @user.send_activation_email
  65. flash[:info] = "Please check your email to activate your account."
  66. redirect_to root_url
  67. else
  68. render 'new'
  69. end
  70. end
  71.  
  72. def edit
  73. @user = User.find(params[:id])
  74. end
  75.  
  76. def update
  77. @user = User.find(params[:id])
  78. if @user.update_attributes(user_params)
  79. flash[:success] = "Profile updated"
  80. redirect_to @user
  81. else
  82. render 'edit'
  83. end
  84. end
  85.  
  86. private
  87.  
  88. def user_params
  89. params.require(:user).permit(:name, :email, :password,
  90. :password_confirmation)
  91. end
  92.  
  93. # Before filters
  94.  
  95. # Confirms a logged-in user.
  96. def logged_in_user
  97. unless logged_in?
  98. store_location
  99. flash[:danger] = "Please log in."
  100. redirect_to login_url
  101. end
  102. end
  103.  
  104. # Confirms the correct user.
  105. def correct_user
  106. @user = User.find(params[:id])
  107. redirect_to(root_url) unless current_user?(@user)
  108. end
  109.  
  110.  
  111.  
  112. # Confirms an admin user.
  113. def admin_user
  114. redirect_to(root_url) unless current_user.admin?
  115. end
  116. end
  117.  
  118. require 'test_helper'
  119.  
  120. class UsersSignupTest < ActionDispatch::IntegrationTest
  121.  
  122. def setup
  123. ActionMailer::Base.deliveries.clear
  124. end
  125.  
  126. test "invalid signup information" do
  127. get signup_path
  128. assert_no_difference 'User.count' do
  129. post users_path, params: { user: { name: "",
  130. email: "user@invalid",
  131. password: "foo",
  132. password_confirmation: "bar" } }
  133. end
  134. assert_template 'users/new'
  135. assert_select 'div#error_explanation'
  136. assert_select 'div.field_with_errors'
  137. end
  138.  
  139. test "valid signup information with account activation" do
  140. get signup_path
  141. assert_difference 'User.count', 1 do
  142. post users_path, params: { user: { name: "Example User",
  143. email: "user@example.com",
  144. password: "password",
  145. password_confirmation: "password" } }
  146. end
  147. assert_equal 1, ActionMailer::Base.deliveries.size
  148. user = assigns(:user)
  149. assert_not user.activated?
  150. # Try to log in before activation.
  151. log_in_as(user)
  152. assert_not is_logged_in?
  153. # Invalid activation token
  154. get edit_account_activation_path("invalid token", email: user.email)
  155. assert_not is_logged_in?
  156. # Valid token, wrong email
  157. get edit_account_activation_path(user.activation_token, email: 'wrong')
  158. assert_not is_logged_in?
  159. # Valid activation token
  160. get edit_account_activation_path(user.activation_token, email: user.email)
  161. assert user.reload.activated?
  162. follow_redirect!
  163. assert_template 'users/show'
  164. assert is_logged_in?
  165. end
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement