Fix broken spec and linting errors

This commit is contained in:
romanrizzi 2019-09-11 11:52:06 -03:00
parent 30fe9289b8
commit 588391cb2f
3 changed files with 21 additions and 18 deletions

View File

@ -694,7 +694,7 @@ SQL
check_params!
return save_default_query if @id && @id < 0
@id = @id ||self.class.alloc_id
@id = @id || self.class.alloc_id
DataExplorer.pstore_set "q:#{id}", to_hash
end

View File

@ -282,7 +282,7 @@ describe DataExplorer::QueryController do
it "only returns queries that the group has access to" do
group.add(user)
make_query('SELECT 1 as value', {name: 'A'}, ["#{group.id}"])
make_query('SELECT 1 as value', { name: 'A' }, ["#{group.id}"])
get :group_reports_index, params: { group_name: group.name }, format: :json
expect(response.status).to eq(200)
@ -310,7 +310,7 @@ describe DataExplorer::QueryController do
describe "#group_reports_run" do
it "calls run on QueryController" do
query = make_query('SELECT 1 as value', {name: 'B'}, ["#{group.id}"])
query = make_query('SELECT 1 as value', { name: 'B' }, ["#{group.id}"])
controller.expects(:run).at_least_once
get :group_reports_run, params: { group_name: group.name, id: query.id }, format: :json
@ -362,4 +362,3 @@ describe DataExplorer::QueryController do
end
end
end

View File

@ -1,11 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Guardian do
before { SiteSetting.data_explorer_enabled = true }
def make_query(group_ids = [])
q = DataExplorer::Query.new
q.id = Fabrication::Sequencer.sequence("query-id", 1)
q.name ="Query number #{q.id}"
q.name = "Query number #{q.id}"
q.sql = "SELECT 1"
q.group_ids = group_ids
q.save