|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 | 3 | RSpec.describe Superset::Dashboard::Embedded::Put, type: :service do
|
4 |
| - subject { described_class.new(dashboard_id: dashboard_id, embedded_domain: allowed_domain) } |
| 4 | + subject { described_class.new(dashboard_id: dashboard_id, allowed_domains: allowed_domains) } |
5 | 5 | let(:dashboard_id) { 1 }
|
6 | 6 |
|
7 | 7 | describe 'with a dashboard that has embedded settings, ie has a result' do
|
8 |
| - let(:allowed_domain) { ['http://test-domain.io/'] } |
| 8 | + let(:allowed_domains) { ['http://test-domain.io/'] } |
9 | 9 | let(:uuid) { '631bxxxx-xxxx-xxxx-xxxx-xxxxxxxxx247' }
|
10 | 10 | let(:response) do
|
11 | 11 | {
|
12 | 12 | 'result' =>
|
13 | 13 | {
|
14 |
| - "allowed_domains" => allowed_domain, |
| 14 | + "allowed_domains" => allowed_domains, |
15 | 15 | "changed_by"=>{"first_name"=>"Jay", "id"=>9, "last_name"=>"Bee", "username"=>"4bf....3f5"},
|
16 | 16 | "changed_on" => "2023-10-30T03:06:51.437527",
|
17 | 17 | "dashboard_id" => "1",
|
|
20 | 20 | }.with_indifferent_access
|
21 | 21 | end
|
22 | 22 |
|
23 |
| - before do |
24 |
| - allow(subject).to receive(:response).and_return(response) |
| 23 | + context 'with params' do |
| 24 | + before { allow(subject).to receive(:response).and_return(response) } |
| 25 | + |
| 26 | + context 'that are valid' do |
| 27 | + it 'returns uuid' do |
| 28 | + expect(subject.uuid).to eq(uuid) |
| 29 | + end |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + context 'where allowed_domains is not an array' do |
| 34 | + let(:allowed_domains) { 'http://test-domain.io/' } |
| 35 | + |
| 36 | + before { allow(subject).to receive(:response).and_call_original } |
| 37 | + |
| 38 | + it 'raises error' do |
| 39 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, "allowed_domains array is required") |
| 40 | + end |
25 | 41 | end
|
26 | 42 |
|
27 |
| - describe '#uuid' do |
28 |
| - it 'returns uuid' do |
29 |
| - expect(subject.uuid).to eq(uuid) |
| 43 | + context 'where allowed_domains is nil' do |
| 44 | + let(:allowed_domains) { nil } |
| 45 | + |
| 46 | + before { allow(subject).to receive(:response).and_call_original } |
| 47 | + |
| 48 | + it 'raises error' do |
| 49 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, "allowed_domains array is required") |
| 50 | + end |
| 51 | + end |
| 52 | + |
| 53 | + context 'where dashboard_id is nil' do |
| 54 | + let(:dashboard_id) { nil } |
| 55 | + |
| 56 | + before { allow(subject).to receive(:response).and_call_original } |
| 57 | + |
| 58 | + it 'raises error' do |
| 59 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id integer is required") |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + context 'where dashboard_id is not an int' do |
| 64 | + let(:dashboard_id) { 'asdf' } |
| 65 | + |
| 66 | + before { allow(subject).to receive(:response).and_call_original } |
| 67 | + |
| 68 | + it 'raises error' do |
| 69 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id integer is required") |
30 | 70 | end
|
31 | 71 | end
|
32 | 72 | end
|
|
0 commit comments