Skip to content

Commit 684c64b

Browse files
committed
[NEP-18619]: Rspec fixes
1 parent 2ca3995 commit 684c64b

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

spec/superset/dashboard/datasets/list_spec.rb

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,14 @@
108108
end
109109

110110
describe '#table' do
111+
before do
112+
allow(subject).to receive(:datasets_details).and_return(([
113+
{"id"=>101, "datasource_name"=>"Acme Forecasts", "schema"=>"acme", "database"=>{"id"=>1, "name"=>"DB1", "backend"=>"postgres"}, "sql"=>"select * from acme.forecasts"},
114+
{"id"=>102, "datasource_name"=>"video_game_sales", "schema"=>"public", "database"=>{"id"=>2, "name"=>"examples", "backend"=>"postgres"}, "sql"=>"select * from acme_new.forecasts"}
115+
]+ filter_dataset_json).map(&:with_indifferent_access))
116+
end
117+
let(:filter_dataset_json) { [] }
111118
it 'prints a table with the dashboard title and charts' do
112-
113119
expect(subject.table.to_s).to eq(
114120
"+-----+------------------+----------+---------------+------------------+--------+-------------+\n" \
115121
"| 1: Test Dashboard |\n" \
@@ -121,5 +127,51 @@
121127
"+-----+------------------+----------+---------------+------------------+--------+-------------+"
122128
)
123129
end
130+
131+
context 'prints a table with the dashboard title with chart and filter datasets' do
132+
let(:include_filter_datasets) { true }
133+
let(:filter_dataset_json) {
134+
[
135+
{
136+
"id"=>103,
137+
"datasource_name"=>"Filter 1",
138+
"schema"=>"acme",
139+
"database"=>{
140+
"id"=>1,
141+
"name"=>"DB1",
142+
"backend"=>"postgres"
143+
},
144+
"sql"=>"select * from acme.forecasts",
145+
"filter_only" => true
146+
},
147+
{
148+
"id"=>104,
149+
"datasource_name"=>"Filter 2",
150+
"schema"=>"public",
151+
"database"=>{
152+
"id"=>2,
153+
"name"=>"examples",
154+
"backend"=>"postgres"
155+
},
156+
"sql"=>"select * from acme_new.forecasts",
157+
"filter_only" => true
158+
}
159+
]
160+
}
161+
specify do
162+
expect(subject.table.to_s).to eq(
163+
"+-----+------------------+----------+---------------+------------------+--------+-------------+\n" \
164+
"| 1: Test Dashboard |\n" \
165+
"+-----+------------------+----------+---------------+------------------+--------+-------------+\n" \
166+
"| Id | Datasource name | Database | Database name | Database backend | Schema | Filter only |\n" \
167+
"+-----+------------------+----------+---------------+------------------+--------+-------------+\n" \
168+
"| 101 | Acme Forecasts | 1 | DB1 | postgres | acme | |\n" \
169+
"| 102 | video_game_sales | 2 | examples | postgres | public | |\n" \
170+
"| 103 | Filter 1 | 1 | DB1 | postgres | acme | true |\n" \
171+
"| 104 | Filter 2 | 2 | examples | postgres | public | true |\n" \
172+
"+-----+------------------+----------+---------------+------------------+--------+-------------+"
173+
)
174+
end
175+
end
124176
end
125177
end

0 commit comments

Comments
 (0)