From 61413dcb93a243562ff727de8f234e5a2aed4deb Mon Sep 17 00:00:00 2001 From: Lucas Sotty Date: Fri, 4 Aug 2017 11:43:53 +0200 Subject: [PATCH] Added test for association between product and intervention_participations --- test/models/product_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 901cea05b3..34b0689ed2 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -94,4 +94,31 @@ class ProductTest < ActiveSupport::TestCase assert Product.of_working_set(item.name).count >= 0 end end + + test 'intervention_participations association' do + category = ProductNatureCategory.create!(name: "Category name") + nature = ProductNature.create!( + name: "Nature name", + category: category, + population_counting: "unitary", + variety: "cultivable_zone" + ) + variant = ProductNatureVariant.create!( + unit_name: "Variant unit name", + category: category, + nature: nature, + variety: "cultivable_zone" + ) + product = Product.create!( + category: category, + nature: nature, + variant: variant, + variety: "cultivable_zone" + ) + intervention_participation = InterventionParticipation.create!( + product: product, + state: "in_progress" + ) + assert_equal(1, product.intervention_participations.length) + end end