ACK

----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Tuesday, November 16, 2010 4:30:45 PM GMT +01:00 Amsterdam / Berlin / 
Bern / Rome / Stockholm / Vienna
Subject: [deltacloud-devel] [PATCH aeolus] BZ#649389/BZ#652719 Updated Login 
failed message and removed fields errors on login page

From: Martyn Taylor <[email protected]>

---
 src/app/controllers/user_sessions_controller.rb |    1 +
 src/app/models/user_session.rb                  |    2 +-
 src/app/views/user_sessions/new.haml            |    1 -
 src/features/authentication.feature             |   11 +++++++++--
 src/features/step_definitions/authentication.rb |    4 ++++
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/app/controllers/user_sessions_controller.rb 
b/src/app/controllers/user_sessions_controller.rb
index 14d32ae..3e4e8f0 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: The Username and Password you entered 
do not match"
       render :action => :new
     end
   end
diff --git a/src/app/models/user_session.rb b/src/app/models/user_session.rb
index b9b2224..544ec6b 100644
--- a/src/app/models/user_session.rb
+++ b/src/app/models/user_session.rb
@@ -20,5 +20,5 @@
 # Likewise, all the methods added will be available for all controllers.
 
 class UserSession < Authlogic::Session::Base
-
+  generalize_credentials_error_messages true
 end
diff --git a/src/app/views/user_sessions/new.haml 
b/src/app/views/user_sessions/new.haml
index c3a60f1..9bd71f6 100644
--- a/src/app/views/user_sessions/new.haml
+++ b/src/app/views/user_sessions/new.haml
@@ -2,7 +2,6 @@
   %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
diff --git a/src/features/authentication.feature 
b/src/features/authentication.feature
index 8b94a55..0aa39fd 100644
--- a/src/features/authentication.feature
+++ b/src/features/authentication.feature
@@ -45,7 +45,7 @@ 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 be on the login error page
 
   Scenario: Edit profile
@@ -74,4 +74,11 @@ 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 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
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to