From cf907cc060a518877f1a497a666b60272ffc112e Mon Sep 17 00:00:00 2001 From: Seth Call Date: Thu, 26 Sep 2013 13:43:02 +0000 Subject: [PATCH] * VRFS-711 - adding new welcome email with useful links --- ruby/lib/jam_ruby/app/mailers/user_mailer.rb | 15 ++++++++-- .../user_mailer/confirm_email.html.erb | 5 ++++ .../user_mailer/confirm_email.text.erb | 3 ++ .../user_mailer/welcome_message.html.erb | 29 +++++++++++++++++-- .../user_mailer/welcome_message.text.erb | 17 +++++++++-- ruby/lib/jam_ruby/models/user.rb | 3 +- ruby/spec/mailers/render_emails_spec.rb | 3 +- ruby/spec/mailers/user_mailer_spec.rb | 25 ++++++++++++++-- web/lib/user_manager.rb | 2 +- web/spec/features/signup_spec.rb | 2 +- web/spec/managers/user_manager_spec.rb | 7 ++--- 11 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index ff5740718..009517765 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -19,13 +19,24 @@ #sendgrid_enable :opentrack, :clicktrack # this makes our emails creepy, imo (seth) sendgrid_unique_args :env => Environment.mode - def welcome_message(user, signup_confirm_url) + def confirm_email(user, signup_confirm_url) @user = user @signup_confirm_url = signup_confirm_url + sendgrid_category "Confirm Email" + sendgrid_unique_args :type => "confirm_email" + + mail(:to => user.email, :subject => "#{user.first_name}, please confirm your JamKazam email") do |format| + format.text + format.html + end + end + + def welcome_message(user) + @user = user sendgrid_category "Welcome" sendgrid_unique_args :type => "welcome_message" - mail(:to => user.email, :subject => "Welcome to JamKazam, #{user.first_name} ") do |format| + mail(:to => user.email, :subject => "Welcome to JamKazam, #{user.first_name}") do |format| format.text format.html end diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb new file mode 100644 index 000000000..074024223 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb @@ -0,0 +1,5 @@ +<% provide(:title, 'Confirm Email') %> + +

Welcome to Jamkazam, <%= @user.first_name %>!

+ +

To confirm this email address, please go to the signup confirmation page..

diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb new file mode 100644 index 000000000..73ad001bd --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb @@ -0,0 +1,3 @@ +Welcome to Jamkazam, <%= @user.first_name %>! + +To confirm this email address, please go to the signup confirmation page at: <%= @signup_confirm_url %>. \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.html.erb index 0358cb78d..5e31b9429 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.html.erb @@ -1,4 +1,27 @@ -<% provide(:title, 'Welcome to Jamkazam') %> +<% provide(:title, 'Welcome to JamKazam!') %> -

Welcome to Jamkazam, <%= @user.first_name %>!

-

To confirm this email address, please go to the signup confirmation page..

+

We're delighted that you have decided to try the JamKazam service, + and we hope that you will enjoy using JamKazam to play music with others. + Following are links to some resources that can help to get you up and running quickly. +

+ +

+Tutorial videos that show you how to use the key features of the product: +https://jamkazam.desk.com/customer/portal/articles/1304097-tutorial-videos +

+ +

+Getting Started knowledge base articles: +https://jamkazam.desk.com/customer/portal/topics/564807-getting-started/articles +

+ +

+Support Portal in case you run into trouble and need help: +https://jamkazam.desk.com/ +

+ +

+ We look forward to seeing - and hearing - you online soon! +

