|
108 | 108 | end
|
109 | 109 |
|
110 | 110 | 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) { [] } |
111 | 118 | it 'prints a table with the dashboard title and charts' do
|
112 |
| - |
113 | 119 | expect(subject.table.to_s).to eq(
|
114 | 120 | "+-----+------------------+----------+---------------+------------------+--------+-------------+\n" \
|
115 | 121 | "| 1: Test Dashboard |\n" \
|
|
121 | 127 | "+-----+------------------+----------+---------------+------------------+--------+-------------+"
|
122 | 128 | )
|
123 | 129 | 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 |
124 | 176 | end
|
125 | 177 | end
|
0 commit comments