HEre is my code for my integration test:
require 'test_helper'
class UserSignupTest < ActionDispatch::IntegrationTest
test "a user can signup and return back to root url" do
visit new_user_path
fill_in "user[username]", with: "flyers1"
fill_in "user[first_name]", with: "user"
fill_in "user[last_name]", with: "name"
fill_in "user[email]", with: "username@gmail.com"
fill_in "user[street]", with: "street"
fill_in "user[city]", with: "city"
fill_in "user[state]", with: "state"
fill_in "user[country]", with: "country"
fill_in "user[password]", with: "password"
fill_in "user[password_confirmation]", with: "password"
click_button "Finish Signup"
refute flash.empty?
end
Here is my controller method for create:
def create
user = User.new(user_params)
if user.valid?
valid_user_signup(user)
else
invalid_user_signup(user)
end
end
and
def valid_user_signup(user)
user.save
session[:user_id] = user.id
flash[:success] = "Signup Successful"
redirect_to root_path
end
What is going on here? Why do I get an error message that says "undefined method flash" for nil:nilclass?
Aucun commentaire:
Enregistrer un commentaire