diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 7d25a2da36c..bd607088aa3 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -40,38 +40,21 @@ describe UsersController do end describe '.authorize_email' do - context 'invalid token' do - before do - EmailToken.expects(:confirm).with('asdfasdf').returns(nil) - get :authorize_email, token: 'asdfasdf' - end - - it 'return success' do - response.should be_success - end - - it 'sets a flash error' do - flash[:error].should be_present - end + it 'errors out for invalid tokens' do + get :authorize_email, token: 'asdfasdf' + response.should be_success + flash[:error].should be_present end context 'valid token' do - let(:user) { Fabricate(:user) } - before do - EmailToken.expects(:confirm).with('asdfasdf').returns(user) - get :authorize_email, token: 'asdfasdf' - end + it 'authorizes with a correct token' do + user = Fabricate(:user) + email_token = user.email_tokens.create(email: user.email) - it 'returns success' do + get :authorize_email, token: email_token.token response.should be_success - end - - it "doesn't set an error" do flash[:error].should be_blank - end - - it 'logs in as the user' do session[:current_user_id].should be_present end end