Add human version translation for state
This commit is contained in:
parent
d87989622c
commit
822c7cdd96
5 changed files with 12 additions and 6 deletions
|
@ -13,7 +13,7 @@ class API::V1::DossiersController < APIController
|
|||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
dossiers = procedure.dossiers.where.not(state: :draft).paginate(page: params[:page])
|
||||
|
||||
render json: {dossiers: dossiers.map{|dossier| DossiersSerializer.new(dossier)}, pagination: pagination(dossiers)}, status: 200
|
||||
render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {}, status: 404
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ class API::V1::DossiersController < APIController
|
|||
dossier = procedure.dossiers.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: {dossier: DossierSerializer.new(dossier).as_json}, status: 200 }
|
||||
format.json { render json: { dossier: DossierSerializer.new(dossier).as_json }, status: 200 }
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {}, status: 404
|
||||
|
|
|
@ -292,5 +292,4 @@ class Dossier < ActiveRecord::Base
|
|||
def serialize_value_for_export(value)
|
||||
value.nil? || value.kind_of?(Time) ? value : value.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,7 +4,8 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
:updated_at,
|
||||
:archived,
|
||||
:mandataire_social,
|
||||
:state
|
||||
:state,
|
||||
:simplified_state
|
||||
|
||||
has_one :entreprise
|
||||
has_one :etablissement
|
||||
|
@ -14,4 +15,8 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
has_many :champs_private
|
||||
has_many :pieces_justificatives
|
||||
has_many :types_de_piece_justificative
|
||||
|
||||
def simplified_state
|
||||
object.decorate.display_state
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
"updated_at": "2008-09-01T08:05:00.000Z",
|
||||
"archived": false,
|
||||
"mandataire_social": false,
|
||||
"state": "updated",
|
||||
"simplified_state": "En construction",
|
||||
"entreprise": {
|
||||
"siren": "440117620",
|
||||
"capital_social": 537100000,
|
||||
|
@ -174,4 +176,4 @@
|
|||
"recorded": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ describe API::V1::DossiersController do
|
|||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state] }
|
||||
let(:field_list) { [:id, :created_at, :updated_at, :archived, :mandataire_social, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state] }
|
||||
subject { body[:dossier] }
|
||||
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
|
|
Loading…
Reference in a new issue