demarches-normaliennes/spec/views/admin/procedures/show.html.haml_spec.rb
2019-08-12 13:47:01 +02:00

78 lines
2.5 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require 'spec_helper'
describe 'admin/procedures/show.html.haml', type: :view do
let(:archived_at) { nil }
let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) }
before do
assign(:procedure, procedure)
end
describe 'procedure is draft' do
context 'when procedure does not have a gestionnare affected' do
before do
render
end
describe 'publish button is not visible' do
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') }
end
end
context 'when procedure have a gestionnare affected' do
before do
create :assign_to, instructeur: create(:instructeur), procedure: procedure
render
end
describe 'publish button is visible' do
it { expect(rendered).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') }
end
describe 'procedure path is not customized' do
it { expect(rendered).to have_content('Cette démarche est actuellement en test') }
end
end
end
describe 'procedure is published' do
before do
procedure.publish!(procedure.administrateurs.first, 'fake_path', procedure.lien_site_web)
procedure.reload
render
end
describe 'archive button is visible', js: true do
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') }
end
describe 'procedure link is present' do
it { expect(rendered).to have_content(commencer_url(path: procedure.path)) }
end
end
describe 'procedure is archived' do
before do
procedure.publish!(procedure.administrateurs.first, 'fake_path', procedure.lien_site_web)
procedure.archive!
procedure.reload
render
end
describe 'Re-enable button is visible' do
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') }
end
describe 'procedure link is present' do
it { expect(rendered).to have_content('Cette démarche est archivée et nest donc plus accessible par le public.') }
end
end
end