Created
March 21, 2012 20:19
-
-
Save vpamulap/2152451 to your computer and use it in GitHub Desktop.
How would I unit test add_to_shopping_list?
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
class MealQueueRecipe < ActiveRecord::Base | |
belongs_to :meal_queue | |
belongs_to :recipe | |
after_create :add_to_shopping_list | |
after_destroy :remove_from_shopping_list | |
def add_to_shopping_list | |
sl = get_shopping_list | |
sl.add_mqr(self) | |
end | |
def remove_from_shopping_list | |
sl = get_shopping_list | |
sl.remove_mqr(self) | |
end | |
private | |
def get_shopping_list | |
self.meal_queue.user.shopping_list | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment