gearheads
/
mastodon
Archived
2
0
Fork 0
This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
mastodon/spec/features/log_in_spec.rb

52 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
describe 'Log in' do
include ProfileStories
subject { page }
let(:email) { 'test@example.com' }
let(:password) { 'password' }
let(:confirmed_at) { Time.zone.now }
before do
as_a_registered_user
2017-06-01 17:25:59 +02:00
visit new_user_session_path
end
it 'A valid email and password user is able to log in' do
fill_in 'user_email', with: email
fill_in 'user_password', with: password
2017-06-01 17:25:59 +02:00
click_on I18n.t('auth.login')
is_expected.to have_css('div.app-holder')
2017-06-01 17:25:59 +02:00
end
it 'A invalid email and password user is not able to log in' do
fill_in 'user_email', with: 'invalid_email'
fill_in 'user_password', with: 'invalid_password'
2017-06-01 17:25:59 +02:00
click_on I18n.t('auth.login')
is_expected.to have_css('.flash-message', text: failure_message('invalid'))
2017-06-01 17:25:59 +02:00
end
context do
let(:confirmed_at) { nil }
2017-06-01 17:25:59 +02:00
it 'A unconfirmed user is able to log in' do
fill_in 'user_email', with: email
fill_in 'user_password', with: password
2017-06-01 17:25:59 +02:00
click_on I18n.t('auth.login')
is_expected.to have_css('div.admin-wrapper')
2017-06-01 17:25:59 +02:00
end
end
2017-06-01 17:25:59 +02:00
def failure_message(message)
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
I18n.t("devise.failure.#{message}", authentication_keys: keys.join('support.array.words_connector'))
end
end