search for: sessionscontrollertest

Displaying 1 result from an estimated 1 matches for "sessionscontrollertest".

2012 Mar 14
0
How do I create a new object in testing to test a controller?
...to the extreme: def create @user = User.find_by_email(params[:email]) if @user flash.now[:notice] = "ok, it exists" else flash.now[:notice] = "it does not exist" end render :new end This is my functional test: require ''test_helper'' class SessionsControllerTest < ActionController::TestCase test "object creation" do user = User.create!(email: "user-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org", password: "secret") assert user.valid? # make sure User.new is correct assert user.persisted? # make sure it''s p...