Skip to content

Commit

Permalink
fix: avoid deleting manual assignments while syncing demand
Browse files Browse the repository at this point in the history
  • Loading branch information
lhguerra committed Dec 19, 2024
1 parent a8d38d8 commit e1e1e53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/demands_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def demand_efforts
private

def clean_assignments_efforts
@demand.item_assignments.destroy_all
@demand.item_assignments.joins(:demand_efforts).where(demand_efforts: { automatic_update: true }).destroy_all
@demand.demand_efforts.where(automatic_update: true).destroy_all
end

Expand Down
8 changes: 6 additions & 2 deletions spec/controllers/demands_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@
it 'calls the services and the reader' do
first_assignment = Fabricate :item_assignment, demand: first_demand
second_assignment = Fabricate :item_assignment, demand: first_demand
first_effort = Fabricate :demand_effort, demand: first_demand
other_effort = Fabricate :demand_effort, demand: first_demand
manual_assignment = Fabricate :item_assignment, demand: first_demand
first_effort = Fabricate :demand_effort, demand: first_demand, automatic_update: true, item_assignment: first_assignment
other_effort = Fabricate :demand_effort, demand: first_demand, automatic_update: true, item_assignment: second_assignment
manual_effort = Fabricate :demand_effort, demand: first_demand, automatic_update: false, item_assignment: manual_assignment

expect(Jira::ProcessJiraIssueJob).to receive(:perform_later)
put :synchronize_jira, params: { company_id: company, id: first_demand }
Expand All @@ -396,6 +398,8 @@

expect(first_demand.reload.item_assignments).not_to include(first_assignment, second_assignment)
expect(first_demand.demand_efforts).not_to include(first_effort, other_effort)
expect(first_demand.demand_efforts).to include(manual_effort)
expect(first_demand.item_assignments).to include(manual_assignment)
end
end
end
Expand Down

0 comments on commit e1e1e53

Please sign in to comment.