Commit 3b316fadbfc6d15dc38479abd4057a7efcb07f09

Authored by Rodrigo Souto
1 parent ad1a6b16

[template-welcome-page] Option to redirect to welcome page after signup

   * Move welcome page a separate action under the HomeController
     instead of cranking it under the signup.
   * May show welcome page to both signup (with or without
     confirmation).

(ActionItem3075)
app/controllers/public/account_controller.rb
@@ -110,7 +110,7 @@ class AccountController < ApplicationController @@ -110,7 +110,7 @@ class AccountController < ApplicationController
110 check_join_in_community(@user) 110 check_join_in_community(@user)
111 go_to_signup_initial_page 111 go_to_signup_initial_page
112 else 112 else
113 - @register_pending = true 113 + redirect_to :controller => :home, :action => :welcome
114 end 114 end
115 end 115 end
116 end 116 end
@@ -441,6 +441,8 @@ class AccountController < ApplicationController @@ -441,6 +441,8 @@ class AccountController < ApplicationController
441 redirect_to user.url 441 redirect_to user.url
442 when 'user_control_panel' 442 when 'user_control_panel'
443 redirect_to user.admin_url 443 redirect_to user.admin_url
  444 + when 'welcome_page'
  445 + redirect_to :controller => :home, :action => :welcome
444 else 446 else
445 redirect_back_or_default(default) 447 redirect_back_or_default(default)
446 end 448 end
app/controllers/public/home_controller.rb
@@ -18,4 +18,9 @@ class HomeController < PublicController @@ -18,4 +18,9 @@ class HomeController < PublicController
18 @no_design_blocks = true 18 @no_design_blocks = true
19 end 19 end
20 20
  21 + def welcome
  22 + self.class.no_design_blocks
  23 + @display_confirmation_tips = !user.present? && !environment.enabled?(:skip_new_user_email_confirmation)
  24 + end
  25 +
21 end 26 end
app/models/environment.rb
@@ -153,7 +153,8 @@ class Environment < ActiveRecord::Base @@ -153,7 +153,8 @@ class Environment < ActiveRecord::Base
153 'site_homepage' => _('Redirects the user to the environment homepage.'), 153 'site_homepage' => _('Redirects the user to the environment homepage.'),
154 'user_profile_page' => _('Redirects the user to his profile page.'), 154 'user_profile_page' => _('Redirects the user to his profile page.'),
155 'user_homepage' => _('Redirects the user to his homepage.'), 155 'user_homepage' => _('Redirects the user to his homepage.'),
156 - 'user_control_panel' => _('Redirects the user to his control panel.') 156 + 'user_control_panel' => _('Redirects the user to his control panel.'),
  157 + 'welcome_page' => _('Redirects the user to the environment welcome page.')
157 } 158 }
158 end 159 end
159 validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true 160 validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true
app/views/account/signup.html.erb
1 -<% if @register_pending %>  
2 - <div id='thanks-for-signing'>  
3 - <% if environment.has_custom_welcome_screen? %>  
4 - <%= environment.settings[:signup_welcome_screen_body].html_safe %>  
5 - <% else %>  
6 - <h1><%= _("Welcome to %s!") % environment.name %></h1>  
7 - <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3>  
8 - <p><%= _("Firstly, some tips for getting started:") %></p>  
9 - <h4><%= _("Confirm your account!") %></h4>  
10 - <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p>  
11 - <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p>  
12 - <h4><%= _("What to do next?") %></h4>  
13 - <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p>  
14 - <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p>  
15 - <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p>  
16 - <p><%= _("Start exploring and have fun!") %></p>  
17 - <% end %>  
18 - </div>  
19 -<% else %>  
20 - <h1><%= _('Sign up for %s!') % environment.name %></h1>  
21 - <%= render :partial => 'signup_form' %>  
22 -<% end %> 1 +<h1><%= _('Sign up for %s!') % environment.name %></h1>
  2 +<%= render :partial => 'signup_form' %>
app/views/home/welcome.html.erb 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +<div id='thanks-for-signing'>
  2 + <% if environment.has_custom_welcome_screen? %>
  3 + <%= environment.settings[:signup_welcome_screen_body].html_safe %>
  4 + <% else %>
  5 + <h1><%= _("Welcome to %s!") % environment.name %></h1>
  6 + <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3>
  7 + <p><%= _("Firstly, some tips for getting started:") %></p>
  8 + <% if @display_confirmation_tips %>
  9 + <h4><%= _("Confirm your account!") %></h4>
  10 + <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p>
  11 + <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p>
  12 + <% end %>
  13 + <h4><%= _("What to do next?") %></h4>
  14 + <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p>
  15 + <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p>
  16 + <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p>
  17 + <p><%= _("Start exploring and have fun!") %></p>
  18 + <% end %>
  19 +</div>
