Skip to content

Commit 4279b5a

Browse files
nihil2501ojbucao
authored andcommitted
[ART] POA request resolution validates unique POA request
1 parent 3fffd6a commit 4279b5a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

modules/accredited_representative_portal/app/models/accredited_representative_portal/power_of_attorney_request_resolution.rb

+2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ module Resolving
3232
has_kms_key
3333

3434
has_encrypted :reason, key: :kms_key, **lockbox_options
35+
36+
validates :power_of_attorney_request, uniqueness: true
3537
end
3638
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe AccreditedRepresentativePortal::PowerOfAttorneyRequestResolution, type: :model do
6+
it 'must uniquely be associated to a poa request' do
7+
resolution_a = create(:power_of_attorney_request_resolution, :expiration)
8+
9+
resolution_b = build(
10+
:power_of_attorney_request_resolution, :expiration,
11+
power_of_attorney_request: resolution_a.power_of_attorney_request
12+
)
13+
14+
expect(resolution_b).not_to be_valid
15+
expect(resolution_b.errors.full_messages).to eq(
16+
[
17+
"Power of attorney request has already been taken",
18+
"Resolving is invalid"
19+
]
20+
)
21+
end
22+
end

0 commit comments

Comments
 (0)