Skip to content

Commit

Permalink
Add copy authorization request event
Browse files Browse the repository at this point in the history
Mostly for data migration from v1
  • Loading branch information
skelz0r committed Apr 24, 2024
1 parent 4257e5e commit a23ec9b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/decorators/authorization_request_event_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def text
end
alias comment text # see WebhookEventSerializer

def previous_request_id
entity.previous_request_id
end

private

def humanized_changelog
Expand Down
2 changes: 2 additions & 0 deletions app/models/authorization_request_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class AuthorizationRequestEvent < ApplicationRecord
submit
update

copy

applicant_message
instructor_message

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
**{
user_full_name: authorization_request_event.user_full_name,
text: simple_format(authorization_request_event.text),
previous_request_id: authorization_request_event.previous_request_id,
}.compact
).html_safe
%>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ fr:
icon: close-circle-line
color: error

copy:
text: |
<strong>%{user_full_name}</strong> a copié la demande %{previous_request_id}
reopen:
text: "<strong>%{user_full_name}</strong> a réouvert l'habilitation"

Expand Down
17 changes: 17 additions & 0 deletions spec/factories/authorization_request_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@
end
end

trait :copy do
entity_is_authorization_request

name { 'copy' }

after(:build) do |authorization_request_event|
authorization_request = authorization_request_event.entity
authorization_request_trait = authorization_request.type.split('::').last.underscore.to_sym

previous_authorization_request = create(:authorization_request, :validated, authorization_request_trait, applicant: authorization_request.applicant)

authorization_request_event.entity.update!(
previous_request_id: previous_authorization_request.id,
)
end
end

trait :applicant_message do
name { 'applicant_message' }

Expand Down

0 comments on commit a23ec9b

Please sign in to comment.