Skip to content

Commit

Permalink
Adding spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soundarya-mv committed Aug 29, 2024
1 parent 39f62d7 commit c9f5062
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions spec/superset/guest_token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,51 @@
end

describe '#params' do
before do
allow(subject).to receive(:current_user).and_return(user)
end
context "with additional params" do
before do
allow(subject).to receive(:additional_params).and_return(additional_params)
end

context 'without a current_user' do
let(:user) { nil }
context 'without a current_user' do
let(:additional_params) { {} }

specify do
expect(subject.params).to eq(
{
"resources": [
{
"id": ss_dashboard_id,
"type": "dashboard" }
],
"rls": [],
"user": { }
}
)
specify do
expect(subject.params).to eq(
{
"resources": [
{
"id": ss_dashboard_id,
"type": "dashboard" }
],
"rls": [],
"user": { }
}
)
end
end
end

context 'with a current_user' do
let(:user) { double(id: 101) }
context 'with a current_user' do
let(:additional_params) { {embedded_app_current_user_id: 1} }

specify 'passes user id to superset' do
expect(subject.params).to eq(
{
"resources": [
{
"id": ss_dashboard_id,
"type": "dashboard" }
],
"rls": [],
"user": { username: "101" }
}
)
specify 'passes user id to superset' do
expect(subject.params).to eq(
{
"resources": [
{
"id": ss_dashboard_id,
"type": "dashboard" }
],
"rls": [],
"user": { username: additional_params[:embedded_app_current_user_id].to_s },
"embedded_app_current_user_id": additional_params[:embedded_app_current_user_id]
}
)
end
end
end

context 'with rls clause' do
before { allow(subject).to receive(:rls_clause).and_return(rls_clause) }
let(:user) { nil }
let(:rls_clause) { [{ "clause": "publisher = 'Nintendo'" }] }
specify do
expect(subject.params).to eq(
Expand All @@ -95,7 +97,6 @@

context 'with rls clause as empty array' do
before { allow(subject).to receive(:rls_clause).and_return(rls_clause) }
let(:user) { nil }
let(:rls_clause) { [] }
specify do
expect(subject.params).to eq(
Expand Down

0 comments on commit c9f5062

Please sign in to comment.