2015-11-27 17:13:06 +01:00
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe 'admin/procedures/show.html.haml', type: :view do
|
2019-11-14 09:43:45 +01:00
|
|
|
|
let(:closed_at) { nil }
|
|
|
|
|
let(:procedure) { create(:procedure, :with_service, closed_at: closed_at) }
|
2015-11-27 17:13:06 +01:00
|
|
|
|
|
2015-12-04 16:17:35 +01:00
|
|
|
|
before do
|
2016-05-19 10:57:18 +02:00
|
|
|
|
assign(:procedure, procedure)
|
2019-08-13 15:43:23 +02:00
|
|
|
|
assign(:procedure_lien, commencer_url(path: procedure.path))
|
2015-12-04 16:17:35 +01:00
|
|
|
|
end
|
2015-11-27 17:13:06 +01:00
|
|
|
|
|
2016-06-30 10:24:01 +02:00
|
|
|
|
describe 'procedure is draft' do
|
2019-08-21 16:17:02 +02:00
|
|
|
|
context 'when procedure does not have a instructeur affected' do
|
2016-10-12 14:44:08 +02:00
|
|
|
|
before do
|
|
|
|
|
render
|
|
|
|
|
end
|
2016-06-30 10:24:01 +02:00
|
|
|
|
|
2016-10-12 14:44:08 +02:00
|
|
|
|
describe 'publish button is not visible' do
|
2018-08-14 15:17:22 +02:00
|
|
|
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
|
|
|
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
|
|
|
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
2016-10-12 14:44:08 +02:00
|
|
|
|
end
|
2016-06-30 10:24:01 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-08-21 16:17:02 +02:00
|
|
|
|
context 'when procedure have a instructeur affected' do
|
2016-10-12 14:44:08 +02:00
|
|
|
|
before do
|
2019-08-21 16:16:53 +02:00
|
|
|
|
create(:instructeur).assign_to_procedure(procedure)
|
2016-10-12 14:44:08 +02:00
|
|
|
|
render
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'publish button is visible' do
|
2016-12-14 18:53:40 +01:00
|
|
|
|
it { expect(rendered).to have_css('a#publish-procedure') }
|
2018-08-14 15:17:22 +02:00
|
|
|
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
|
|
|
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
2016-10-12 14:44:08 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-03-06 14:42:27 +01:00
|
|
|
|
describe 'procedure path is not customized' do
|
|
|
|
|
it { expect(rendered).to have_content('Cette démarche est actuellement en test') }
|
2016-10-12 14:44:08 +02:00
|
|
|
|
end
|
2016-06-30 10:24:01 +02:00
|
|
|
|
end
|
2016-06-09 17:49:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2016-06-30 10:24:01 +02:00
|
|
|
|
describe 'procedure is published' do
|
2016-06-24 16:41:44 +02:00
|
|
|
|
before do
|
2019-07-30 16:54:43 +02:00
|
|
|
|
procedure.publish!
|
2016-06-30 10:24:01 +02:00
|
|
|
|
procedure.reload
|
2016-06-24 16:41:44 +02:00
|
|
|
|
render
|
|
|
|
|
end
|
2016-06-09 17:49:38 +02:00
|
|
|
|
|
2016-06-30 10:24:01 +02:00
|
|
|
|
describe 'archive button is visible', js: true do
|
2018-08-14 15:17:22 +02:00
|
|
|
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
|
|
|
|
it { expect(rendered).to have_css('button#archive-procedure') }
|
|
|
|
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
2015-11-27 17:13:06 +01:00
|
|
|
|
end
|
|
|
|
|
|
2016-06-30 10:24:01 +02:00
|
|
|
|
describe 'procedure link is present' do
|
2018-10-30 12:00:58 +01:00
|
|
|
|
it { expect(rendered).to have_content(commencer_url(path: procedure.path)) }
|
2015-11-27 17:13:06 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
2015-12-04 16:17:35 +01:00
|
|
|
|
|
2019-11-14 09:43:45 +01:00
|
|
|
|
describe 'procedure is closed' do
|
2016-06-30 10:24:01 +02:00
|
|
|
|
before do
|
2019-07-30 16:54:43 +02:00
|
|
|
|
procedure.publish!
|
2019-11-14 09:43:45 +01:00
|
|
|
|
procedure.close!
|
2016-06-30 10:24:01 +02:00
|
|
|
|
procedure.reload
|
|
|
|
|
render
|
2016-06-09 17:49:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2016-06-30 10:24:01 +02:00
|
|
|
|
describe 'Re-enable button is visible' do
|
2018-08-14 15:17:22 +02:00
|
|
|
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
|
|
|
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
|
|
|
|
it { expect(rendered).to have_css('a#reopen-procedure') }
|
2016-06-24 16:41:44 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-02-21 12:20:18 +01:00
|
|
|
|
describe 'procedure link is present' do
|
2019-11-14 09:43:45 +01:00
|
|
|
|
it { expect(rendered).to have_content('Cette démarche est close et n’est donc plus accessible par le public.') }
|
2016-06-09 17:49:38 +02:00
|
|
|
|
end
|
2015-12-04 16:17:35 +01:00
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
|
end
|