+ +  - Team JamKazam \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.text.erb index 73ad001bd..89f7d39fc 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/welcome_message.text.erb @@ -1,3 +1,16 @@ -Welcome to Jamkazam, <%= @user.first_name %>! +We're delighted that you have decided to try the JamKazam service, +and we hope that you will enjoy using JamKazam to play music with others. +Following are links to some resources that can help to get you up and running quickly. -To confirm this email address, please go to the signup confirmation page at: <%= @signup_confirm_url %>. \ No newline at end of file +Tutorial videos that show you how to use the key features of the product: +https://jamkazam.desk.com/customer/portal/articles/1304097-tutorial-videos + +Getting Started knowledge base articles: +https://jamkazam.desk.com/customer/portal/topics/564807-getting-started/articles + +Support Portal in case you run into trouble and need help: +https://jamkazam.desk.com/ + +We look forward to seeing - and hearing - you online soon! + + - Team JamKazam \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index bccb851d1..0e2c4d1ac 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -723,6 +723,7 @@ module JamRuby else # don't send an signup email if the user was invited already *and* they used the same email that they were invited with if !invited_user.nil? && invited_user.email.casecmp(user.email).zero? + UserMailer.welcome_message(user).deliver else # FIXME: @@ -731,7 +732,7 @@ module JamRuby # # any errors here should also rollback the transaction; that's OK. If emails aren't going to be delivered, # it's already a really bad situation; make user signup again - UserMailer.welcome_message(user, signup_confirm_url.nil? ? nil : (signup_confirm_url + "/" + user.signup_token) ).deliver + UserMailer.confirm_email(user, signup_confirm_url.nil? ? nil : (signup_confirm_url + "/" + user.signup_token) ).deliver end end end diff --git a/ruby/spec/mailers/render_emails_spec.rb b/ruby/spec/mailers/render_emails_spec.rb index 120a660f5..901ef61c5 100644 --- a/ruby/spec/mailers/render_emails_spec.rb +++ b/ruby/spec/mailers/render_emails_spec.rb @@ -25,7 +25,8 @@ describe "RenderMailers", :slow => true do save_emails_to_disk(mail, @filename) end - it { @filename="welcome_message"; UserMailer.welcome_message(user, "/signup").deliver } + it { @filename="welcome_message"; UserMailer.welcome_message(user).deliver } + it { @filename="confirm_email"; UserMailer.confirm_email(user, "/signup").deliver } it { @filename="password_reset"; UserMailer.password_reset(user, '/reset_password').deliver } it { @filename="password_changed"; UserMailer.password_changed(user).deliver } it { @filename="updated_email"; UserMailer.updated_email(user).deliver } diff --git a/ruby/spec/mailers/user_mailer_spec.rb b/ruby/spec/mailers/user_mailer_spec.rb index 68d7da550..6980cac0b 100644 --- a/ruby/spec/mailers/user_mailer_spec.rb +++ b/ruby/spec/mailers/user_mailer_spec.rb @@ -17,14 +17,35 @@ describe UserMailer do - describe "should send welcome email" do + describe "should send confirm email" do let (:mail) { UserMailer.deliveries[0] } let (:signup_confirmation_url) { "http://example.com/confirm" } let (:signup_confirmation_url_with_token ) { "#{signup_confirmation_url}/#{user.signup_token}" } before(:each) do - UserMailer.welcome_message(user, signup_confirmation_url_with_token).deliver + UserMailer.confirm_email(user, signup_confirmation_url_with_token).deliver + end + + + it { UserMailer.deliveries.length.should == 1 } + it { mail['from'].to_s.should == UserMailer::DEFAULT_SENDER } + it { mail['to'].to_s.should == user.email } + it { mail.multipart?.should == true } # because we send plain + html + + # verify that the messages are correctly configured + it { mail.html_part.body.include?("Welcome").should be_true } + it { mail.html_part.body.include?(signup_confirmation_url_with_token).should be_true } + it { mail.text_part.body.include?("Welcome").should be_true } + it { mail.text_part.body.include?(signup_confirmation_url_with_token).should be_true } + end + + describe "should send welcome email" do + + let (:mail) { UserMailer.deliveries[0] } + + before(:each) do + UserMailer.welcome_message(user).deliver end diff --git a/web/lib/user_manager.rb b/web/lib/user_manager.rb index 4eb487be5..66727cd83 100644 --- a/web/lib/user_manager.rb +++ b/web/lib/user_manager.rb @@ -36,7 +36,7 @@ class UserManager < BaseManager @user = User.signup(first_name, last_name, email, password, password_confirmation, terms_of_service, subscribe_email, location, instruments, birth_date, musician, photo_url, invited_user, signup_confirm_url) - return @user + return @user #end end diff --git a/web/spec/features/signup_spec.rb b/web/spec/features/signup_spec.rb index f7a23d0f4..f0abf52dc 100644 --- a/web/spec/features/signup_spec.rb +++ b/web/spec/features/signup_spec.rb @@ -79,7 +79,7 @@ describe "Signup" do it { should have_selector('h1', text: "congratulations") } # there is no email sent though when you signup based on an invite (because you just left your email to get here) - it { UserMailer.deliveries.length.should == 0 } + it { UserMailer.deliveries.length.should == 1 } it {uri = URI.parse(current_url); "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native')} end diff --git a/web/spec/managers/user_manager_spec.rb b/web/spec/managers/user_manager_spec.rb index ce1ffcbe0..6795e5f55 100644 --- a/web/spec/managers/user_manager_spec.rb +++ b/web/spec/managers/user_manager_spec.rb @@ -162,8 +162,7 @@ describe UserManager do @invitation.errors.any?.should be_false @invitation.accepted.should be_true - UserMailer.deliveries.length.should == 0 # no emails should be sent, in this case - + UserMailer.deliveries.length.should == 1 end it "signup successfully with due to user invitation with no autofriend" do @@ -183,7 +182,7 @@ describe UserManager do @invitation.errors.any?.should be_false @invitation.accepted.should be_true - UserMailer.deliveries.length.should == 0 # no emails should be sent, in this case + UserMailer.deliveries.length.should == 1 end it "signup successfully with due to user invitation with autofriend" do @@ -205,7 +204,7 @@ describe UserManager do @user.friends?(@some_user).should be_true @user.friends?(@some_user).should be_true - UserMailer.deliveries.length.should == 0 # no emails should be sent, in this case + UserMailer.deliveries.length.should == 1 end it "signup successfully with due to user invitation with autofriend, but uses another email" do