demarches-normaliennes/spec/features/admin/procedure_cloning_spec.rb

45 lines
1.5 KiB
Ruby
Raw Normal View History

2018-05-23 23:32:49 +02:00
require 'features/admin/procedure_spec_helper'
2016-12-26 10:56:48 +01:00
feature 'As an administrateur I wanna clone a procedure', js: true do
2018-05-23 23:32:49 +02:00
include ProcedureSpecHelper
2016-12-26 10:56:48 +01:00
let(:administrateur) { create(:administrateur) }
before do
create :procedure, :with_service,
aasm_state: :publiee, published_at: Time.zone.now,
administrateurs: [administrateur],
libelle: 'libellé de la procédure',
path: 'libelle-de-la-procedure'
2019-08-09 10:46:39 +02:00
login_as administrateur.user, scope: :user
2016-12-26 10:56:48 +01:00
end
context 'Cloning a procedure owned by the current admin' do
scenario do
visit admin_procedures_path
2016-12-26 10:56:48 +01:00
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
page.all('.clone-btn').first.click
visit admin_procedures_draft_path
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
click_on Procedure.last.libelle
expect(page).to have_current_path(admin_procedure_path(Procedure.last))
find('#publish-procedure').click
within '#publish-modal' do
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'
2019-12-04 15:45:06 +01:00
expect(page).to have_text('ancienne sera dépubliée')
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'publish'
end
page.refresh
visit admin_procedures_archived_path
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
visit admin_procedures_draft_path
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
2016-12-26 10:56:48 +01:00
end
end
end