The code powering m.abunchtell.com https://m.abunchtell.com
You can not 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.3 KiB

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