1 require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
2 require File.join( File.dirname(__FILE__), "..", "user_spec_helper")
3 require File.join( File.dirname(__FILE__), "..", "authenticated_system_spec_helper")
10 User.clear_database_table
15 controller = create_user
16 controller.should redirect
17 end.should change(User, :count).by(1)
20 it 'requires login on signup' do
22 controller = create_user(:login => nil)
23 controller.assigns(:user).errors.on(:login).should_not be_nil
24 controller.should respond_successfully
25 end.should_not change(User, :count)
28 it 'requires password on signup' do
30 controller = create_user(:password => nil)
31 controller.assigns(:user).errors.on(:password).should_not be_nil
32 controller.should respond_successfully
33 end.should_not change(User, :count)
36 it 'requires password confirmation on signup' do
38 controller = create_user(:password_confirmation => nil)
39 controller.assigns(:user).errors.on(:password_confirmation).should_not be_nil
40 controller.should respond_successfully
41 end.should_not change(User, :count)
44 it 'requires email on signup' do
46 controller = create_user(:email => nil)
47 controller.assigns(:user).errors.on(:email).should_not be_nil
48 controller.should respond_successfully
49 end.should_not change(User, :count)
52 it "should have a route for user activation" do
53 request_to("/users/activate/1234") do |params|
54 params[:controller].should == "Users"
55 params[:action].should == "activate"
56 params[:activation_code].should == "1234"
60 it 'activates user' do
61 controller = create_user(:login => "aaron", :password => "test", :password_confirmation => "test")
62 @user = controller.assigns(:user)
63 User.authenticate('aaron', 'test').should be_nil
64 controller = get "/users/activate/1234"
65 controller.should redirect_to("/")
68 def create_user(options = {})
69 post "/users", :user => valid_user_hash.merge(options)