Skip to content

Instantly share code, notes, and snippets.

@vpamulap
Created March 21, 2012 20:19
Show Gist options
  • Save vpamulap/2152451 to your computer and use it in GitHub Desktop.
Save vpamulap/2152451 to your computer and use it in GitHub Desktop.
How would I unit test add_to_shopping_list?
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