1
0
Fork 0
forked from fedi/mastodon
mastodon/spec/features/log_in_spec.rb
Eugen Rochko 964ae8eee5
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.

Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.

After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.

Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00

48 lines
1.3 KiB
Ruby

require "rails_helper"
feature "Log in" do
given(:email) { "test@examle.com" }
given(:password) { "password" }
given(:confirmed_at) { Time.zone.now }
background do
Fabricate(:user, email: email, password: password, confirmed_at: confirmed_at)
visit new_user_session_path
end
subject { page }
scenario "A valid email and password user is able to log in" do
fill_in "user_email", with: email
fill_in "user_password", with: password
click_on I18n.t('auth.login')
is_expected.to have_css("div.app-holder")
end
scenario "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"
click_on I18n.t('auth.login')
is_expected.to have_css(".flash-message", text: failure_message("invalid"))
end
context do
given(:confirmed_at) { nil }
scenario "A unconfirmed user is able to log in" do
fill_in "user_email", with: email
fill_in "user_password", with: password
click_on I18n.t('auth.login')
is_expected.to have_css("div.admin-wrapper")
end
end
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