adds dossier editing of investments to valuation
This commit is contained in:
@@ -158,4 +158,238 @@ feature 'Valuation budget investments' do
|
||||
expect(page).to have_content("Old idea")
|
||||
end
|
||||
|
||||
feature 'Show' do
|
||||
scenario 'visible for assigned valuators' do
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: administrator)
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
click_link investment.title
|
||||
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content(investment.description)
|
||||
expect(page).to have_content(investment.author.name)
|
||||
expect(page).to have_content(investment.heading.name)
|
||||
expect(page).to have_content('1234')
|
||||
expect(page).to have_content('Unfeasible')
|
||||
expect(page).to have_content('It is impossible')
|
||||
expect(page).to have_content('Ana (ana@admins.org)')
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Rachel (rachel@valuators.org)')
|
||||
expect(page).to have_content('Rick (rick@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'visible for admins' do
|
||||
logout
|
||||
login_as create(:administrator).user
|
||||
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: administrator)
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
visit valuation_budget_budget_investment_path(@budget, investment)
|
||||
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content(investment.description)
|
||||
expect(page).to have_content(investment.author.name)
|
||||
expect(page).to have_content(investment.heading.name)
|
||||
expect(page).to have_content('1234')
|
||||
expect(page).to have_content('Unfeasible')
|
||||
expect(page).to have_content('It is impossible')
|
||||
expect(page).to have_content('Ana (ana@admins.org)')
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Rachel (rachel@valuators.org)')
|
||||
expect(page).to have_content('Rick (rick@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'not visible for not assigned valuators' do
|
||||
logout
|
||||
login_as create(:valuator).user
|
||||
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: create(:administrator))
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
expect { visit valuation_budget_budget_investment_path(@budget, investment) }.to raise_error "Not Found"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature 'Valuate' do
|
||||
background do
|
||||
@investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: nil,
|
||||
administrator: create(:administrator))
|
||||
@investment.valuators << @valuator
|
||||
end
|
||||
|
||||
scenario 'Dossier empty by default' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
click_link @investment.title
|
||||
|
||||
within('#price') { expect(page).to have_content('Undefined') }
|
||||
within('#price_first_year') { expect(page).to have_content('Undefined') }
|
||||
within('#duration') { expect(page).to have_content('Undefined') }
|
||||
within('#feasibility') { expect(page).to have_content('Undecided') }
|
||||
expect(page).to_not have_content('Valuation finished')
|
||||
expect(page).to_not have_content('Internal comments')
|
||||
end
|
||||
|
||||
scenario 'Edit dossier' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
within("#budget_investment_#{@investment.id}") do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in 'budget_investment_price', with: '12345'
|
||||
fill_in 'budget_investment_price_first_year', with: '9876'
|
||||
fill_in 'budget_investment_price_explanation', with: 'Very cheap idea'
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
fill_in 'budget_investment_duration', with: '19 months'
|
||||
fill_in 'budget_investment_internal_comments', with: 'Should be double checked by the urbanism area'
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content "Dossier updated"
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
click_link @investment.title
|
||||
|
||||
within('#price') { expect(page).to have_content('12345') }
|
||||
within('#price_first_year') { expect(page).to have_content('9876') }
|
||||
expect(page).to have_content('Very cheap idea')
|
||||
within('#duration') { expect(page).to have_content('19 months') }
|
||||
within('#feasibility') { expect(page).to have_content('Feasible') }
|
||||
expect(page).to_not have_content('Valuation finished')
|
||||
expect(page).to have_content('Internal comments')
|
||||
expect(page).to have_content('Should be double checked by the urbanism area')
|
||||
end
|
||||
|
||||
scenario 'Feasibility can be marked as pending' do
|
||||
visit valuation_budget_budget_investment_path(@budget, @investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to_not be_checked
|
||||
expect(find "#budget_investment_feasibility_feasible").to be_checked
|
||||
|
||||
choose 'budget_investment_feasibility_undecided'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
end
|
||||
|
||||
scenario 'Feasibility selection makes proper fields visible', :js do
|
||||
feasible_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope']
|
||||
unfeasible_fields = ['Feasibility explanation']
|
||||
any_feasibility_fields = ['Valuation finished','Internal comments']
|
||||
undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
|
||||
undecided_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
|
||||
unfeasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(feasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_unfeasible'
|
||||
|
||||
feasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(unfeasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_unfeasible").to be_checked
|
||||
feasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(unfeasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_undecided'
|
||||
|
||||
undecided_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Finish valuation' do
|
||||
visit valuation_budget_budget_investment_path(@budget, @investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
check 'budget_investment_valuation_finished'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
expect(page).to_not have_content @investment.title
|
||||
click_link 'Valuation finished'
|
||||
|
||||
expect(page).to have_content @investment.title
|
||||
click_link @investment.title
|
||||
expect(page).to have_content('Valuation finished')
|
||||
end
|
||||
|
||||
scenario 'Validates price formats' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
within("#budget_investment_#{@investment.id}") do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in 'budget_investment_price', with: '12345,98'
|
||||
fill_in 'budget_investment_price_first_year', with: '9876.6'
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content('2 errors')
|
||||
expect(page).to have_content('Only integer numbers', count: 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user