mirror of https://github.com/mastodon/mastodon
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
5 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
2 years ago
|
describe 'Log in' do
|
||
5 years ago
|
include ProfileStories
|
||
8 years ago
|
|
||
2 years ago
|
subject { page }
|
||
|
|
||
2 years ago
|
let(:email) { 'test@example.com' }
|
||
|
let(:password) { 'password' }
|
||
2 years ago
|
let(:confirmed_at) { Time.zone.now }
|
||
8 years ago
|
|
||
2 years ago
|
before do
|
||
5 years ago
|
as_a_registered_user
|
||
8 years ago
|
visit new_user_session_path
|
||
8 years ago
|
end
|
||
8 years ago
|
|
||
2 years ago
|
it 'A valid email and password user is able to log in' do
|
||
5 years ago
|
fill_in 'user_email', with: email
|
||
|
fill_in 'user_password', with: password
|
||
12 months ago
|
click_on I18n.t('auth.login')
|
||
8 years ago
|
|
||
2 years ago
|
expect(subject).to have_css('div.app-holder')
|
||
8 years ago
|
end
|
||
|
|
||
2 years ago
|
it 'A invalid email and password user is not able to log in' do
|
||
5 years ago
|
fill_in 'user_email', with: 'invalid_email'
|
||
|
fill_in 'user_password', with: 'invalid_password'
|
||
12 months ago
|
click_on I18n.t('auth.login')
|
||
8 years ago
|
|
||
2 years ago
|
expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
|
||
8 years ago
|
end
|
||
|
|
||
2 years ago
|
context 'when confirmed at is nil' do
|
||
2 years ago
|
let(:confirmed_at) { nil }
|
||
8 years ago
|
|
||
2 years ago
|
it 'A unconfirmed user is able to log in' do
|
||
5 years ago
|
fill_in 'user_email', with: email
|
||
|
fill_in 'user_password', with: password
|
||
12 months ago
|
click_on I18n.t('auth.login')
|
||
8 years ago
|
|
||
2 years ago
|
expect(subject).to have_css('div.admin-wrapper')
|
||
8 years ago
|
end
|
||
|
end
|
||
8 years ago
|
|
||
8 years ago
|
def failure_message(message)
|
||
|
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
|
||
5 years ago
|
I18n.t("devise.failure.#{message}", authentication_keys: keys.join('support.array.words_connector'))
|
||
8 years ago
|
end
|
||
|
end
|