dossier: add details résumé
This commit is contained in:
parent
c7ba3cbd59
commit
1b7950058d
8 changed files with 283 additions and 3 deletions
|
@ -0,0 +1,87 @@
|
|||
describe 'new_user/dossiers/show/_status_progress.html.haml', type: :view do
|
||||
subject! { render 'new_user/dossiers/show/status_progress.html.haml', dossier: dossier }
|
||||
|
||||
matcher :have_timeline_item do |selector|
|
||||
match do |rendered|
|
||||
expect(rendered).to have_selector(item_selector(selector))
|
||||
end
|
||||
|
||||
chain :active do
|
||||
@active = true
|
||||
end
|
||||
|
||||
chain :inactive do
|
||||
@active = false
|
||||
end
|
||||
|
||||
def item_selector(selector)
|
||||
item_selector = ".status-timeline #{selector}"
|
||||
item_selector += '.active' if @active == true
|
||||
item_selector += ':not(.active)' if @active == false
|
||||
item_selector
|
||||
end
|
||||
end
|
||||
|
||||
context 'when brouillon' do
|
||||
let(:dossier) { create :dossier }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).to have_timeline_item('.brouillon').active
|
||||
expect(rendered).to have_timeline_item('.en-construction').inactive
|
||||
expect(rendered).to have_timeline_item('.en-instruction').inactive
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .brouillon') }
|
||||
end
|
||||
|
||||
context 'when en construction' do
|
||||
let(:dossier) { create :dossier, :en_construction }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).to have_timeline_item('.brouillon').inactive
|
||||
expect(rendered).to have_timeline_item('.en-construction').active
|
||||
expect(rendered).to have_timeline_item('.en-instruction').inactive
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .en-construction') }
|
||||
end
|
||||
|
||||
context 'when en instruction' do
|
||||
let(:dossier) { create :dossier, :en_instruction }
|
||||
|
||||
it 'renders the timeline (without the final states)' do
|
||||
expect(rendered).to have_timeline_item('.brouillon').inactive
|
||||
expect(rendered).to have_timeline_item('.en-construction').inactive
|
||||
expect(rendered).to have_timeline_item('.en-instruction').active
|
||||
expect(rendered).to have_timeline_item('.termine').inactive
|
||||
end
|
||||
|
||||
it { is_expected.to have_selector('.status-explanation .en-instruction') }
|
||||
end
|
||||
|
||||
context 'when accepté' do
|
||||
let(:dossier) { create :dossier, :accepte, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .accepte') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
end
|
||||
|
||||
context 'when refusé' do
|
||||
let(:dossier) { create :dossier, :refuse, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .refuse') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
end
|
||||
|
||||
context 'when classé sans suite' do
|
||||
let(:dossier) { create :dossier, :sans_suite, :with_motivation }
|
||||
|
||||
it { is_expected.not_to have_selector('.status-timeline') }
|
||||
it { is_expected.to have_selector('.status-explanation .sans-suite') }
|
||||
it { is_expected.to have_text(dossier.motivation) }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue