[fix #4181] add service to procedure API
This commit is contained in:
parent
a32ac46492
commit
25596ca2f2
3 changed files with 26 additions and 1 deletions
|
@ -17,6 +17,7 @@ class ProcedureSerializer < ActiveModel::Serializer
|
|||
has_many :types_de_champ, serializer: TypeDeChampSerializer
|
||||
has_many :types_de_champ_private, serializer: TypeDeChampSerializer
|
||||
has_many :types_de_piece_justificative
|
||||
belongs_to :service, serializer: ServiceSerializer
|
||||
|
||||
def archived_at
|
||||
object.archived_at&.in_time_zone('UTC')
|
||||
|
|
9
app/serializers/service_serializer.rb
Normal file
9
app/serializers/service_serializer.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class ServiceSerializer < ActiveModel::Serializer
|
||||
attributes :id, :siret, :email
|
||||
attribute :nom, key: :name
|
||||
attribute :type_organisme, key: :type_organization
|
||||
attribute :organisme, key: :organization
|
||||
attribute :telephone, key: :phone
|
||||
attribute :horaires, key: :schedule
|
||||
attribute :adresse, key: :address
|
||||
end
|
|
@ -25,7 +25,7 @@ describe API::V1::ProceduresController, type: :controller do
|
|||
it { is_expected.to have_http_status(200) }
|
||||
|
||||
describe 'body' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: admin) }
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, administrateur: admin) }
|
||||
let(:response) { get :show, params: { id: procedure.id, token: token } }
|
||||
|
||||
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
|
||||
|
@ -51,6 +51,21 @@ describe API::V1::ProceduresController, type: :controller do
|
|||
it { expect(subject[:order_place]).to eq(champ.order_place) }
|
||||
it { expect(subject[:description]).to eq(champ.description) }
|
||||
end
|
||||
|
||||
describe 'service' do
|
||||
subject { super()[:service] }
|
||||
|
||||
let(:service) { procedure.service }
|
||||
|
||||
it { expect(subject[:id]).to eq(service.id) }
|
||||
it { expect(subject[:email]).to eq(service.email) }
|
||||
it { expect(subject[:name]).to eq(service.nom) }
|
||||
it { expect(subject[:type_organization]).to eq(service.type_organisme) }
|
||||
it { expect(subject[:organization]).to eq(service.organisme) }
|
||||
it { expect(subject[:phone]).to eq(service.telephone) }
|
||||
it { expect(subject[:schedule]).to eq(service.horaires) }
|
||||
it { expect(subject[:address]).to eq(service.adresse) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue