fixed update form

pull/5233/head
Markus Kahl 8 years ago
parent 6cc211cab0
commit 4a295f2a9a
  1. 4
      lib/api/v3/queries/queries_api.rb
  2. 4
      lib/api/v3/queries/update_form_representer.rb
  3. 6
      lib/api/v3/utilities/path_helper.rb
  4. 2
      spec/requests/api/v3/queries/create_form_api_spec.rb
  5. 20
      spec/requests/api/v3/queries/update_form_api_spec.rb

@ -98,8 +98,6 @@ module API
requires :id, desc: 'Query id'
end
route_param :id do
mount API::V3::Queries::UpdateFormAPI
before do
@query = Query.find(params[:id])
@ -108,6 +106,8 @@ module API
end
end
mount API::V3::Queries::UpdateFormAPI
patch do
update_query @query, request_body, current_user
end

@ -30,7 +30,7 @@
module API
module V3
module Queries
class CreateFormRepresenter < FormRepresenter
class UpdateFormRepresenter < FormRepresenter
link :self do
{
href: api_v3_paths.query_form(represented.id),
@ -48,7 +48,7 @@ module API
link :commit do
if allow_commit?
{
href: api_v3_paths.queries(represented.id),
href: api_v3_paths.query(represented.id),
method: :post
}
end

@ -147,10 +147,14 @@ module API
"#{project(id)}/queries/default"
end
def self.query_form
def self.create_query_form
"#{queries}/form"
end
def self.query_form(id)
"#{query(id)}/form"
end
def self.query_star(id)
"#{query(id)}/star"
end

@ -32,7 +32,7 @@ require 'rack/test'
describe "POST /api/v3/queries/form", type: :request do
include API::V3::Utilities::PathHelper
let(:path) { api_v3_paths.query_form }
let(:path) { api_v3_paths.create_query_form }
let(:user) { FactoryGirl.create(:admin) }
let!(:project) { FactoryGirl.create(:project_with_types) }

@ -32,7 +32,7 @@ require 'rack/test'
describe "POST /api/v3/queries/form", type: :request do
include API::V3::Utilities::PathHelper
let(:path) { api_v3_paths.query_form }
let(:path) { api_v3_paths.query_form(query.id) }
let(:user) { FactoryGirl.create(:admin) }
let!(:project) { FactoryGirl.create(:project_with_types) }
let!(:query) { FactoryGirl.create :query, name: "Existing Query", is_public: true }
@ -64,8 +64,6 @@ describe "POST /api/v3/queries/form", type: :request do
describe 'with empty parameters' do
it 'has 0 validation errors' do
require 'pry'; binding.pry
expect(form.dig("_embedded", "validationErrors").size).to eq 0
end
end
@ -219,22 +217,6 @@ describe "POST /api/v3/queries/form", type: :request do
end
end
context "with groupBy specified as a GET parameter" do
let(:path) { api_v3_paths.query_form + "?groupBy=author"}
let(:override_params) do
links = parameters[:_links]
links.delete :groupBy
{ _links: links }
end
it "initializes the form with the given groupBy" do
expect(form.dig("_embedded", "payload", "_links", "groupBy", "href"))
.to eq "/api/v3/queries/group_bys/author"
end
end
context "with an unknown filter" do
let(:override_params) do
filter = parameters[:filters][0]

Loading…
Cancel
Save