|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 | 3 | 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) } |
5 | 5 | let(:dashboard_id) { 1 }
|
| 6 | + let(:include_filter_datasets) { false } |
6 | 7 | let(:result) do
|
7 | 8 | [
|
8 | 9 | {
|
|
64 | 65 | {"id"=>102, "datasource_name"=>"video_game_sales", "schema"=>"public", "database"=>{"id"=>2, "name"=>"examples", "backend"=>"postgres"}, "sql"=>"select * from acme_new.forecasts"}
|
65 | 66 | ])
|
66 | 67 | 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 |
67 | 108 | end
|
68 | 109 |
|
69 | 110 | describe '#table' do
|
|
0 commit comments