From 3a332fadd1ddcc4bc6c849c2f5ed96ba48d163e1 Mon Sep 17 00:00:00 2001 From: Celso Martins Date: Tue, 27 Aug 2024 15:53:07 -0300 Subject: [PATCH] fix: fix blocker and unblocker --- app/models/demand_block.rb | 2 +- spec/controllers/demand_blocks_controller_spec.rb | 12 ++++++------ spec/models/demand_block_spec.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/demand_block.rb b/app/models/demand_block.rb index 0c4e38d2c..89162e1b4 100644 --- a/app/models/demand_block.rb +++ b/app/models/demand_block.rb @@ -43,7 +43,7 @@ class DemandBlock < ApplicationRecord belongs_to :demand belongs_to :stage, optional: true belongs_to :blocker, class_name: 'TeamMember', inverse_of: :demand_blocks - belongs_to :unblocker, class_name: 'TeamMember', inverse_of: :demand_blocks, optional: true + belongs_to :unblocker, class_name: 'TeamMember', inverse_of: :demand_unblocks, optional: true belongs_to :risk_review, optional: true has_many :demand_block_notifications, dependent: :destroy, class_name: 'Notifications::DemandBlockNotification' diff --git a/spec/controllers/demand_blocks_controller_spec.rb b/spec/controllers/demand_blocks_controller_spec.rb index 9c2d31637..87ce53b3d 100644 --- a/spec/controllers/demand_blocks_controller_spec.rb +++ b/spec/controllers/demand_blocks_controller_spec.rb @@ -539,7 +539,7 @@ second_block = Fabricate :demand_block, demand: first_demand, block_type: :coding_needed, blocker: team_member, unblocker: other_team_member, block_reason: 'second_block', block_time: 3.days.ago, unblock_time: 2.days.ago, active: true third_block = Fabricate :demand_block, demand: second_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'third_block', block_time: 5.days.ago, unblock_time: 4.days.ago, active: true fourth_block = Fabricate :demand_block, demand: first_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'fourth_block', block_time: 4.days.ago, unblock_time: Time.zone.yesterday, active: true - Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true + fifth_block = Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :waiting_external_supplier, blocker: team_member, unblocker: team_member, block_reason: 'sixth_block', block_time: 6.days.ago, unblock_time: 5.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'seventh_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: Time.zone.today Fabricate :demand_block, demand: third_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'eigth_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: nil @@ -550,7 +550,7 @@ post :search, params: { company_id: company, demand_blocks_ids: DemandBlock.all.map(&:id).join(','), blocks_team_member: other_team_member.id } expect(response).to render_template 'demand_blocks/index' - expect(assigns(:demand_blocks)).to eq [second_block, fourth_block, third_block] + expect(assigns(:demand_blocks)).to eq [second_block, fourth_block, third_block, fifth_block] expect(assigns(:demands_count)).to eq 2 end end @@ -739,7 +739,7 @@ second_block = Fabricate :demand_block, demand: first_demand, block_type: :coding_needed, blocker: team_member, unblocker: other_team_member, block_reason: 'second_block', block_time: 3.days.ago, unblock_time: 2.days.ago, active: true third_block = Fabricate :demand_block, demand: second_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'third_block', block_time: 5.days.ago, unblock_time: 4.days.ago, active: true fourth_block = Fabricate :demand_block, demand: first_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'fourth_block', block_time: 4.days.ago, unblock_time: Time.zone.yesterday, active: true - Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true + fifth_block = Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :waiting_external_supplier, blocker: team_member, unblocker: team_member, block_reason: 'sixth_block', block_time: 6.days.ago, unblock_time: 5.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'seventh_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: Time.zone.today Fabricate :demand_block, demand: third_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'eigth_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: nil @@ -750,7 +750,7 @@ post :search, params: { company_id: company, demand_blocks_ids: DemandBlock.all.map(&:id).join(','), blocks_team_member: other_team_member.id, blocks_ordering: :member_name } expect(response).to have_http_status :ok - expect(assigns(:demand_blocks)).to match_array [second_block, third_block, fourth_block] + expect(assigns(:demand_blocks)).to match_array [second_block, third_block, fourth_block, fifth_block] expect(response).to render_template 'demand_blocks/index' end end @@ -771,7 +771,7 @@ second_block = Fabricate :demand_block, demand: first_demand, block_type: :coding_needed, blocker: team_member, unblocker: other_team_member, block_reason: 'second_block', block_time: 3.days.ago, unblock_time: 2.days.ago, active: true third_block = Fabricate :demand_block, demand: second_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'third_block', block_time: 5.days.ago, unblock_time: 4.days.ago, active: true fourth_block = Fabricate :demand_block, demand: first_demand, block_type: :specification_needed, blocker: other_team_member, unblocker: other_team_member, block_reason: 'fourth_block', block_time: 4.days.ago, unblock_time: Time.zone.yesterday, active: true - Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true + fifth_block = Fabricate :demand_block, demand: first_demand, block_type: :waiting_external_supplier, blocker: other_team_member, unblocker: team_member, block_reason: 'fifth_block', block_time: 5.days.ago, unblock_time: 3.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :waiting_external_supplier, blocker: team_member, unblocker: team_member, block_reason: 'sixth_block', block_time: 6.days.ago, unblock_time: 5.days.ago, active: true Fabricate :demand_block, demand: second_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'seventh_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: Time.zone.today Fabricate :demand_block, demand: third_demand, block_type: :coding_needed, blocker: team_member, unblocker: team_member, block_reason: 'eigth_block', block_time: 7.days.ago, unblock_time: 6.days.ago, active: true, discarded_at: nil @@ -782,7 +782,7 @@ post :search, params: { company_id: company, demand_blocks_ids: DemandBlock.all.map(&:id).join(','), blocks_team_member: other_team_member.id, blocks_ordering: :block_time } expect(response).to have_http_status :ok - expect(assigns(:demand_blocks)).to eq [second_block, fourth_block, third_block] + expect(assigns(:demand_blocks)).to eq [second_block, fourth_block, third_block, fifth_block] expect(response).to render_template 'demand_blocks/index' end end diff --git a/spec/models/demand_block_spec.rb b/spec/models/demand_block_spec.rb index ff665badb..f0bc96852 100644 --- a/spec/models/demand_block_spec.rb +++ b/spec/models/demand_block_spec.rb @@ -10,7 +10,7 @@ it { is_expected.to belong_to(:stage).optional } it { is_expected.to belong_to(:risk_review).optional } it { is_expected.to belong_to(:blocker).class_name(TeamMember).inverse_of(:demand_blocks) } - it { is_expected.to belong_to(:unblocker).class_name(TeamMember).inverse_of(:demand_blocks).optional } + it { is_expected.to belong_to(:unblocker).class_name(TeamMember).inverse_of(:demand_unblocks).optional } it { is_expected.to have_many(:demand_block_notifications).class_name('Notifications::DemandBlockNotification').dependent(:destroy) } end