-
Notifications
You must be signed in to change notification settings - Fork 57
/
control_information_spec.rb
105 lines (87 loc) · 2.78 KB
/
control_information_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
require 'rails_helper'
require 'lighthouse/direct_deposit/control_information'
RSpec.describe Lighthouse::DirectDeposit::ControlInformation do
let(:info) { described_class.new }
before do
info.clear_restrictions
end
context 'when clear_restrictions is called' do
it 'is updatable' do
expect(info.account_updatable?).to be(true)
end
end
context 'when no restrictions' do
it 'is updateable' do
expect(info.account_updatable?).to be(true)
expect(info.restrictions).to be_empty
end
context 'and can_update_direct_deposit is false' do
it 'is invalid' do
info.is_edu_claim_available = true
info.can_update_direct_deposit = false
expect(info.valid?).to be(false)
expect(info.errors).to eq(['Has no restrictions. Account should be updatable.'])
end
end
end
context 'when there is a restriction' do
it 'is not updateable' do
info.restrictions.each do |name|
info.clear_restrictions
info.send("#{name}=", false)
expect(info.account_updatable?).to be(false)
expect(info.restrictions).not_to be_empty
end
end
context 'and can_update_direct_deposit is true' do
it 'is invalid' do
info.is_corp_available = true
info.has_index = false
info.can_update_direct_deposit = true
expect(info.valid?).to be(false)
expect(info.errors).to eq(['Has restrictions. Account should not be updatable.'])
end
end
end
context 'when is_corp_available is true' do
it 'is for comp and pen' do
info.is_corp_available = true
expect(info.comp_and_pen?).to be(true)
end
end
context 'when is_edu_claim_available is true' do
it 'is for edu benefits' do
info.is_edu_claim_available = true
expect(info.edu_benefits?).to be(true)
end
end
context 'when no benefit type' do
it 'is invalid' do
expect(info.valid?).to be(false)
expect(info.errors).to eq(['Missing benefit type. Must be either CnP or EDU benefits.'])
end
end
context 'benefit type' do
it 'returns a benefit type of cnp' do
info.is_corp_available = true
info.is_edu_claim_available = false
expect(info.benefit_type).to eq('cnp')
end
it 'returns a benefit type of edu' do
info.is_corp_available = false
info.is_edu_claim_available = true
expect(info.benefit_type).to eq('edu')
end
it 'returns a benefit type of both' do
info.is_corp_available = true
info.is_edu_claim_available = true
expect(info.benefit_type).to eq('both')
end
it 'returns a benefit type of none' do
info.is_corp_available = false
info.is_edu_claim_available = false
expect(info.benefit_type).to eq('none')
end
end
end