features/signup.feature
@@ -152,6 +152,21 @@ Feature: signup @@ -152,6 +152,21 @@ Feature: signup
152 Then I should be on the homepage 152 Then I should be on the homepage
153 153
154 @selenium 154 @selenium
  155 + Scenario: user should go to the environment's welcome page after signup
  156 + Given the environment is configured to redirect to welcome page after signup
  157 + And I am on /search/people
  158 + When I follow "Sign up"
  159 + And I fill in the following within ".no-boxes":
  160 + | e-Mail | josesilva@example.com |
  161 + | Username | josesilva |
  162 + | Password | secret |
  163 + | Password confirmation | secret |
  164 + | Full name | José da Silva |
  165 + And wait for the captcha signup time
  166 + And I press "Create my account"
  167 + Then I should be on the welcome page
  168 +
  169 + @selenium
155 Scenario: user should stay on same page after following confirmation link 170 Scenario: user should stay on same page after following confirmation link
156 Given the environment is configured to stay on the same page after login 171 Given the environment is configured to stay on the same page after login
157 And feature "skip_new_user_email_confirmation" is disabled on environment 172 And feature "skip_new_user_email_confirmation" is disabled on environment
features/step_definitions/noosfero_steps.rb
@@ -745,6 +745,8 @@ Given /^the environment is configured to (.*) after signup$/ do |option| @@ -745,6 +745,8 @@ Given /^the environment is configured to (.*) after signup$/ do |option|
745 'user_homepage' 745 'user_homepage'
746 when 'redirect to profile control panel' 746 when 'redirect to profile control panel'
747 'user_control_panel' 747 'user_control_panel'
  748 + when 'redirect to welcome page'
  749 + 'welcome_page'
748 end 750 end
749 environment = Environment.default 751 environment = Environment.default
750 environment.redirection_after_signup = redirection 752 environment.redirection_after_signup = redirection
features/support/paths.rb
@@ -20,8 +20,8 @@ module NavigationHelpers @@ -20,8 +20,8 @@ module NavigationHelpers
20 when /^\// 20 when /^\//
21 page_name 21 page_name
22 22
23 - when /^(.*)'s profile/  
24 - '/profile/' + profile_identifier($1) 23 + when /the welcome page/
  24 + '/site/welcome'
25 25
26 when /article "([^"]+)"\s*$/ 26 when /article "([^"]+)"\s*$/
27 url_for(Article.find_by_name($1).url.merge({:only_path => true})) 27 url_for(Article.find_by_name($1).url.merge({:only_path => true}))
test/functional/account_controller_test.rb
@@ -50,8 +50,6 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -50,8 +50,6 @@ class AccountControllerTest &lt; ActionController::TestCase
50 def test_should_allow_signup 50 def test_should_allow_signup
51 assert_difference 'User.count' do 51 assert_difference 'User.count' do
52 new_user 52 new_user
53 - assert_response :success  
54 - assert_not_nil assigns(:register_pending)  
55 end 53 end
56 end 54 end
57 55
@@ -104,8 +102,6 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -104,8 +102,6 @@ class AccountControllerTest &lt; ActionController::TestCase
104 assert_difference 'User.count' do 102 assert_difference 'User.count' do
105 Environment.default.update_attribute(:terms_of_use, 'some terms ...') 103 Environment.default.update_attribute(:terms_of_use, 'some terms ...')
106 new_user(:terms_accepted => '1') 104 new_user(:terms_accepted => '1')
107 - assert_response :success  
108 - assert_not_nil assigns(:register_pending)  
109 end 105 end
110 end 106 end
111 107
@@ -626,7 +622,6 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -626,7 +622,6 @@ class AccountControllerTest &lt; ActionController::TestCase
626 Person.any_instance.stubs(:required_fields).returns(['organization']) 622 Person.any_instance.stubs(:required_fields).returns(['organization'])
627 assert_difference 'User.count' do 623 assert_difference 'User.count' do
628 post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' }, :profile_data => { :organization => 'example.com' } 624 post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' }, :profile_data => { :organization => 'example.com' }
629 - assert_response :success  
630 end 625 end
631 assert_equal 'example.com', Person['testuser'].organization 626 assert_equal 'example.com', Person['testuser'].organization
632 end 627 end
@@ -958,6 +953,14 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -958,6 +953,14 @@ class AccountControllerTest &lt; ActionController::TestCase
958 assert_equal label, "Lavras do Sul" 953 assert_equal label, "Lavras do Sul"
959 end 954 end
960 955
  956 + should 'redirect to welcome page after successful signup if environment configured as so' do
  957 + environment = Environment.default
  958 + environment.redirection_after_signup = 'welcome_page'
  959 + environment.save!
  960 + new_user
  961 + assert_redirected_to :controller => 'home', :action => 'welcome'
  962 + end
  963 +
961 protected 964 protected
962 def new_user(options = {}, extra_options ={}) 965 def new_user(options = {}, extra_options ={})
963 data = {:profile_data => person_data} 966 data = {:profile_data => person_data}