Skip to content

Commit

Permalink
feat: added efforts to customer
Browse files Browse the repository at this point in the history
  • Loading branch information
celsoMartins committed Dec 5, 2024
1 parent 226f7e4 commit 911b487
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 3 additions & 2 deletions spec/models/customer_spec.rb
Original file line number Diff line number Diff line change
@@ -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') }
Expand All @@ -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
Expand Down

0 comments on commit 911b487

Please sign in to comment.