-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Art/power of attorney request status updates.models #19600
Closed
nihil2501
wants to merge
3
commits into
master
from
art/power-of-attorney-request-status-updates.models
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
..._portal/app/models/accredited_representative_portal/power_of_attorney_request_decision.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestDecision < ApplicationRecord | ||
include PowerOfAttorneyRequestStatusUpdate::StatusUpdating | ||
|
||
self.inheritance_column = nil | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
...ortal/app/models/accredited_representative_portal/power_of_attorney_request_expiration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestExpiration < ApplicationRecord | ||
include PowerOfAttorneyRequestStatusUpdate::StatusUpdating | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
...rtal/app/models/accredited_representative_portal/power_of_attorney_request_replacement.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestReplacement < ApplicationRecord | ||
include PowerOfAttorneyRequestStatusUpdate::StatusUpdating | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
...al/app/models/accredited_representative_portal/power_of_attorney_request_status_update.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestStatusUpdate < ApplicationRecord | ||
delegated_type :status_updating, types: %w[ | ||
PowerOfAttorneyRequestReplacements | ||
PowerOfAttorneyRequestExpirations | ||
PowerOfAttorneyRequestWithdrawals | ||
PowerOfAttorneyRequestDecisions | ||
] | ||
|
||
module StatusUpdating | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_one( | ||
:power_of_attorney_request_status_update, | ||
as: :status_updating, | ||
touch: true | ||
) | ||
end | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
...ortal/app/models/accredited_representative_portal/power_of_attorney_request_withdrawal.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestWithdrawal < ApplicationRecord | ||
include PowerOfAttorneyRequestStatusUpdate::StatusUpdating | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ve_portal/db/migrate/20241125061506_create_ar_power_of_attorney_request_status_updates.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateArPowerOfAttorneyRequestStatusUpdates < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :ar_power_of_attorney_request_status_updates, id: :uuid do |t| | ||
t.string 'status_updating_type', null: false | ||
t.uuid 'status_updating_id', null: false | ||
t.datetime 'created_at', null: false | ||
end | ||
|
||
create_table :ar_power_of_attorney_request_replacements, id: :uuid | ||
|
||
create_table :ar_power_of_attorney_request_expirations, id: :uuid | ||
|
||
create_table :ar_power_of_attorney_request_withdrawals, id: :uuid do |t| | ||
t.text 'reason' | ||
end | ||
|
||
create_table :ar_power_of_attorney_request_decisions, id: :uuid do |t| | ||
t.string 'type', null: false | ||
t.text 'declination_reason' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
.../models/accredited_representatiive_portal/power_of_attorney_request_status_update_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../rails_helper' | ||
|
||
mod = AccreditedRepresentativePortal | ||
RSpec.describe mod::PowerOfAttorneyRequestStatusUpdate, type: :model do | ||
it 'conveniently returns heterogeneous lists' do | ||
travel_to '2024-11-25T09:46:24Z' | ||
|
||
ids = [] | ||
|
||
ids << | ||
described_class.create!( | ||
status_updating: mod::PowerOfAttorneyRequestDecision.new( | ||
type: 'acceptance' | ||
) | ||
).id | ||
|
||
ids << | ||
described_class.create!( | ||
status_updating: mod::PowerOfAttorneyRequestDecision.new( | ||
type: 'declination', | ||
declination_reason: 'Some declination reason.' | ||
) | ||
).id | ||
|
||
ids << | ||
described_class.create!( | ||
status_updating: mod::PowerOfAttorneyRequestReplacement.new | ||
).id | ||
|
||
ids << | ||
described_class.create!( | ||
status_updating: mod::PowerOfAttorneyRequestExpiration.new | ||
).id | ||
|
||
ids << | ||
described_class.create!( | ||
status_updating: mod::PowerOfAttorneyRequestWithdrawal.new( | ||
reason: 'Some withdrawal reason.' | ||
) | ||
).id | ||
|
||
status_updates = described_class.includes(:status_updating).find(ids) | ||
|
||
actual = | ||
status_updates.map do |status_update| | ||
serialized = | ||
case status_update.status_updating | ||
when mod::PowerOfAttorneyRequestDecision | ||
{ | ||
type: 'decision', | ||
decision_type: status_update.status_updating.type, | ||
declination_reason: status_update.status_updating.declination_reason | ||
} | ||
when mod::PowerOfAttorneyRequestWithdrawal | ||
{ | ||
type: 'withdrawal', | ||
reason: status_update.status_updating.reason | ||
} | ||
when mod::PowerOfAttorneyRequestExpiration | ||
{ | ||
type: 'expiration' | ||
} | ||
when mod::PowerOfAttorneyRequestReplacement | ||
{ | ||
type: 'replacement' | ||
} | ||
end | ||
|
||
serialized.merge!( | ||
created_at: status_update.created_at.iso8601 | ||
) | ||
end | ||
|
||
expect(actual).to eq( | ||
[ | ||
{ | ||
type: 'decision', | ||
decision_type: 'acceptance', | ||
declination_reason: nil, | ||
created_at: '2024-11-25T09:46:24Z' | ||
}, | ||
{ | ||
type: 'decision', | ||
decision_type: 'declination', | ||
declination_reason: 'Some declination reason.', | ||
created_at: '2024-11-25T09:46:24Z' | ||
}, | ||
{ | ||
type: 'replacement', | ||
created_at: '2024-11-25T09:46:24Z' | ||
}, | ||
{ | ||
type: 'expiration', | ||
created_at: '2024-11-25T09:46:24Z' | ||
}, | ||
{ | ||
type: 'withdrawal', | ||
reason: 'Some withdrawal reason.', | ||
created_at: '2024-11-25T09:46:24Z' | ||
} | ||
] | ||
) | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec directory has a type where "representatiive" with two i's