diff --git a/app/models/partner_request.rb b/app/models/partner_request.rb index 3b4c3549..9560a67a 100644 --- a/app/models/partner_request.rb +++ b/app/models/partner_request.rb @@ -5,7 +5,7 @@ class PartnerRequest < ApplicationRecord accepts_nested_attributes_for :items, allow_destroy: true, reject_if: proc { |attributes| attributes["quantity"].blank? } validates :partner, presence: true - + validates_associated :items def export_json { request: { diff --git a/spec/models/partner_request_spec.rb b/spec/models/partner_request_spec.rb index b59980de..e2f37f12 100644 --- a/spec/models/partner_request_spec.rb +++ b/spec/models/partner_request_spec.rb @@ -15,6 +15,7 @@ describe "#formatted_items_hash" do let(:partner_request) { create(:partner_request_with_items, items_count: 1) } it "builds the item hash values for export json" do + partner_request.reload item = partner_request.items.first formatted_hash = { item.name => item.quantity } expect(partner_request.formatted_items_hash(partner_request.items)).to eql(formatted_hash)