logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

log_in_spec.rb (1411B)


  1. require "rails_helper"
  2. feature "Log in" do
  3. given(:email) { "test@examle.com" }
  4. given(:password) { "password" }
  5. given(:confirmed_at) { Time.now }
  6. background do
  7. Fabricate(:user, email: email, password: password, confirmed_at: confirmed_at)
  8. visit new_user_session_path
  9. end
  10. subject { page }
  11. scenario "A valid email and password user is able to log in" do
  12. fill_in "user_email", with: email
  13. fill_in "user_password", with: password
  14. click_on I18n.t('auth.login')
  15. is_expected.to have_css("div.app-holder")
  16. end
  17. scenario "A invalid email and password user is not able to log in" do
  18. fill_in "user_email", with: "invalid_email"
  19. fill_in "user_password", with: "invalid_password"
  20. click_on I18n.t('auth.login')
  21. is_expected.to have_css(".flash-message", text: failure_message("invalid"))
  22. end
  23. context do
  24. given(:confirmed_at) { nil }
  25. scenario "A unconfirmed user is not able to log in" do
  26. fill_in "user_email", with: email
  27. fill_in "user_password", with: password
  28. click_on I18n.t('auth.login')
  29. is_expected.to have_css(".flash-message", text: failure_message("unconfirmed"))
  30. end
  31. end
  32. def failure_message(message)
  33. keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
  34. I18n.t("devise.failure.#{message}", authentication_keys: keys.join("support.array.words_connector"))
  35. end
  36. end