Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
fixed tweetable urls and email referral parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Arnold committed Sep 5, 2012
1 parent d0b8dfb commit 8646deb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/controllers/petitions_controller.rb
Expand Up @@ -46,7 +46,7 @@ def show
@signing_from_email = sent_email.present? && !@was_signed

@facebook_friend_ids = facebook_friends @member
@tweetable_url = "http://#{request.host}#{request.fullpath}?t=#{cookies[:member_id]}"
@tweetable_url = "http://#{request.host}#{request.fullpath}?ref_type=#{Signature::ReferenceType::TWITTER}&ref_val=#{cookies[:member_id]}"
@query = request.query_parameters
@share_count = FacebookAction.count # used in _thanks_for_signing experiment
end
Expand Down Expand Up @@ -122,7 +122,11 @@ def log_empty_links
end

def sent_email
SentEmail.find_by_hash(params[:n])
if(params[:ref_type] == Signature::ReferenceType::EMAIL)
SentEmail.find_by_hash(params[:ref_val])
else
SentEmail.find_by_hash(params[:n])
end
end
memoize :sent_email

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/signatures_controller.rb
Expand Up @@ -44,7 +44,7 @@ def create

def track_referrals petition, signature
if params[:referral_type]
if (params[:referral_type] == Signature::ReferenceType::EMAIL)
if(params[:referral_type] == Signature::ReferenceType::EMAIL)
deal_with_email_special_case(petition, signature, params[:referral_value])
else
record_referer(signature, :referral_value, params[:referral_type])
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/petitions_controller_spec.rb
@@ -1,3 +1,4 @@

require 'spec_helper'
require 'member_hasher'

Expand Down Expand Up @@ -57,7 +58,7 @@ def valid_attributes
controller.stub(:cookies => {member_id: member.to_hash})
create(:signature, :member_id => member.id, :petition_id => petition.id)
get :show, :id => petition.id.to_s
assigns(:tweetable_url).should == "http://test.host/petitions/#{petition.id}?t=#{member.to_hash}"
assigns(:tweetable_url).should == "http://test.host/petitions/#{petition.id}?ref_type=twitter&ref_val=#{member.to_hash}"
end

it "should set was_signed to false if cookies don`t contain this petition" do
Expand Down
2 changes: 1 addition & 1 deletion spec/smoke/email_subject_experiments.rb
Expand Up @@ -13,7 +13,7 @@

email_as_html = Nokogiri::HTML(email)
petition_link = email_as_html.xpath("//a[text()='Please, click here to sign now!']/@href").to_s
go_to petition_link.scan(/(petitions\/\d+\?n=\d+\.\w+)$/).join
go_to petition_link.scan(/(petitions\/\d+\?ref_type=email&ref_val=\d+\.\w+)$/).join
sign_petition

experiment = email_experiment_results_for petition
Expand Down
2 changes: 1 addition & 1 deletion spec/smoke/petition_signing.rb
Expand Up @@ -35,7 +35,7 @@
referer = create_member
forwarded_notification_hash = referer.to_hash

referred_link = petition_path(@petition) + "?r=#{forwarded_notification_hash}"
referred_link = petition_path(@petition) + "?ref_type=#{Signature::ReferenceType::FORWARDED_NOTIFICATION}&ref_val=#{forwarded_notification_hash}"
go_to referred_link

sign_petition Faker::Name.first_name, Faker::Name.last_name, Faker::Internet.email
Expand Down

0 comments on commit 8646deb

Please sign in to comment.