0
嗨,我在我的EnrolledAccount模型中有以下方法,我想写rpec。我的问题是如何在rspec中创建Item和EnrolledAccount之间的关联。如何在rails中为模型方法编写rspec?
def delete_account
items = self.items
item_array = items.blank? ? [] : items.collect {|i| i.id }
ItemShippingDetail.destroy_all(["item_id in (?)", item_array]) unless item_array.blank?
ItemPaymentDetail.destroy_all(["item_id in (?)", item_array]) unless item_array.blank?
Item.delete_all(["enrolled_account_id = ?", self.id])
self.delete
end
感谢您的帮助。另外我想为这个模型写rpec。你能帮忙吗? – Salil
新增应用程序示例(或显着)规范的关系。 – nathanvda
我想知道我是否可以为delete_account方法编写rspec。 – Salil