allow to login with email instead of nick as well + tests
This commit is contained in:
parent
fa99a0a852
commit
a77c3b59b1
5 changed files with 32 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ describe 'the session', :type => :feature do
|
|||
let(:user) { create :user }
|
||||
|
||||
describe 'login page', :type => :feature do
|
||||
it 'is accesible' do
|
||||
it 'is accessible' do
|
||||
get login_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
|
@ -16,6 +16,13 @@ describe 'the session', :type => :feature do
|
|||
login user.nick, 'XX'+user.password
|
||||
expect(page).to have_selector('.alert-error')
|
||||
end
|
||||
it 'can log me in using an email address' do
|
||||
visit login_path
|
||||
fill_in 'nick', :with => user.email
|
||||
fill_in 'password', :with => user.password
|
||||
find('input[type=submit]').click
|
||||
expect(page).to_not have_selector('.alert-error')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,6 +49,16 @@ describe User do
|
|||
it 'has a unique email' do
|
||||
expect(build(:user, email: "#{user.email}")).to be_invalid
|
||||
end
|
||||
|
||||
it 'can authenticate using email address' do
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_true
|
||||
end
|
||||
|
||||
it 'can authenticate when there is no nick' do
|
||||
user.nick = nil
|
||||
expect(user).to be_valid
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue