-
-
Save tonatiuh/3725616 to your computer and use it in GitHub Desktop.
def new_contact_obligations | |
# self.vertical = conversions.first.placement.vertical | |
self.attributes = load_loc_attrs | |
self.save! | |
notify_observers(:find_campaigns) | |
end |
before :each do | |
@vertical = FactoryGirl.create(:vertical) | |
@geo = FactoryGirl.create(:geo) | |
end | |
context "when find_campaigns callback is called" do | |
it 'should automatically purchase a contact when a matching campaign', run: true do | |
campaign = FactoryGirl.create(:campaign, :geos => [@geo], :vertical => @vertical) | |
contact = FactoryGirl.create(:contact , :geo => @geo, :vertical => @vertical) | |
contact.new_contact_obligations | |
contact.campaigns.first.should eql campaign | |
campaign.purchases.first.contact.should eql contact | |
end | |
end |
yeah i ran into that too. See line 9 of the spec/models/contact_observer_spec.rb file to see how i removed the campaign created by FactoryGirl.create(:contact) from test consideration. Kinda sloppy though. like i said we really should have a factory that creates a contact without the conversion
Do you mind on this test?
it "should find an associated campaign" do
campaign = FactoryGirl.create(:campaign)
contact = FactoryGirl.create(:contact)
contact.new_contact_obligations #until after_commit bug gets fixed
contact.campaigns.first.should eql campaign
campaign.purchases.first.contact.should eql contact
end
I don't figure to which line are you referring.
@tonatiuh, you need to merge/rebase my changes from staging, its also got some good new tests there relevant to what you're working on i think. Here is the version i'm referring to:
https://github.com/stonegiantlabs/ContactLogic/blob/staging/spec/models/contact_observer_spec.rb
Ok man, I'll check that then because looks like that line is the only issue that i have to finish this feature, thanks ( :
By this way it pases, but when I uncomment this line:
´´´ruby
self.vertical = conversions.first.placement.vertical
´´´
it fails, because two verticals are created, the problem is that I don't find how is that
´´´ruby
conversions.first.placement.vertical
´´´
can get a vertical.