demarches-normaliennes/spec/views/admin/procedures/show.html.haml_spec.rb

80 lines
2.4 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe 'admin/procedures/show.html.haml', type: :view do
let(:archived) { false }
let(:procedure) { create(:procedure, archived: archived) }
before do
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
assign(:procedure, procedure)
end
2016-06-30 10:24:01 +02:00
describe 'procedure is draft' do
2016-10-12 14:44:08 +02:00
context 'when procedure does not have a gestionnare affected' do
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
it { expect(rendered).not_to have_css('a#publish') }
it { expect(rendered).not_to have_css('button#archive') }
it { expect(rendered).not_to have_css('a#reenable') }
end
2016-06-30 10:24:01 +02:00
end
2016-10-12 14:44:08 +02:00
context 'when procedure have a gestionnare affected' do
before do
create :assign_to, gestionnaire: create(:gestionnaire), procedure: procedure
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') }
2016-10-12 14:44:08 +02:00
it { expect(rendered).not_to have_css('button#archive') }
it { expect(rendered).not_to have_css('a#reenable') }
end
describe 'procedure link is not present' 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
2016-06-30 10:24:01 +02:00
end
end
2016-06-30 10:24:01 +02:00
describe 'procedure is published' do
before do
2016-07-12 15:20:10 +02:00
procedure.publish!('fake_path')
2016-06-30 10:24:01 +02:00
procedure.reload
render
end
2016-06-30 10:24:01 +02:00
describe 'archive button is visible', js: true do
it { expect(rendered).not_to have_css('a#publish') }
it { expect(rendered).to have_css('button#archive') }
it { expect(rendered).not_to have_css('a#reenable') }
end
2016-06-30 10:24:01 +02:00
describe 'procedure link is present' do
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) }
end
end
2016-06-30 10:24:01 +02:00
describe 'procedure is archived' do
before do
2016-07-12 15:20:10 +02:00
procedure.publish!('fake_path')
2016-06-30 10:24:01 +02:00
procedure.archive
procedure.reload
render
end
2016-06-30 10:24:01 +02:00
describe 'Re-enable button is visible' do
it { expect(rendered).not_to have_css('a#publish') }
it { expect(rendered).not_to have_css('button#archive') }
it { expect(rendered).to have_css('a#reenable') }
end
describe 'procedure link is present' do
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) }
end
end
2017-04-04 15:27:04 +02:00
end