Skip to content

Commit 13ead7d

Browse files
committed
[NEP-18619]: Rspec fixes
1 parent 159ff20 commit 13ead7d

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

spec/superset/dashboard/datasets/list_spec.rb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require 'spec_helper'
22

33
RSpec.describe Superset::Dashboard::Datasets::List do
4-
subject { described_class.new(dashboard_id) }
4+
subject { described_class.new(dashboard_id: dashboard_id, include_filter_datasets: include_filter_datasets) }
55
let(:dashboard_id) { 1 }
6+
let(:include_filter_datasets) { false }
67
let(:result) do
78
[
89
{
@@ -64,6 +65,46 @@
6465
{"id"=>102, "datasource_name"=>"video_game_sales", "schema"=>"public", "database"=>{"id"=>2, "name"=>"examples", "backend"=>"postgres"}, "sql"=>"select * from acme_new.forecasts"}
6566
])
6667
end
68+
69+
context 'returns both chart and filter datasets when include_filter_datasets is true' do
70+
before do
71+
allow(subject).to receive(:filter_dataset_ids).and_return([103,104])
72+
allow(subject).to receive(:filter_datasets).with([103,104]).and_return(filter_dataset_json)
73+
end
74+
let(:include_filter_datasets) { true }
75+
let(:filter_dataset_json) {
76+
[
77+
{
78+
"id"=>103,
79+
"datasource_name"=>"Filter 1",
80+
"schema"=>"acme",
81+
"database"=>{
82+
"id"=>1,
83+
"name"=>"DB1",
84+
"backend"=>"postgres"
85+
},
86+
"sql"=>"select * from acme.forecasts"
87+
},
88+
{
89+
"id"=>104,
90+
"datasource_name"=>"Filter 2",
91+
"schema"=>"public",
92+
"database"=>{
93+
"id"=>2,
94+
"name"=>"examples",
95+
"backend"=>"postgres"
96+
},
97+
"sql"=>"select * from acme_new.forecasts"
98+
}
99+
]
100+
}
101+
specify do
102+
expect(subject.datasets_details).to eq([
103+
{"id"=>101, "datasource_name"=>"Acme Forecasts", "schema"=>"acme", "database"=>{"id"=>1, "name"=>"DB1", "backend"=>"postgres"}, "sql"=>"select * from acme.forecasts"},
104+
{"id"=>102, "datasource_name"=>"video_game_sales", "schema"=>"public", "database"=>{"id"=>2, "name"=>"examples", "backend"=>"postgres"}, "sql"=>"select * from acme_new.forecasts"}
105+
] + filter_dataset_json)
106+
end
107+
end
67108
end
68109

69110
describe '#table' do

spec/superset/dashboard/get_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'published' => true,
1313
'changed_on_delta_humanized' => '1 day ago',
1414
'charts' => dashboard_charts,
15-
'json_metadata' => { 'key1' => 'value1' }.to_json,
15+
'json_metadata' => { 'native_filter_configuration' => [] }.to_json,
1616
'position_json' => { 'key2' => 'value2' }.to_json,
1717
'url' => '',
1818

@@ -43,6 +43,12 @@
4343
end
4444
end
4545

46+
describe '#filter_configuration' do
47+
it 'returns the filter_configuration' do
48+
expect(subject.filter_configuration).to eq(JSON.parse(dashboard_result['json_metadata'])['native_filter_configuration'])
49+
end
50+
end
51+
4652
describe '#positions' do
4753
it 'returns the parsed positions' do
4854
expect(subject.positions).to eq(JSON.parse(dashboard_result['position_json']))

0 commit comments

Comments
 (0)