|
6 | 6 |
|
7 | 7 | describe '.perform' do
|
8 | 8 | context "Dataset count is not considered" do
|
9 |
| - let(:response) { nil } |
10 |
| - before do |
11 |
| - allow(subject).to receive(:response).and_return(response) |
12 |
| - end |
13 |
| - context 'when dashboard_id is not present' do |
14 |
| - let(:dashboard_id) { nil } |
15 |
| - |
16 |
| - it 'raises an error' do |
17 |
| - expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer") |
18 |
| - end |
19 |
| - end |
20 |
| - |
21 |
| - context 'when dashboard_id is not an integer' do |
22 |
| - let(:dashboard_id) { 'string' } |
23 |
| - |
24 |
| - it 'raises an error' do |
25 |
| - expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer") |
26 |
| - end |
27 |
| - end |
28 |
| - |
29 |
| - context 'when dashboard_id is an integer' do |
30 |
| - let(:response) { 'Dashboard warmed up' } |
31 |
| - |
32 |
| - it 'warms up the dashboard' do |
33 |
| - expect(subject.perform).to eq response |
34 |
| - end |
35 |
| - end |
| 9 | + let(:response) { nil } |
| 10 | + before do |
| 11 | + allow(subject).to receive(:response).and_return(response) |
| 12 | + end |
| 13 | + context 'when dashboard_id is not present' do |
| 14 | + let(:dashboard_id) { nil } |
| 15 | + |
| 16 | + it 'raises an error' do |
| 17 | + expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer") |
| 18 | + end |
| 19 | + end |
| 20 | + |
| 21 | + context 'when dashboard_id is not an integer' do |
| 22 | + let(:dashboard_id) { 'string' } |
| 23 | + |
| 24 | + it 'raises an error' do |
| 25 | + expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer") |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + context 'when dashboard_id is an integer' do |
| 30 | + let(:response) { 'Dashboard warmed up' } |
| 31 | + |
| 32 | + it 'warms up the dashboard' do |
| 33 | + expect(subject.perform).to eq response |
| 34 | + end |
| 35 | + end |
36 | 36 | end
|
37 | 37 |
|
38 | 38 | context 'when dashboard has multiple datasets' do
|
39 |
| - let(:dataset_details) do |
40 |
| - [ |
41 |
| - {"name"=>"client database 1", "datasource_name"=>"datasource 101"}, |
42 |
| - {"name"=>"client database 2", "datasource_name"=>"datasource 102"}, |
43 |
| - ] |
44 |
| - end |
45 |
| - let(:api_response) { "Dataset warmed up" } |
46 |
| - before do |
47 |
| - allow(subject).to receive(:fetch_dataset_details).with(dashboard_id) { dataset_details } |
48 |
| - allow(subject).to receive(:api_response).and_return(api_response) |
49 |
| - end |
50 |
| - it 'warms up all the datasets' do |
51 |
| - subject.response |
52 |
| - expect(subject).to have_received(:api_response).exactly(dataset_details.count).times |
53 |
| - end |
| 39 | + let(:dataset_details) do |
| 40 | + [ |
| 41 | + {"name"=>"client database 1", "datasource_name"=>"datasource 101"}, |
| 42 | + {"name"=>"client database 2", "datasource_name"=>"datasource 102"}, |
| 43 | + ] |
| 44 | + end |
| 45 | + let(:api_response) { "Dataset warmed up" } |
| 46 | + before do |
| 47 | + allow(subject).to receive(:fetch_dataset_details).with(dashboard_id) { dataset_details } |
| 48 | + allow(subject).to receive(:api_response).and_return(api_response) |
| 49 | + end |
| 50 | + it 'warms up all the datasets' do |
| 51 | + subject.response |
| 52 | + expect(subject).to have_received(:api_response).exactly(dataset_details.count).times |
| 53 | + end |
54 | 54 | end
|
55 | 55 | end
|
56 | 56 | end
|
0 commit comments