2015-11-27 17:13:06 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'admin/procedures/show.html.haml', type: :view do
|
2016-06-09 17:49:38 +02:00
|
|
|
let(:archived) { false }
|
2016-06-24 16:41:44 +02:00
|
|
|
let(:procedure) { create(:procedure, archived: archived) }
|
2015-11-27 17:13:06 +01:00
|
|
|
|
2015-12-04 16:17:35 +01:00
|
|
|
before do
|
2015-12-24 15:57:03 +01:00
|
|
|
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
|
2016-05-19 10:57:18 +02:00
|
|
|
assign(:procedure, procedure)
|
2015-12-04 16:17:35 +01:00
|
|
|
render
|
|
|
|
end
|
2015-11-27 17:13:06 +01:00
|
|
|
|
2016-06-09 17:49:38 +02:00
|
|
|
describe 'publish button' do
|
|
|
|
it { expect(rendered).to have_content('Publier') }
|
|
|
|
end
|
|
|
|
|
2015-12-04 16:17:35 +01:00
|
|
|
describe 'archive and unarchive button' do
|
2016-06-24 16:41:44 +02:00
|
|
|
before do
|
|
|
|
procedure.publish('fake_path')
|
|
|
|
render
|
|
|
|
end
|
2016-06-09 17:49:38 +02:00
|
|
|
|
|
|
|
context 'when procedure is published' do
|
2016-06-24 16:41:44 +02:00
|
|
|
before do
|
|
|
|
procedure.publish('fake_path')
|
|
|
|
procedure.reload
|
|
|
|
end
|
2015-11-27 17:13:06 +01:00
|
|
|
it { expect(rendered).to have_content('Archiver') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure is archived' do
|
2016-06-09 17:49:38 +02:00
|
|
|
let(:archived) { true }
|
2015-11-30 14:48:37 +01:00
|
|
|
it { expect(rendered).to have_content('Réactiver') }
|
2015-11-27 17:13:06 +01:00
|
|
|
end
|
|
|
|
end
|
2015-12-04 16:17:35 +01:00
|
|
|
|
2016-06-09 17:49:38 +02:00
|
|
|
describe 'procedure link' do
|
|
|
|
|
|
|
|
context 'is not present when not published' do
|
|
|
|
it { expect(rendered).to have_content('Cette procédure n\'a pas encore été publiée et n\'est donc pas accessible par le public.') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'is present when already published' do
|
2016-06-24 16:41:44 +02:00
|
|
|
before do
|
|
|
|
procedure.publish('fake_path')
|
|
|
|
render
|
|
|
|
end
|
|
|
|
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'is not present when archived' do
|
|
|
|
before do
|
|
|
|
procedure.archive
|
|
|
|
render
|
|
|
|
end
|
|
|
|
it { expect(rendered).to have_content('Cette procédure a été archivée et n\'est plus accessible par le public.') }
|
2016-06-09 17:49:38 +02:00
|
|
|
end
|
2015-12-04 16:17:35 +01:00
|
|
|
end
|
2015-11-27 17:13:06 +01:00
|
|
|
end
|