summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-06-02 00:25:59 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-01 17:25:59 +0200
commit509b0cfafc0857538d63f4b93b26462f035d458b (patch)
treed1f9a889e45de810070684831ff9775846371e70
parentfda5c699c2d1165381da87ffe12ebc92e6529f47 (diff)
Add scenarios for log in (#3497)
-rw-r--r--spec/features/log_in_spec.rb40
1 files changed, 34 insertions, 6 deletions
diff --git a/spec/features/log_in_spec.rb b/spec/features/log_in_spec.rb
index 6dc3cd2f4ea..ed626d880eb 100644
--- a/spec/features/log_in_spec.rb
+++ b/spec/features/log_in_spec.rb
@@ -1,19 +1,47 @@
require "rails_helper"
feature "Log in" do
- given(:email) { "test@examle.com" }
- given(:password) { "password" }
+ given(:email) { "test@examle.com" }
+ given(:password) { "password" }
+ given(:confirmed_at) { Time.now }
background do
- Fabricate(:user, email: email, password: password)
+ 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
- visit new_user_session_path
fill_in "user_email", with: email
fill_in "user_password", with: password
- click_on "Log in"
+ 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 not 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(".flash-message", text: failure_message("unconfirmed"))
+ end
+ end
- expect(page).to have_css "div.app-holder"
+ 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