Refactor admin geozones specs
This commit is contained in:
@@ -19,11 +19,9 @@ feature 'Admin geozones' do
|
|||||||
scenario 'Create new geozone' do
|
scenario 'Create new geozone' do
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|
||||||
within('#side_menu') do
|
within('#side_menu') { click_link 'Manage geozones' }
|
||||||
click_link "Manage geozones"
|
|
||||||
end
|
|
||||||
|
|
||||||
click_link "Create geozone"
|
click_link 'Create geozone'
|
||||||
|
|
||||||
fill_in 'geozone_name', with: 'Fancy District'
|
fill_in 'geozone_name', with: 'Fancy District'
|
||||||
fill_in 'geozone_external_code', with: 123
|
fill_in 'geozone_external_code', with: 123
|
||||||
@@ -39,98 +37,100 @@ feature 'Admin geozones' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Edit geozone with no associated elements' do
|
scenario 'Edit geozone with no associated elements' do
|
||||||
target_geozone = create(:geozone, name: 'Edit me!', census_code: '012')
|
geozone = create(:geozone, name: 'Edit me!', census_code: '012')
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") do
|
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||||
click_link "Edit"
|
|
||||||
end
|
|
||||||
|
|
||||||
fill_in 'geozone_name', with: 'New geozone name'
|
fill_in 'geozone_name', with: 'New geozone name'
|
||||||
fill_in 'geozone_census_code', with: '333'
|
fill_in 'geozone_census_code', with: '333'
|
||||||
|
|
||||||
click_button 'Save changes'
|
click_button 'Save changes'
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") do
|
within("#geozone_#{geozone.id}") do
|
||||||
expect(page).to have_content 'New geozone name'
|
expect(page).to have_content 'New geozone name'
|
||||||
expect(page).to have_content '333'
|
expect(page).to have_content '333'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Edit geozone with associated elements' do
|
scenario 'Edit geozone with associated elements' do
|
||||||
target_geozone = create(:geozone, name: 'Edit me!')
|
geozone = create(:geozone, name: 'Edit me!')
|
||||||
proposal = create(:proposal, title: 'Proposal with geozone', geozone: target_geozone)
|
create(:proposal, title: 'Proposal with geozone', geozone: geozone)
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") do
|
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||||
click_link "Edit"
|
|
||||||
end
|
|
||||||
|
|
||||||
fill_in 'geozone_name', with: 'New geozone name'
|
fill_in 'geozone_name', with: 'New geozone name'
|
||||||
|
|
||||||
click_button 'Save changes'
|
click_button 'Save changes'
|
||||||
|
|
||||||
expect(proposal.reload.geozone.name).to eq('New geozone name')
|
within("#geozone_#{geozone.id}") do
|
||||||
|
expect(page).to have_content 'New geozone name'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete geozone with no associated elements' do
|
scenario 'Delete geozone with no associated elements' do
|
||||||
target_geozone = create(:geozone, name: 'Delete me!')
|
geozone = create(:geozone, name: 'Delete me!')
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") { click_link 'Delete' }
|
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||||
|
|
||||||
expect(page).not_to have_content('Delete me!')
|
expect(page).not_to have_content('Delete me!')
|
||||||
expect(Geozone.find_by_id(target_geozone.id)).to be_nil
|
expect(Geozone.where(id: geozone.id)).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete geozone with associated proposal' do
|
scenario 'Delete geozone with associated proposal' do
|
||||||
target_geozone = create(:geozone, name: 'Delete me!')
|
geozone = create(:geozone, name: 'Delete me!')
|
||||||
proposal = create(:proposal, geozone: target_geozone)
|
create(:proposal, geozone: geozone)
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") { click_link 'Delete' }
|
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||||
|
|
||||||
expect(page).to have_content('Delete me!')
|
within("#geozone_#{geozone.id}") do
|
||||||
expect(proposal.reload.geozone).to eq(target_geozone)
|
expect(page).to have_content 'Delete me!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete geozone with associated spending proposal' do
|
scenario 'Delete geozone with associated spending proposal' do
|
||||||
target_geozone = create(:geozone, name: 'Delete me!')
|
geozone = create(:geozone, name: 'Delete me!')
|
||||||
spending_proposal = create(:spending_proposal, geozone: target_geozone)
|
create(:spending_proposal, geozone: geozone)
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") { click_link 'Delete' }
|
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||||
|
|
||||||
expect(page).to have_content('Delete me!')
|
within("#geozone_#{geozone.id}") do
|
||||||
expect(spending_proposal.reload.geozone).to eq(target_geozone)
|
expect(page).to have_content 'Delete me!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete geozone with associated debate' do
|
scenario 'Delete geozone with associated debate' do
|
||||||
target_geozone = create(:geozone, name: 'Delete me!')
|
geozone = create(:geozone, name: 'Delete me!')
|
||||||
debate = create(:debate, geozone: target_geozone)
|
create(:debate, geozone: geozone)
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") { click_link 'Delete' }
|
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||||
|
|
||||||
expect(page).to have_content('Delete me!')
|
within("#geozone_#{geozone.id}") do
|
||||||
expect(debate.reload.geozone).to eq(target_geozone)
|
expect(page).to have_content 'Delete me!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete geozone with associated user' do
|
scenario 'Delete geozone with associated user' do
|
||||||
target_geozone = create(:geozone, name: 'Delete me!')
|
geozone = create(:geozone, name: 'Delete me!')
|
||||||
user = create(:user, geozone: target_geozone)
|
create(:user, geozone: geozone)
|
||||||
|
|
||||||
visit admin_geozones_path
|
visit admin_geozones_path
|
||||||
|
|
||||||
within("#geozone_#{target_geozone.id}") { click_link 'Delete' }
|
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||||
|
|
||||||
expect(page).to have_content('Delete me!')
|
within("#geozone_#{geozone.id}") do
|
||||||
expect(user.reload.geozone).to eq(target_geozone)
|
expect(page).to have_content 'Delete me!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user