From d410d2ee761e0d9c1d940142c9ff59425acc5b25 Mon Sep 17 00:00:00 2001 From: theworldbright Date: Mon, 29 Jun 2015 18:32:10 +0900 Subject: [PATCH] Fix bug where flash error reappeared #6136 closes #6146 closes #6136 --- Changelog.md | 1 + app/controllers/registrations_controller.rb | 2 +- features/desktop/signs_up.feature | 9 +++++++++ features/step_definitions/custom_web_steps.rb | 4 ++++ features/step_definitions/user_steps.rb | 6 +++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 12cdc2a04..d01623e49 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ * Precompile facebox images [#6105](https://github.com/diaspora/diaspora/pull/6105) * Fix wrong closing a-tag [#6111](https://github.com/diaspora/diaspora/pull/6111) * Fix mobile more-button wording when there are less than 15 posts [#6118](https://github.com/diaspora/diaspora/pull/6118) +* Fix reappearing flash boxes during sign-in [#6146](https://github.com/diaspora/diaspora/pull/6146) ## Features * Add configuration options for some debug logs [#6090](https://github.com/diaspora/diaspora/pull/6090) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 611b1cf94..4697592fb 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -20,7 +20,7 @@ class RegistrationsController < Devise::RegistrationsController else @user.errors.delete(:person) - flash[:error] = @user.errors.full_messages.join(" - ") + flash.now[:error] = @user.errors.full_messages.join(" - ") logger.info "event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'" render :action => 'new', :layout => 'with_header' end diff --git a/features/desktop/signs_up.feature b/features/desktop/signs_up.feature index 46ee98c3f..0f955a19c 100644 --- a/features/desktop/signs_up.feature +++ b/features/desktop/signs_up.feature @@ -88,3 +88,12 @@ Feature: new user registration And I press "Sign up" Then I should not be able to sign up And I should have a validation error on "user_password, user_password_confirmation" + + Scenario: User signs up with an already existing username and email and then tries to sign in (Issue #6136) + When I log out manually + And I go to the new user registration page + And I fill in the new user form with an existing email and username + And I submit the form + Then I should see a flash message indicating failure + When I click the sign in button + Then I should not see a flash message indicating failure diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 0009f8b56..19c284888 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -255,6 +255,10 @@ Then /^I should see a flash message indicating failure$/ do flash_message_failure?.should be true end +Then /^I should not see a flash message indicating failure$/ do + expect { flash_message_failure?.should }.to raise_error(Capybara::ElementNotFound) +end + Then /^I should see a flash message with a warning$/ do flash_message_alert?.should be true end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 5c9c55164..b23e37597 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -206,7 +206,7 @@ Given /^I visit alice's invitation code url$/ do visit invite_code_path(invite_code) end -When /^I fill in the new user form$/ do +When /^I fill in the new user form/ do fill_in_new_user_form end @@ -215,3 +215,7 @@ And /^I should be able to friend Alice$/ do step 'I should see "Add contact"' step "I should see \"#{alice.name}\"" end + +When /^I click the sign in button$/ do + click_link "Sign in" +end