|
4 | 4 | # |
5 | 5 | # Table name: teams |
6 | 6 | # |
7 | | -# id :bigint not null, primary key |
8 | | -# careplus_namespace :string |
9 | | -# careplus_password :string |
10 | | -# careplus_staff_code :string |
11 | | -# careplus_staff_type :string |
12 | | -# careplus_username :string |
13 | | -# careplus_venue_code :string |
14 | | -# days_before_consent_reminders :integer default(7), not null |
15 | | -# days_before_consent_requests :integer default(21), not null |
16 | | -# email :string |
17 | | -# name :text not null |
18 | | -# national_reporting_cut_off_date :date |
19 | | -# phone :string |
20 | | -# phone_instructions :string |
21 | | -# privacy_notice_url :string |
22 | | -# privacy_policy_url :string |
23 | | -# programme_types :enum not null, is an Array |
24 | | -# type :integer not null |
25 | | -# workgroup :string not null |
26 | | -# created_at :datetime not null |
27 | | -# updated_at :datetime not null |
28 | | -# organisation_id :bigint not null |
29 | | -# reply_to_id :uuid |
| 7 | +# id :bigint not null, primary key |
| 8 | +# careplus_automated_reports_enabled_at :datetime |
| 9 | +# careplus_namespace :string |
| 10 | +# careplus_password :string |
| 11 | +# careplus_staff_code :string |
| 12 | +# careplus_staff_type :string |
| 13 | +# careplus_username :string |
| 14 | +# careplus_venue_code :string |
| 15 | +# days_before_consent_reminders :integer default(7), not null |
| 16 | +# days_before_consent_requests :integer default(21), not null |
| 17 | +# email :string |
| 18 | +# name :text not null |
| 19 | +# national_reporting_cut_off_date :date |
| 20 | +# phone :string |
| 21 | +# phone_instructions :string |
| 22 | +# privacy_notice_url :string |
| 23 | +# privacy_policy_url :string |
| 24 | +# programme_types :enum not null, is an Array |
| 25 | +# type :integer not null |
| 26 | +# workgroup :string not null |
| 27 | +# created_at :datetime not null |
| 28 | +# updated_at :datetime not null |
| 29 | +# organisation_id :bigint not null |
| 30 | +# reply_to_id :uuid |
30 | 31 | # |
31 | 32 | # Indexes |
32 | 33 | # |
|
175 | 176 | create(:team, :with_careplus_enabled, careplus_username: nil) |
176 | 177 | create(:team, :with_careplus_enabled, careplus_password: nil) |
177 | 178 | create(:team, :with_careplus_enabled, careplus_namespace: nil) |
| 179 | + create( |
| 180 | + :team, |
| 181 | + :with_careplus_enabled, |
| 182 | + careplus_automated_reports_enabled_at: nil |
| 183 | + ) |
178 | 184 | create( |
179 | 185 | :team, |
180 | 186 | careplus_username: "careplus_user", |
|
208 | 214 | end |
209 | 215 | end |
210 | 216 |
|
| 217 | + describe "#has_careplus_credentials?" do |
| 218 | + subject(:has_careplus_credentials?) { team.has_careplus_credentials? } |
| 219 | + |
| 220 | + context "when CarePlus credentials are configured" do |
| 221 | + let(:team) { create(:team, :with_careplus_enabled) } |
| 222 | + |
| 223 | + it { should be(true) } |
| 224 | + end |
| 225 | + |
| 226 | + context "when CarePlus credentials are missing" do |
| 227 | + let(:team) do |
| 228 | + create(:team, :with_careplus_enabled, careplus_username: nil) |
| 229 | + end |
| 230 | + |
| 231 | + it { should be(false) } |
| 232 | + end |
| 233 | + end |
| 234 | + |
211 | 235 | describe "#eligible_for_automated_careplus_reports?" do |
212 | 236 | subject(:eligible_for_automated_careplus_reports?) do |
213 | 237 | team.eligible_for_automated_careplus_reports? |
|
227 | 251 | it { should be(false) } |
228 | 252 | end |
229 | 253 |
|
| 254 | + context "when CarePlus integration has not been enabled yet" do |
| 255 | + let(:team) do |
| 256 | + create( |
| 257 | + :team, |
| 258 | + :with_careplus_enabled, |
| 259 | + careplus_automated_reports_enabled_at: nil |
| 260 | + ) |
| 261 | + end |
| 262 | + |
| 263 | + it { should be(false) } |
| 264 | + end |
| 265 | + |
230 | 266 | context "when CarePlus export fields are missing" do |
231 | 267 | let(:team) do |
232 | 268 | create( |
|
0 commit comments