mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
This allows us to run the specs separately to generate the documentation. It's more efficient this way and the separate swagger doc file is easier to read. The engine-specific swagger helper also allows us to simplify the spec files. Added an exception to our styleguide because it's intended and useful to have a complete (lengthy) description of the API in one block.
35 lines
885 B
Ruby
35 lines
885 B
Ruby
# frozen_string_literal: true
|
|
|
|
require DfcProvider::Engine.root.join("spec/swagger_helper")
|
|
|
|
describe "Persons", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml", rswag_autodoc: true do
|
|
let(:user) { create(:oidc_user, id: 10_000) }
|
|
let(:other_user) { create(:oidc_user) }
|
|
|
|
before { login_as user }
|
|
|
|
path "/api/dfc-v1.7/persons/{id}" do
|
|
get "Show person" do
|
|
parameter name: :id, in: :path, type: :string
|
|
produces "application/json"
|
|
|
|
response "200", "successful" do
|
|
let(:id) { user.id }
|
|
|
|
run_test! do
|
|
expect(response.body).to include "dfc-b:Person"
|
|
expect(response.body).to include "persons/10000"
|
|
end
|
|
end
|
|
|
|
response "404", "not found" do
|
|
let(:id) { other_user.id }
|
|
|
|
run_test! do
|
|
expect(response.body).to_not include "dfc-b:Person"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|