Refactor publish dialog

This commit is contained in:
Paul Chavard 2018-08-14 15:17:22 +02:00 committed by Pierre de La Morinerie
parent 559984c351
commit b57c22cafe
13 changed files with 90 additions and 72 deletions

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'admin/procedures/show.html.haml', type: :view do
let(:archived_at) { nil }
let(:procedure) { create(:procedure, archived_at: archived_at) }
let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) }
before do
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
@ -16,9 +16,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
end
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') }
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
@ -30,12 +30,12 @@ describe 'admin/procedures/show.html.haml', type: :view do
describe 'publish button is visible' do
it { expect(rendered).to have_css('a#publish-procedure') }
it { expect(rendered).not_to have_css('button#archive') }
it { expect(rendered).not_to have_css('a#reenable') }
it { expect(rendered).not_to have_css('button#archive-procedure') }
it { expect(rendered).not_to have_css('a#reopen-procedure') }
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.') }
it { expect(rendered).to have_content('Cette procédure na pas encore de lien, et nest donc pas accessible par le public.') }
end
end
end
@ -48,9 +48,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
end
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') }
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
@ -67,13 +67,13 @@ describe 'admin/procedures/show.html.haml', type: :view do
end
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') }
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(commencer_url(procedure_path: procedure.path)) }
it { expect(rendered).to have_content('Cette procédure est archivée et nest donc pas accessible par le public.') }
end
end
end