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 }
|
|
|
|
let(:published) { false }
|
|
|
|
let(:procedure) { create(:procedure, published: published, 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-09 17:49:38 +02:00
|
|
|
let(:published) { true }
|
|
|
|
|
|
|
|
context 'when procedure is published' do
|
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
|
|
|
|
let(:published) { true }
|
|
|
|
it { expect(rendered).to have_content(new_users_dossiers_url(procedure_id: procedure.id)) }
|
|
|
|
end
|
2015-12-04 16:17:35 +01:00
|
|
|
end
|
2015-11-27 17:13:06 +01:00
|
|
|
end
|