From 41af2d79b561f098abf3b3d00467679cd3a69cd3 Mon Sep 17 00:00:00 2001
From: Arpit Jalan <arpit@techapj.com>
Date: Wed, 1 Oct 2014 23:03:49 +0530
Subject: [PATCH] add user email on account created page

---
 app/controllers/users_controller.rb       |  2 ++
 app/views/users/account_created.html.erb  |  4 +++-
 config/locales/server.en.yml              |  2 +-
 spec/controllers/users_controller_spec.rb | 12 ++++++++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 806315ca8..a83c7e75b 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -220,6 +220,8 @@ class UsersController < ApplicationController
       authentication.finish
       activation.finish
 
+      # save user email in session, to show on account-created page
+      session["user_created_email"] = user.email
 
       render json: {
         success: true,
diff --git a/app/views/users/account_created.html.erb b/app/views/users/account_created.html.erb
index ce13d4f14..ea8cf7d9e 100644
--- a/app/views/users/account_created.html.erb
+++ b/app/views/users/account_created.html.erb
@@ -1,3 +1,5 @@
 <div id='simple-container'>
-  <span style="font-size: 16px; line-height: 24px;"><%= t 'login.activate_email' %></span>
+  <% if session["user_created_email"] %>
+    <span style="font-size: 16px; line-height: 24px;"><%= t('login.activate_email', email: session["user_created_email"]).html_safe %></span>
+  <% end %>
 </div>
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 62500b33a..bf64f9c9e 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1087,7 +1087,7 @@ en:
     incorrect_username_email_or_password: "Incorrect username, email or password"
     wait_approval: "Thanks for signing up. We will notify you when your account has been approved."
     active: "Your account is activated and ready to use."
-    activate_email: "You're almost done! We sent an activation mail to the email address you provided. Please follow the instructions in the email to activate your account."
+    activate_email: "<p>You're almost done! We sent an activation mail to <b>%{email}</b>. Please follow the instructions in the email to activate your account.</p><p>If it doesn't arrive, check your spam folder, or try to log in again to send another activation mail.</p>"
     not_activated: "You can't log in yet. We sent an activation email to you. Please follow the instructions in the email to activate your account."
     not_allowed_from_ip_address: "You can't login as %{username} from that IP address."
     suspended: "You can't log in until %{date}."
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 6ba162515..1b12ac2e7 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -356,6 +356,9 @@ describe UsersController do
         post_user
 
         expect(JSON.parse(response.body)['active']).to be_falsey
+
+        # should save user_created_email in session
+        session["user_created_email"].should == @user.email
       end
 
       context "and 'must approve users' site setting is enabled" do
@@ -389,6 +392,9 @@ describe UsersController do
       it 'enqueues a welcome email' do
         User.any_instance.expects(:enqueue_welcome_message).with('welcome_user')
         post_user
+
+        # should save user_created_email in session
+        session["user_created_email"].should == @user.email
       end
 
       it "shows the 'active' message" do
@@ -471,6 +477,9 @@ describe UsersController do
         xhr :post, :create, create_params
         json = JSON::parse(response.body)
         json["success"].should == true
+
+        # should not change the session
+        session["user_created_email"].should be_blank
       end
     end
 
@@ -512,6 +521,9 @@ describe UsersController do
         xhr :post, :create, create_params
         json = JSON::parse(response.body)
         json["success"].should_not == true
+        
+        # should not change the session
+        session["user_created_email"].should be_blank
       end
     end