Test la méthode parsed_latest_zone_labels
This commit is contained in:
parent
7281f3ec1a
commit
db0b32a99a
1 changed files with 17 additions and 0 deletions
|
@ -91,6 +91,10 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
let!(:draft_procedure) { create(:procedure) }
|
||||
let!(:published_procedure) { create(:procedure_with_dossiers, :published, dossiers_count: 2) }
|
||||
let!(:closed_procedure) { create(:procedure, :closed) }
|
||||
let!(:procedure_detail_draft) { ProcedureDetail.new(id: draft_procedure.id, latest_zone_labels: '{ "zone1", "zone2" }') }
|
||||
let!(:procedure_detail_published) { ProcedureDetail.new(id: published_procedure.id, latest_zone_labels: '{ "zone3", "zone4" }') }
|
||||
let!(:procedure_detail_closed) { ProcedureDetail.new(id: closed_procedure.id, latest_zone_labels: '{ "zone5", "zone6" }') }
|
||||
|
||||
subject { get :all }
|
||||
|
||||
it { expect(subject.status).to eq(200) }
|
||||
|
@ -116,6 +120,19 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
expect(assigns(:procedures).any? { |p| p.id == draft_procedure.id }).to be_falsey
|
||||
end
|
||||
|
||||
context 'with parsed latest zone labels' do
|
||||
it 'parses the latest zone labels correctly' do
|
||||
expect(procedure_detail_draft.parsed_latest_zone_labels).to eq(["zone1", "zone2"])
|
||||
expect(procedure_detail_published.parsed_latest_zone_labels).to eq(["zone3", "zone4"])
|
||||
expect(procedure_detail_closed.parsed_latest_zone_labels).to eq(["zone5", "zone6"])
|
||||
end
|
||||
|
||||
it 'returns an empty array for invalid JSON' do
|
||||
procedure_detail_draft.latest_zone_labels = '{ invalid json }'
|
||||
expect(procedure_detail_draft.parsed_latest_zone_labels).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
context 'for default admin zones' do
|
||||
let(:zone1) { create(:zone) }
|
||||
let(:zone2) { create(:zone) }
|
||||
|
|
Loading…
Reference in a new issue