Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ERROR["test_password_resets", PasswordResetsTest, 2016-10-20 15:24:37 +0000]
- test_password_resets#PasswordResetsTest (1476977077.03s)
- NoMethodError: NoMethodError: undefined method `[]' for nil:NilClass
- app/controllers/password_resets_controller.rb:10:in `create'
- test/integration/password_resets_test.rb:14:in `block in <class:PasswordResetsTest>'
- app/controllers/password_resets_controller.rb:10:in `create'
- test/integration/password_resets_test.rb:14:in `block in <class:PasswordResetsTest>'
- ERROR["test_invalid_signup_information", UsersSignupTest, 2016-10-20 15:24:37 +0000]
- test_invalid_signup_information#UsersSignupTest (1476977077.04s)
- ActionController::ParameterMissing: ActionController::ParameterMissing: param is missing or the value is empty: user
- app/controllers/users_controller.rb:52:in `user_params'
- app/controllers/users_controller.rb:25:in `create'
- test/integration/user_signup_test.rb:12:in `block (2 levels) in <class:UsersSignupTest>'
- test/integration/user_signup_test.rb:11:in `block in <class:UsersSignupTest>'
- app/controllers/users_controller.rb:52:in `user_params'
- app/controllers/users_controller.rb:25:in `create'
- test/integration/user_signup_test.rb:12:in `block (2 levels) in <class:UsersSignupTest>'
- test/integration/user_signup_test.rb:11:in `block in <class:UsersSignupTest>'
- ERROR["test_valid_signup_information_with_account_activation", UsersSignupTest, 2016-10-20 15:24:37 +0000]
- test_valid_signup_information_with_account_activation#UsersSignupTest (1476977077.05s)
- ActionController::ParameterMissing: ActionController::ParameterMissing: param is missing or the value is empty: user
- app/controllers/users_controller.rb:52:in `user_params'
- app/controllers/users_controller.rb:25:in `create'
- test/integration/user_signup_test.rb:25:in `block (2 levels) in <class:UsersSignupTest>'
- test/integration/user_signup_test.rb:24:in `block in <class:UsersSignupTest>'
- app/controllers/users_controller.rb:52:in `user_params'
- app/controllers/users_controller.rb:25:in `create'
- test/integration/user_signup_test.rb:25:in `block (2 levels) in <class:UsersSignupTest>'
- test/integration/user_signup_test.rb:24:in `block in <class:UsersSignupTest>'
- FAIL["test_should_get_edit", PasswordResetsControllerTest, 2016-10-20 15:24:37 +0000]
- test_should_get_edit#PasswordResetsControllerTest (1476977077.05s)
- Expected response to be a <success>, but was <302>
- test/controllers/password_resets_controller_test.rb:11:in `block in <class:PasswordResetsControllerTest>'
- class UsersController < ApplicationController
- before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
- before_action :correct_user, only: [:edit, :update]
- before_action :admin_user, only: :destroy
- def destroy
- User.find(params[:id]).destroy
- flash[:success] = "User deleted"
- redirect_to users_url
- end
- def index
- @users = User.paginate(page: params[:page])
- end
- def show
- @user = User.find(params[:id])
- end
- def new
- @user = User.new
- end
- def create
- @user = User.new(user_params)
- if @user.save
- @user.send_activation_email
- flash[:info] = "Please check your email to activate your account."
- redirect_to root_url
- else
- render 'new'
- end
- end
- def edit
- @user = User.find(params[:id])
- end
- def update
- @user = User.find(params[:id])
- if @user.update_attributes(user_params)
- flash[:success] = "Profile updated"
- redirect_to @user
- else
- render 'edit'
- end
- end
- private
- def user_params
- params.require(:user).permit(:name, :email, :password,
- :password_confirmation)
- end
- # Before filters
- # Confirms a logged-in user.
- def logged_in_user
- unless logged_in?
- store_location
- flash[:danger] = "Please log in."
- redirect_to login_url
- end
- end
- # Confirms the correct user.
- def correct_user
- @user = User.find(params[:id])
- redirect_to(root_url) unless current_user?(@user)
- end
- # Confirms an admin user.
- def admin_user
- redirect_to(root_url) unless current_user.admin?
- end
- end
- require 'test_helper'
- class UsersSignupTest < ActionDispatch::IntegrationTest
- def setup
- ActionMailer::Base.deliveries.clear
- end
- test "invalid signup information" do
- get signup_path
- assert_no_difference 'User.count' do
- post users_path, params: { user: { name: "",
- email: "user@invalid",
- password: "foo",
- password_confirmation: "bar" } }
- end
- assert_template 'users/new'
- assert_select 'div#error_explanation'
- assert_select 'div.field_with_errors'
- end
- test "valid signup information with account activation" do
- get signup_path
- assert_difference 'User.count', 1 do
- post users_path, params: { user: { name: "Example User",
- email: "user@example.com",
- password: "password",
- password_confirmation: "password" } }
- end
- assert_equal 1, ActionMailer::Base.deliveries.size
- user = assigns(:user)
- assert_not user.activated?
- # Try to log in before activation.
- log_in_as(user)
- assert_not is_logged_in?
- # Invalid activation token
- get edit_account_activation_path("invalid token", email: user.email)
- assert_not is_logged_in?
- # Valid token, wrong email
- get edit_account_activation_path(user.activation_token, email: 'wrong')
- assert_not is_logged_in?
- # Valid activation token
- get edit_account_activation_path(user.activation_token, email: user.email)
- assert user.reload.activated?
- follow_redirect!
- assert_template 'users/show'
- assert is_logged_in?
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement