diff --git a/spec/features/admin/budget_phases_spec.rb b/spec/features/admin/budget_phases_spec.rb new file mode 100644 index 000000000..3395c1e68 --- /dev/null +++ b/spec/features/admin/budget_phases_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +feature 'Admin budget phases' do + let(:budget) { create(:budget) } + + context 'Edit' do + + before :each do + admin = create(:administrator) + login_as(admin.user) + end + + scenario 'Update phase' do + visit edit_admin_budget_budget_phase_path(budget, budget.current_phase) + + fill_in 'start_date', with: DateTime.current + 1.days + fill_in 'end_date', with: DateTime.current + 12.days + fill_in 'budget_phase_summary', with: 'This is the summary of the phase.' + fill_in 'budget_phase_description', with: 'This is the description of the phase.' + uncheck 'budget_phase_enabled' + click_button 'Save changes' + + expect(page).to have_current_path(edit_admin_budget_path(budget)) + expect(page).to have_content 'Changes saved' + + expect(budget.current_phase.starts_at.to_date).to eq((DateTime.current + 1.days).to_date) + expect(budget.current_phase.ends_at.to_date).to eq((DateTime.current + 12.days).to_date) + expect(budget.current_phase.summary).to eq('This is the summary of the phase.') + expect(budget.current_phase.description).to eq('This is the description of the phase.') + expect(budget.current_phase.enabled).to be(false) + end + end +end diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 7b41715fe..f07fd7096 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -90,7 +90,6 @@ feature 'Admin budgets' do click_link 'Create new budget' fill_in 'budget_name', with: 'M30 - Summer campaign' - fill_in 'budget_description_accepting', with: 'Budgeting for summer 2017 maintenance and improvements of the road M-30' select 'Accepting projects', from: 'budget[phase]' click_button 'Create Participatory budget' @@ -134,7 +133,29 @@ feature 'Admin budgets' do expect(page).to have_content('There is 1 participatory budget') end end - + + context 'Edit' do + let!(:budget) { create(:budget) } + + scenario 'Show phases table' do + visit admin_budgets_path + click_link 'Edit budget' + + within '#budget-phases-table' do + budget.phases.each do |phase| + within "#budget_phase_#{phase.id}" do + expect(page).to have_content(I18n.t("budgets.phase.#{phase.kind}")) + expect(page).to have_content("#{phase.starts_at.to_date} - #{phase.ends_at.to_date}") + expect(page).to have_css('.budget-phase-enabled.enabled') + expect(page).to have_link('Edit phase', href: edit_admin_budget_budget_phase_path(budget, phase)) + + expect(page).to have_content('Active') if budget.current_phase == phase + end + end + end + end + end + context 'Update' do background do