9fd38cae5e
System specs have been available since Rails 5.1, and are better integrated with the Rails framework. - Rename `spec/features` to `spec/system` - Rename `feature do` to `describe do` - Configure Capybara for system specs Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
41 lines
1.5 KiB
Ruby
41 lines
1.5 KiB
Ruby
require 'system/admin/procedure_spec_helper'
|
|
|
|
describe 'As an administrateur I wanna clone a procedure', js: true do
|
|
include ProcedureSpecHelper
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
before do
|
|
create(:procedure, :with_service, :with_instructeur,
|
|
aasm_state: :publiee,
|
|
administrateurs: [administrateur],
|
|
libelle: 'libellé de la procédure',
|
|
path: 'libelle-de-la-procedure')
|
|
login_as administrateur.user, scope: :user
|
|
end
|
|
|
|
context 'Cloning a procedure owned by the current admin' do
|
|
scenario do
|
|
visit admin_procedures_path
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
page.all('.procedures-actions-btn').first.click
|
|
page.all('.clone-btn').first.click
|
|
visit admin_procedures_path(statut: "brouillons")
|
|
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-link').click
|
|
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
click_on 'publish'
|
|
|
|
page.refresh
|
|
|
|
visit admin_procedures_path(statut: "archivees")
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
visit admin_procedures_path(statut: "brouillons")
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
|
|
end
|
|
end
|
|
end
|