Merge pull request #1546 from consul/no-money-error

Fix no money error
This commit is contained in:
Alberto
2017-05-17 17:36:20 +02:00
committed by GitHub
3 changed files with 26 additions and 6 deletions

View File

@@ -18,9 +18,7 @@ module Budgets
load_investment
load_heading
unless @ballot.add_investment(@investment)
head :bad_request
end
@ballot.add_investment(@investment)
end
def destroy
@@ -29,7 +27,6 @@ module Budgets
@line.destroy
load_investments
#@ballot.reset_geozone
end
private

View File

@@ -9,7 +9,7 @@ class Budget
has_many :headings, -> { uniq }, through: :groups
def add_investment(investment)
lines.create!(investment: investment)
lines.create(investment: investment).persisted?
end
def total_amount_spent

View File

@@ -592,7 +592,7 @@ feature 'Ballots' do
end
end
scenario 'Insufficient functs (removed after destroying from sidebar)', :js do
scenario 'Insufficient funds (removed after destroying from sidebar)', :js do
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
bi2 = create(:budget_investment, :selected, heading: california, price: 500)
@@ -621,6 +621,29 @@ feature 'Ballots' do
end
end
scenario "Edge case voting a non-elegible investment", :js do
investment1 = create(:budget_investment, :selected, heading: new_york, price: 10000)
login_as(user)
visit budget_path(budget)
click_link "States"
click_link "New York"
new_york.update(price: 10)
within("#budget_investment_#{investment1.id}") do
expect(page).to have_selector('.in-favor a', visible: true)
find('.add a').trigger('click')
expect(page.status_code).to eq(200)
expect(page).to_not have_content "Remove"
expect(page).to have_selector('.participation-not-allowed', visible: false)
find("div.ballot").hover
expect(page).to have_selector('.participation-not-allowed', visible: true)
expect(page).to have_selector('.in-favor a', visible: false)
end
end
scenario "Balloting is disabled when budget isn't in the balotting phase", :js do
budget.update(phase: 'accepting')