Skip to content

Commit

Permalink
fix: fix blocker and unblocker
Browse files Browse the repository at this point in the history
  • Loading branch information
celsoMartins committed Aug 27, 2024
1 parent dc2a1eb commit 3a332fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/demand_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/demand_blocks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/demand_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3a332fa

Please sign in to comment.