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