|
34 | 34 | end
|
35 | 35 |
|
36 | 36 | describe '#params' do
|
37 |
| - before do |
38 |
| - allow(subject).to receive(:current_user).and_return(user) |
39 |
| - end |
| 37 | + context "with additional params" do |
| 38 | + before do |
| 39 | + allow(subject).to receive(:additional_params).and_return(additional_params) |
| 40 | + end |
40 | 41 |
|
41 |
| - context 'without a current_user' do |
42 |
| - let(:user) { nil } |
| 42 | + context 'without a current_user' do |
| 43 | + let(:additional_params) { {} } |
43 | 44 |
|
44 |
| - specify do |
45 |
| - expect(subject.params).to eq( |
46 |
| - { |
47 |
| - "resources": [ |
48 |
| - { |
49 |
| - "id": ss_dashboard_id, |
50 |
| - "type": "dashboard" } |
51 |
| - ], |
52 |
| - "rls": [], |
53 |
| - "user": { } |
54 |
| - } |
55 |
| - ) |
| 45 | + specify do |
| 46 | + expect(subject.params).to eq( |
| 47 | + { |
| 48 | + "resources": [ |
| 49 | + { |
| 50 | + "id": ss_dashboard_id, |
| 51 | + "type": "dashboard" } |
| 52 | + ], |
| 53 | + "rls": [], |
| 54 | + "user": { } |
| 55 | + } |
| 56 | + ) |
| 57 | + end |
56 | 58 | end
|
57 |
| - end |
58 | 59 |
|
59 |
| - context 'with a current_user' do |
60 |
| - let(:user) { double(id: 101) } |
| 60 | + context 'with a current_user' do |
| 61 | + let(:additional_params) { {embedded_app_current_user_id: 1} } |
61 | 62 |
|
62 |
| - specify 'passes user id to superset' do |
63 |
| - expect(subject.params).to eq( |
64 |
| - { |
65 |
| - "resources": [ |
66 |
| - { |
67 |
| - "id": ss_dashboard_id, |
68 |
| - "type": "dashboard" } |
69 |
| - ], |
70 |
| - "rls": [], |
71 |
| - "user": { username: "101" } |
72 |
| - } |
73 |
| - ) |
| 63 | + specify 'passes user id to superset' do |
| 64 | + expect(subject.params).to eq( |
| 65 | + { |
| 66 | + "resources": [ |
| 67 | + { |
| 68 | + "id": ss_dashboard_id, |
| 69 | + "type": "dashboard" } |
| 70 | + ], |
| 71 | + "rls": [], |
| 72 | + "user": { username: additional_params[:embedded_app_current_user_id].to_s }, |
| 73 | + "embedded_app_current_user_id": additional_params[:embedded_app_current_user_id] |
| 74 | + } |
| 75 | + ) |
| 76 | + end |
74 | 77 | end
|
75 | 78 | end
|
76 | 79 |
|
77 | 80 | context 'with rls clause' do
|
78 | 81 | before { allow(subject).to receive(:rls_clause).and_return(rls_clause) }
|
79 |
| - let(:user) { nil } |
80 | 82 | let(:rls_clause) { [{ "clause": "publisher = 'Nintendo'" }] }
|
81 | 83 | specify do
|
82 | 84 | expect(subject.params).to eq(
|
|
95 | 97 |
|
96 | 98 | context 'with rls clause as empty array' do
|
97 | 99 | before { allow(subject).to receive(:rls_clause).and_return(rls_clause) }
|
98 |
| - let(:user) { nil } |
99 | 100 | let(:rls_clause) { [] }
|
100 | 101 | specify do
|
101 | 102 | expect(subject.params).to eq(
|
|
0 commit comments