diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 37398285f..05e22ca89 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -49,10 +49,13 @@ class SessionsController < ApplicationController nil, # @country nil, nil) + + # Users who sign up using oauth are presumed to have valid email adddresses. + user.confirm_email! + auth = user.user_authorizations.build :provider => auth_hash[:provider], :uid => auth_hash[:uid], :token => auth_hash[:credentials][:token], :token_expiration => Time.at(auth_hash[:credentials][:expires_at]) user.save - auth.save complete_sign_in user end end diff --git a/lib/managers/user_manager.rb b/lib/managers/user_manager.rb index a48d4d7c3..052181181 100644 --- a/lib/managers/user_manager.rb +++ b/lib/managers/user_manager.rb @@ -9,7 +9,7 @@ class UserManager < BaseManager end def signup(first_name, last_name, email, password, password_confirmation, - city, state, country, instruments, signup_confirm_url) + city, state, country, instruments, signup_confirm_url) @user = User.new diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb new file mode 100644 index 000000000..7f45aee3b --- /dev/null +++ b/spec/controllers/sessions_controller_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe SessionsController do + render_views + + describe "GET 'new'" do + it "should work" do + get :new + response.should be_success + end + + it "should have the right title" do + get :new + response.body.should have_selector('title', :content => "Jamkazam | Sign in") + end + end + + + describe "POST 'create'" do + before(:each) do + @user = Factory(:user) + @attr = { :email => @user.email, :password => @user.password } + end + + it "should sign the user in" do + post :create, :session => @attr + controller.current_user.should == @user + controller.signed_in?.should == true + end + + + it "should redirect the user to the proper page" do + post :create, :session => @attr + response.should redirect_to(client_url) + end + + + end + + +end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb new file mode 100644 index 000000000..e69de29bb