Created
September 22, 2012 01:39
-
-
Save tonatiuh/3764818 to your computer and use it in GitHub Desktop.
Update another record on after_save on model
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
after_save :bid_adjusts | |
def bid_adjusts | |
unless @old_exclusive_campaign.nil? | |
campaign = Campaign.find(@old_exclusive_campaign.id) | |
campaign.update_attributes(exclusivity: false) | |
campaign.save | |
end | |
end |
Author
tonatiuh
commented
Sep 22, 2012
describe "once an exclusive campaign is created" do
context "takes over exclusivity from an old campaign" do
let(:old_campaign) { FactoryGirl.create(:campaign_exclusive, :name => "Old Exclusive", :bid => 3) }
it "should set to false the exclusivity field of old campaign", run: true do
FactoryGirl.create(:campaign_exclusive, bid: 4)
# may or may not need to do old_campaign.reload
old_campaign.exclusivity.should be_false
end
end
end
I don't know if you need to reload the old_campaign object... as we're using let
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment