|
| 1 | +# rubocop:disable RSpec/ExampleLength |
1 | 2 | RSpec.describe ScormEngine::Api::Endpoints::Configuration do |
2 | 3 | describe "#get_app_configuration" do |
3 | | - let(:subject) { scorm_engine_client.get_app_configuration } |
| 4 | + client(:client) { scorm_engine_client.get_app_configuration } |
4 | 5 |
|
5 | 6 | it "is successful" do |
6 | | - expect(subject.success?).to eq true |
| 7 | + expect(client.success?).to eq true |
7 | 8 | end |
8 | 9 |
|
9 | 10 | it "returns settings and values" do |
10 | | - expect(subject.result.UserCountReportLookBackDays).to be_truthy |
11 | | - expect(subject.result["UserCountReportDaysBetweenReports"]).to be_truthy |
| 11 | + aggregate_failures do |
| 12 | + expect(client.result.UserCountReportLookBackDays).to be_truthy |
| 13 | + expect(client.result["UserCountReportDaysBetweenReports"]).to be_truthy |
| 14 | + end |
12 | 15 | end |
13 | 16 |
|
14 | 17 | describe "includeMetadata" do |
15 | | - let(:subject) { scorm_engine_client.get_app_configuration(includeMetadata: true) } |
| 18 | + let(:client) { scorm_engine_client.get_app_configuration(includeMetadata: true) } |
16 | 19 |
|
17 | 20 | it "is successful" do |
18 | | - expect(subject.success?).to eq true |
| 21 | + expect(client.success?).to eq true |
19 | 22 | end |
20 | 23 |
|
21 | 24 | it "returns metadata in raw_response when included in options" do |
22 | | - expect(subject.raw_response.body["settingItems"].first["metadata"]).to_not be_nil |
| 25 | + expect(client.raw_response.body["settingItems"].first["metadata"]).not_to be_nil |
23 | 26 | end |
24 | 27 | end |
25 | 28 | end |
26 | 29 |
|
27 | 30 | describe "#post_app_configuration" do |
28 | | - let(:subject) { scorm_engine_client } |
| 31 | + let(:client) { scorm_engine_client } |
29 | 32 | let(:response) { |
30 | | - subject.post_app_configuration( |
| 33 | + client.post_app_configuration( |
31 | 34 | settings: { "UserCountReportLookBackDays" => "90", |
32 | 35 | "UserCountReportDaysBetweenReports" => 20 } |
33 | 36 | ) |
|
37 | 40 | expect(response.success?).to eq true |
38 | 41 | end |
39 | 42 |
|
40 | | - it "persists the settings" do |
| 43 | + it "persists the settings, default params" do |
| 44 | + response # trigger the api |
| 45 | + configuration = client.get_app_configuration.result |
| 46 | + aggregate_failures do |
| 47 | + expect(configuration["UserCountReportLookBackDays"]).to eq "90" |
| 48 | + expect(configuration["UserCountReportDaysBetweenReports"]).to eq "20" |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + it "persists the settings, modified params" do |
41 | 53 | response # trigger the api |
42 | | - configuration = subject.get_app_configuration.result |
43 | | - expect(configuration["UserCountReportLookBackDays"]).to eq "90" |
44 | | - expect(configuration["UserCountReportDaysBetweenReports"]).to eq "20" |
45 | 54 |
|
46 | | - subject.post_app_configuration( |
| 55 | + client.post_app_configuration( |
47 | 56 | settings: { "UserCountReportLookBackDays" => "365", |
48 | 57 | "UserCountReportDaysBetweenReports" => 30 } |
49 | 58 | ) |
50 | 59 |
|
51 | 60 | sleep 3 # there seems to be a delay between posting new values and when they're updated frd |
52 | 61 |
|
53 | | - configuration = subject.get_app_configuration.result |
54 | | - expect(configuration["UserCountReportLookBackDays"]).to eq "365" |
55 | | - expect(configuration["UserCountReportDaysBetweenReports"]).to eq "30" |
| 62 | + configuration = client.get_app_configuration.result |
| 63 | + aggregate_failures do |
| 64 | + expect(configuration["UserCountReportLookBackDays"]).to eq "365" |
| 65 | + expect(configuration["UserCountReportDaysBetweenReports"]).to eq "30" |
| 66 | + end |
56 | 67 | end |
57 | 68 |
|
58 | 69 | it "fails when settings are invalid" do |
59 | | - response = subject.post_app_configuration(settings: { "NonExistentSettingTotesBogus" => "YES" }) |
60 | | - expect(response.success?).to eq false |
61 | | - expect(response.status).to eq 400 |
62 | | - expect(response.message).to match(/NonExistentSettingTotesBogus is not a valid setting ID/) |
| 70 | + response = client.post_app_configuration(settings: { "NonExistentSettingTotesBogus" => "YES" }) |
| 71 | + aggregate_failures do |
| 72 | + expect(response.success?).to eq false |
| 73 | + expect(response.status).to eq 400 |
| 74 | + expect(response.message).to match(/NonExistentSettingTotesBogus is not a valid setting ID/) |
| 75 | + end |
63 | 76 | end |
64 | 77 | end |
65 | 78 |
|
66 | 79 | describe "#delete_app_configuration" do |
67 | | - let(:subject) { scorm_engine_client } |
| 80 | + let(:client) { scorm_engine_client } |
68 | 81 | let(:response) { |
69 | | - subject.delete_app_configuration(setting_id: "UserCountReportLookBackDays") |
| 82 | + client.delete_app_configuration(setting_id: "UserCountReportLookBackDays") |
70 | 83 | } |
71 | 84 |
|
72 | 85 | it "is successful" do |
73 | 86 | expect(response.success?).to eq true |
74 | 87 | end |
| 88 | + |
75 | 89 | it "fails when settings are invalid" do |
76 | | - response = subject.delete_app_configuration(setting_id: "NonExistentSettingTotesBogus") |
77 | | - expect(response.success?).to eq false |
78 | | - expect(response.status).to eq 400 |
79 | | - expect(response.message).to match(/NonExistentSettingTotesBogus/) |
| 90 | + response = client.delete_app_configuration(setting_id: "NonExistentSettingTotesBogus") |
| 91 | + aggregate_failures do |
| 92 | + expect(response.success?).to eq false |
| 93 | + expect(response.status).to eq 400 |
| 94 | + expect(response.message).to match(/NonExistentSettingTotesBogus/) |
| 95 | + end |
80 | 96 | end |
81 | 97 | end |
82 | 98 | end |
| 99 | +# rubocop:enable RSpec/ExampleLength |
0 commit comments