From: Martyn Taylor <[email protected]>
---
src/app/controllers/user_sessions_controller.rb | 1 +
src/app/views/user_sessions/new.haml | 3 ++-
src/features/authentication.feature | 13 +++++++++++--
src/features/step_definitions/authentication.rb | 4 ++++
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/app/controllers/user_sessions_controller.rb
b/src/app/controllers/user_sessions_controller.rb
index 14d32ae..5f3ed02 100644
--- a/src/app/controllers/user_sessions_controller.rb
+++ b/src/app/controllers/user_sessions_controller.rb
@@ -37,6 +37,7 @@ class UserSessionsController < ApplicationController
flash[:notice] = "Login successful!"
redirect_back_or_default root_url
else
+ flash[:warning] = "Login failed"
render :action => :new
end
end
diff --git a/src/app/views/user_sessions/new.haml
b/src/app/views/user_sessions/new.haml
index c3a60f1..ffbd2c3 100644
--- a/src/app/views/user_sessions/new.haml
+++ b/src/app/views/user_sessions/new.haml
@@ -2,13 +2,14 @@
%h2 Log In
.dcloud_form
- form_for @user_session, :url => user_session_path do |f|
- = f.error_messages
%fieldset
= f.label :login, "Username:"
= f.text_field :login
+ = f.error_message_on :login, "Username "
%fieldset
= f.label :password
= f.password_field :password
+ = f.error_message_on :password, "Password "
%div.indented
= f.check_box :remember_me
= f.label :remember_me
diff --git a/src/features/authentication.feature
b/src/features/authentication.feature
index 8b94a55..ee760ac 100644
--- a/src/features/authentication.feature
+++ b/src/features/authentication.feature
@@ -45,7 +45,8 @@ Feature: User authentication
Given I am a registered user
And I am on the login page
When I forget to enter my password
- Then I should see "Password cannot be blank"
+ Then I should see "Login failed"
+ And I should see "Password cannot be blank"
And I should be on the login error page
Scenario: Edit profile
@@ -74,4 +75,12 @@ Feature: User authentication
Then should see "Editing Account"
When I enter a string of length "101" into "user[login]"
And I press "Save"
- Then I should see "Login is too long (maximum is 100 characters)"
\ No newline at end of file
+ Then I should see "Login is too long (maximum is 100 characters)"
+
+ Scenario: Log in incorrect details
+ Given I am a registered user
+ And I am on the login page
+ When I login with incorrect credentials
+ Then I should see "Login failed"
+ And I should see "Username is not valid"
+ And I should be on the login error page
\ No newline at end of file
diff --git a/src/features/step_definitions/authentication.rb
b/src/features/step_definitions/authentication.rb
index 13bc9a6..e7a84bd 100644
--- a/src/features/step_definitions/authentication.rb
+++ b/src/features/step_definitions/authentication.rb
@@ -53,4 +53,8 @@ When /^I enter a string of length "([^"]*)" into "([^"]*)"$/
do |length, field_n
string = ""
length.to_i.times { string << valid_chars[rand(valid_chars.length)] }
When "I fill in \"#{field_name}\" with \"#{string}\""
+end
+
+When /^I login with incorrect credentials$/ do
+ login("wrong_username", "wrong_password")
end
\ No newline at end of file
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel