From 911b48771be3e173b15e9f46ce94d1302af149f5 Mon Sep 17 00:00:00 2001 From: Celso Martins Date: Thu, 5 Dec 2024 17:09:04 -0300 Subject: [PATCH] feat: added efforts to customer --- app/models/customer.rb | 1 + spec/models/customer_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index bfd941a22..eb693d3d6 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -32,6 +32,7 @@ class Customer < ApplicationRecord has_many :products, dependent: :restrict_with_error has_many :demands, dependent: :nullify + has_many :demand_efforts, through: :demands has_many :demand_blocks, -> { distinct }, through: :demands has_many :contracts, dependent: :restrict_with_error has_many :customer_consolidations, dependent: :destroy, class_name: 'Consolidations::CustomerConsolidation' diff --git a/spec/models/customer_spec.rb b/spec/models/customer_spec.rb index 33eb7ea9f..1a49ac52d 100644 --- a/spec/models/customer_spec.rb +++ b/spec/models/customer_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe Customer do - context 'associations' do + context 'with associations' do it { is_expected.to belong_to :company } it { is_expected.to belong_to(:customer).optional } it { is_expected.to have_many :products } it { is_expected.to have_many(:demands).dependent(:nullify) } + it { is_expected.to have_many(:demand_efforts).through(:demands) } it { is_expected.to have_many(:contracts).dependent(:restrict_with_error) } it { is_expected.to have_many(:demand_blocks).through(:demands) } it { is_expected.to have_many(:customer_consolidations).dependent(:destroy).class_name('Consolidations::CustomerConsolidation') } @@ -16,7 +17,7 @@ it { is_expected.to have_many(:slack_configurations).dependent(:destroy) } end - context 'validations' do + context 'with validations' do context 'simple ones' do it { is_expected.to validate_presence_of :name } end