I''ve installed the "acts_as_authenticated" plugin and made
some
modifications to the controller (app/controllers/account_controller.rb)
"signup" module as follows:
== def signup
@page_title = ''Create Account''
@user = User.new(@params[:user])
if request.post?
if @user.save
session[:user] = User.authenticate(@user.login, @user.password)
redirect_to(:controller => ''/home'', :action =>
''welcome'')
else
flash[:notice] = "Signup unsuccessful!"
end
end
end
==
The "success" integration test
(test/integration/authentication_test.rb) looks like this (snipped):
==class AuthenticationTest < ActionController::IntegrationTest
def setup
User.create(:login => "goober",
:email =>
"goober-I/zrSzmPSO5BDgjK7y7TUQ@public.gmane.org",
:password => "gomer",
:password_confirmation => "gomer")
end
...
def test_successful_signup
gooddog = enter_site(:gooddog)
gooddog.signs_up_successfully
end
...
private
module BrowsingTestDSL
include ERB::Util
attr_writer :name
...
def signs_up_successfully
post_signup("gooddog",
"gooddog-plI9Zfxs2xb6V6G2DxALlg@public.gmane.org",
"gooddog",
"gooddog")
assert_redirected_to :controller => "home", :action =>
"welcome"
end
...
private
def post_signup(login, email, password, confirm_password)
post "/account/signup", :login => login, :email => email,
:password => password, :confirm_password => confirm_password
end
end
def enter_site(name)
open_session do |session|
session.extend(BrowsingTestDSL)
session.name = name
yield session if block_given?
end
end
end
==
I''m on Windows and am running the test using this command:
> ruby test/integration/authentication_test.rb - n test_successful_signup
Resulting in:
"Expected response to be a <:redirect>, but was <200>"
Running live produces the desired behavior, i.e., a new user is
created, data stored in the database, and the user is redirected to a
Welcome page.
Is there something(s) about the test environment that I''ve missed?
Thanks,
Stan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---