Created
September 12, 2012 22:16
-
-
Save tonatiuh/3710358 to your computer and use it in GitHub Desktop.
Records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## The vertical | |
#Be sure of that vertical with id 1 exists | |
## The campaign (form) | |
#Put to the campaign the state of washignton | |
#Set to the campaign the vertical: 1 | |
## The contacts (on the rails console) | |
Contact.create(:name => 'Jodee Clore', :vertical_id => 1, :geo_id => '15121') #this geo_id's are citys of washington | |
Contact.create(:name => 'Trish Roudebush', :vertical_id => 1, :geo_id => '14974') |
I adapted it like follows and it doesn't pass : /
it 'should purchase automatically a contact on matching campaign' do
vertical = FactoryGirl.create(:vertical)
geo = FactoryGirl.create(:geo)
campaign = FactoryGirl.create(:campaign, :geos => [geo], :vertical => vertical)
contact = FactoryGirl.create(:contact, :geo => geo, :vertical => vertical)
Purchase.last.contact.should == contact
end
Got
Failure/Error: Purchase.last.contact.should == contact
NoMethodError:
undefined method `contact' for nil:NilClass
Looks like it is not creating the purchase.
it 'should purchase automatically a contact on matching campaign' do
vertical = FactoryGirl.create(:vertical)
geo = FactoryGirl.create(:geo)
campaign = FactoryGirl.create(:campaign, :geos => [geo], :vertical => vertical)
contact = FactoryGirl.create(:contact, :geo => geo, :vertical => vertical)
contact.new_contact_obligations ## this triggers a notification to the ContactObserver, which in turn triggers the purchase transaction
Purchase.last.contact.should == contact
end
perhaps the test assertion could also be:
contact.purchases.count.should eq(1)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what if:
This
contact
should automatically be purchased by thecampaign
object.