diff --git a/spec/controllers/queries_controller_spec.rb b/spec/controllers/queries_controller_spec.rb index 39fc165..73ef240 100644 --- a/spec/controllers/queries_controller_spec.rb +++ b/spec/controllers/queries_controller_spec.rb @@ -28,27 +28,28 @@ describe DataExplorer::QueryController do SiteSetting.data_explorer_enabled = false end it 'denies every request' do - get :index; expect(response.body).to be_empty # check_xhr fail + get :index + expect(response.body).to be_empty - xhr :get, :index + get :index, format: :json expect(response.status).to eq(404) - xhr :get, :schema + get :schema, format: :json expect(response.status).to eq(404) - xhr :get, :show, id: 3 + get :show, params: { id: 3 }, format: :json expect(response.status).to eq(404) - xhr :post, :create, id: 3 + post :create, params: { id: 3 }, format: :json expect(response.status).to eq(404) - xhr :post, :run, id: 3 + post :run, params: { id: 3 }, format: :json expect(response.status).to eq(404) - xhr :put, :update, id: 3 + put :update, params: { id: 3 }, format: :json expect(response.status).to eq(404) - xhr :delete, :destroy, id: 3 + delete :destroy, params: { id: 3 }, format: :json expect(response.status).to eq(404) end end @@ -56,7 +57,7 @@ describe DataExplorer::QueryController do describe "#index" do it "behaves nicely with no queries" do DataExplorer::Query.destroy_all - xhr :get, :index + get :index, format: :json expect(response).to be_success expect(response_json['queries']).to eq([]) end @@ -65,7 +66,7 @@ describe DataExplorer::QueryController do DataExplorer::Query.destroy_all q1 = make_query q2 = make_query - xhr :get, :index + get :index, format: :json expect(response).to be_success expect(response_json['queries'].length).to eq(2) expect(response_json['queries'][0]['name']).to eq(q1.name) @@ -78,7 +79,7 @@ describe DataExplorer::QueryController do def run_query(id, params = {}) params = Hash[params.map { |a| [a[0], a[1].to_s] }] - xhr :post, :run, id: id, _params: MultiJson.dump(params) + post :run, params: { id: id, _params: MultiJson.dump(params) }, format: :json end it "can run queries" do q = make_query('SELECT 23 as my_value') @@ -87,28 +88,29 @@ describe DataExplorer::QueryController do expect(response_json['success']).to eq(true) expect(response_json['errors']).to eq([]) expect(response_json['columns']).to eq(['my_value']) - expect(response_json['rows']).to eq([['23']]) + expect(response_json['rows']).to eq([[23]]) end it "can process parameters" do - q = make_query <