Skip to content

Commit

Permalink
Merge pull request #1663 from etalab/bugfix/update-on-transfer-ar
Browse files Browse the repository at this point in the history
DataPass webhooks: update authorization requests on tranfer
  • Loading branch information
skelz0r authored Sep 12, 2024
2 parents 6ced83a + 4bef5b3 commit 9ad61bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def reopening_event?
end

def should_update_authorization_request?
!context.reopening || (context.reopening && %w[approve validate].include?(context.event))
!context.reopening || (context.reopening && %w[transfer approve validate].include?(context.event))
end

def create_or_update_contacts_with_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
create(:authorization_request, :with_all_contacts, status: 'validated', external_id: authorization_id)
end

context 'when event is not approve or validate' do
context 'when event is not approve, validate or transfer' do
let!(:event) { 'draft' }

it { is_expected.to be_a_success }
Expand All @@ -108,7 +108,7 @@
end
end

context 'when event is approve or validate' do
context 'when event is validate' do
let!(:event) { 'validate' }

it { is_expected.to be_a_success }
Expand All @@ -119,6 +119,18 @@
}.to change { authorization_request.reload.last_update.to_i }
end
end

context 'when event is transfer' do
let!(:event) { 'transfer' }

it { is_expected.to be_a_success }

it 'updates the authorization request' do
expect {
subject
}.to change { authorization_request.reload.last_update.to_i }
end
end
end
end

Expand Down

0 comments on commit 9ad61bf

Please sign in to comment.