Skip to content
Browse files

'share on facebook' in post-signature emails is now using experiment …

…correctly
  • Loading branch information...
1 parent 04d131a commit 36222db0041df5dbb5162abdbc697252ace8b7dc @jimarnold jimarnold committed Nov 29, 2012
Showing with 15 additions and 5 deletions.
  1. +3 −1 app/mailers/notifications.rb
  2. +12 −4 spec/mailers/notifications_spec.rb
View
4 app/mailers/notifications.rb
@@ -16,7 +16,9 @@ def signed_petition signature
experiments = EmailExperiments.new(email)
@image_url = experiments.best_image
@short_summary = experiments.best_summary
- @fb_share_url = "https://www.facebook.com/sharer/sharer.php?u=#{petition_url(signature.petition)}?mail_share_ref=#{email.to_hash}"
+ if experiments.show_facebook_share_button
+ @fb_share_url = "https://www.facebook.com/sharer/sharer.php?u=#{petition_url(signature.petition)}?mail_share_ref=#{email.to_hash}"
+ end
begin
mail({
View
16 spec/mailers/notifications_spec.rb
@@ -19,7 +19,15 @@
let(:signature) { create :signature, petition: petition }
let(:unsubscribe_link) { 'http://test/unsubscribe' }
let(:referer) { signature.member.to_hash }
- let(:mail) { Notifications.signed_petition(signature) }
+ let(:mail) {Notifications.signed_petition(signature)}
+ let(:sent_email) do
+ mail
+ SignatureEmail.last
+ end
+
+ before do
+ EmailExperiments.any_instance.stub(:show_facebook_share_button).and_return(true)
+ end
subject { mail }
its(:subject) { should match(/#{signature.petition.title}/) }
@@ -43,16 +51,16 @@
context 'html' do
let(:entities) { 'a<br>html "title"' }
let(:link) { "http://test/petitions/#{signature.petition.id}?r=#{referer}" }
- let(:paragraph) do
- "<p><b><a href=\"#{link}\">Please, click here to sign now!</a></b></p>"
- end
+ let(:paragraph) {"<p><b><a href=\"#{link}\">Please, click here to sign now!</a></b></p>"}
+ let(:fb_share_url) {"http://test/petitions/#{signature.petition.id}?mail_share_ref=#{sent_email.to_hash}"}
subject { mail.body.encoded }
it { should include unsubscribe_link }
it { should include paragraph }
it { should include entities }
it { should include link }
it { should_not include 'LINK' }
+ it { should include fb_share_url }
end
context 'plain text' do

0 comments on commit 36222db

Please sign in to comment.
Something went wrong with that request. Please try again.