scube-server/spec/models/user_spec.rb
Thibault Jouan 7bf4d4c5f9 Add authentication and User model
* Add User model
* Add SessionsController
* Add password authentication on User
* Request authentication for all actions except sign in
* Add some helpers for ApplicationController
* Update features to work with mandatory authentication
2011-08-06 23:04:36 +00:00

45 lines
783 B
Ruby

require 'spec_helper'
describe User do
subject { user }
let(:user) { Factory.build(:user) }
context 'with valid attributes' do
it { should be_valid }
end
context 'when email empty' do
before do
user.email = ''
end
it { should_not be_valid }
end
context 'when password empty' do
before do
user.password = ''
end
it { should_not be_valid }
end
describe '.authenticate' do
let (:user) { Factory.create(:user) }
it 'returns the user with valid credentials' do
User.authenticate(
user.email,
user.password
).should == user
end
it 'returns false with invalid credentials' do
User.authenticate(
user.email,
'WRONG'
).should be_false
end
end
end