Schema graph_ql (#8406)
* First draft schema graph_ql * Add tests for json schema procedures
This commit is contained in:
parent
68ddae7382
commit
962016e32e
7 changed files with 79 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
RSpec.describe API::Public::V1::JSONDescriptionProceduresController, type: :controller do
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
describe '#show' do
|
||||
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
||||
subject(:show_request) do
|
||||
get :show, params: params
|
||||
end
|
||||
|
||||
before { show_request }
|
||||
|
||||
context 'the procedure is found' do
|
||||
let(:params) { { path: procedure.path } }
|
||||
let(:expected_response) do
|
||||
API::V2::Schema.execute(API::V2::StoredQuery.get('ds-query-v2'),
|
||||
variables: {
|
||||
demarche: { "number": procedure.id },
|
||||
includeRevision: true
|
||||
},
|
||||
operation_name: "getDemarcheDescriptor")
|
||||
.to_h.dig("data", "demarcheDescriptor").to_json
|
||||
end
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
|
||||
it { expect(response.body).to eq(expected_response) }
|
||||
end
|
||||
|
||||
context "the procedure is not found" do
|
||||
let(:params) { { path: "error" } }
|
||||
|
||||
it { expect(response).to have_http_status(:not_found) }
|
||||
|
||||
it { expect(response).to have_failed_with("procedure error is not found") }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue