2021-04-08 12:47:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-12-29 07:31:29 -05:00
|
|
|
require "rails_helper"
|
2021-04-08 12:47:44 -04:00
|
|
|
|
|
|
|
describe "Data explorer group serializer additions" do
|
2022-02-01 15:38:24 -05:00
|
|
|
fab!(:group_user) { Fabricate(:user) }
|
|
|
|
fab!(:other_user) { Fabricate(:user) }
|
2024-02-29 12:15:57 -05:00
|
|
|
fab!(:group)
|
2023-03-22 17:29:08 -04:00
|
|
|
let!(:query) { DiscourseDataExplorer::Query.create!(name: "My query", sql: "") }
|
2021-04-08 12:47:44 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.data_explorer_enabled = true
|
|
|
|
group.add(group_user)
|
2023-03-22 17:29:08 -04:00
|
|
|
DiscourseDataExplorer::QueryGroup.create!(group: group, query: query)
|
2021-04-08 12:47:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "query boolean is true for group user" do
|
|
|
|
sign_in group_user
|
|
|
|
get "/g/#{group.name}.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.parsed_body["group"]["has_visible_data_explorer_queries"]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "query boolean is false for group user when there are no queries" do
|
|
|
|
query.destroy!
|
|
|
|
sign_in group_user
|
|
|
|
get "/g/#{group.name}.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.parsed_body["group"]["has_visible_data_explorer_queries"]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not include query boolean for anon" do
|
|
|
|
get "/g/#{group.name}.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.parsed_body["group"]["has_visible_data_explorer_queries"]).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not include query boolean for non-group user" do
|
|
|
|
sign_in other_user
|
|
|
|
get "/g/#{group.name}.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.parsed_body["group"]["has_visible_data_explorer_queries"]).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|