diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index ad603e1..6cac48c 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -69,6 +69,8 @@ class AccountController < ApplicationController session[:notice] = _("This environment doesn't allow user registration.") end + store_location(request.referer) unless params[:return_to] or session[:return_to] + @block_bot = !!session[:may_be_a_bot] @invitation_code = params[:invitation_code] begin @@ -98,7 +100,7 @@ class AccountController < ApplicationController end if @user.activated? self.current_user = @user - redirect_to '/' + go_to_signup_initial_page else @register_pending = true end @@ -369,6 +371,7 @@ class AccountController < ApplicationController def go_to_initial_page if params[:return_to] + #I never get here redirect_to params[:return_to] elsif environment.enabled?('allow_change_of_redirection_after_login') case user.preferred_login_redirection @@ -394,6 +397,23 @@ class AccountController < ApplicationController end end + def go_to_signup_initial_page + case @user.environment.redirection_after_signup + when 'keep_on_same_page' + redirect_back_or_default(user.admin_url) + when 'site_homepage' + redirect_to :controller => :home + when 'user_profile_page' + redirect_to user.public_profile_url + when 'user_homepage' + redirect_to user.url + when 'user_control_panel' + redirect_to user.admin_url + else + redirect_to user.url + end + end + def redirect_if_logged_in if logged_in? go_to_initial_page diff --git a/features/signup.feature b/features/signup.feature index 6cd6ff5..df60d9c 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -3,7 +3,7 @@ Feature: signup I want to sign up to the site So I can have fun using its features -@selenium + @selenium Scenario: successfull registration Given I am on the homepage When I follow "Login" @@ -60,3 +60,84 @@ Feature: signup And I fill in "Name" with "" When I press "Save" Then I should see "Name can't be blank" + + @selenium + Scenario: user should stay on same page after signup + Given the environment is configured to stay on the same page after signup + And feature "skip_new_user_email_confirmation" is enabled on environment + And I am on /search/people + When I follow "Sign up" + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + And wait for the captcha signup time + And I press "Create my account" + Then I should be on /search/people + + @selenium + Scenario: user should go to his homepage after signup + Given the environment is configured to redirect to profile homepage after signup + And feature "skip_new_user_email_confirmation" is enabled on environment + And I am on /search/people + When I follow "Sign up" + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + And wait for the captcha signup time + And I press "Create my account" + Then I should be on josesilva's profile + + @selenium + Scenario: user should go to his control panel after signup + Given the environment is configured to redirect to profile control panel after signup + And feature "skip_new_user_email_confirmation" is enabled on environment + And I am on /search/people + When I follow "Sign up" + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + And wait for the captcha signup time + And I press "Create my account" + Then I should be on josesilva's control panel + + @selenium + Scenario: user should go to his profile page after signup + Given the environment is configured to redirect to profile page after signup + And feature "skip_new_user_email_confirmation" is enabled on environment + And I am on /search/people + When I follow "Sign up" + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + And wait for the captcha signup time + And I press "Create my account" + Then I should be on josesilva's profile + + @selenium + Scenario: user should go to the environment's homepage after signup + Given the environment is configured to redirect to site homepage after signup + And feature "skip_new_user_email_confirmation" is enabled on environment + And I am on /search/people + When I follow "Sign up" + And I fill in the following within ".no-boxes": + | e-Mail | josesilva@example.com | + | Username | josesilva | + | Password | secret | + | Password confirmation | secret | + | Full name | José da Silva | + And wait for the captcha signup time + And I press "Create my account" + Then I should be on the homepage + diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index bdecb0d..aeb5649 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option profile.save end +Given /^the environment is configured to (.*) after signup$/ do |option| + redirection = case option + when 'stay on the same page' + 'keep_on_same_page' + when 'redirect to site homepage' + 'site_homepage' + when 'redirect to user profile page' + 'user_profile_page' + when 'redirect to profile homepage' + 'user_homepage' + when 'redirect to profile control panel' + 'user_control_panel' + end + environment = Environment.default + environment.redirection_after_signup = redirection + environment.save +end + When /^wait for the captcha signup time$/ do environment = Environment.default sleep environment.min_signup_delay + 1 -- libgit2 0.21.2