Skip to content

Instantly share code, notes, and snippets.

@kernow
Created December 16, 2010 15:01
Show Gist options
  • Save kernow/743488 to your computer and use it in GitHub Desktop.
Save kernow/743488 to your computer and use it in GitHub Desktop.
# cucumber feature
Scenario: Add member to mailing list
Given I am on the registration page
When I fill in my details
And I check "add me to the mailing list"
And I press "Sign up"
When the account is confirmed the member should be added to the mailing list
Scenario: Don't add member to mailing list
Given I am on the registration page
When I fill in my details
And I press "Sign up"
When the account is confirmed the member should not be added to the mailing list
# cucumber step definition
When /^the account is confirmed the member should (not )?be added to the mailing list$/ do |negative|
member = Member.last
if negative
puts "---- negative"
Subscriber.should_not_receive :add
else
puts "---- positive"
Subscriber.should_receive(:add).with(anything, member.email, member.name, anything, true)
end
visit member_confirmation_path(member, :confirmation_token => member.confirmation_token)
end
# model code
# devise doesn't provide any callbacks for after confirmation
# so override the method and call super on it
def confirm!
super
puts "boom!!"
signup_to_newsletter #if self.receive_newsletter
end
def signup_to_newsletter
# exceptions only get sent to exceptional, clients don't care if this fails
Exceptional.rescue do
puts "doing!"
cs = CreateSend.new
Subscriber.add CAMPAIGN_MONITOR_LIST_ID, self.email, self.name, [], true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment