Skip to content

Commit

Permalink
issue #117 - expose new Budget.skip_balance attribute in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Oct 19, 2017
1 parent f3a1900 commit d7a0e66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions biweeklybudget/flaskapp/static/js/budgets_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function budgetModalDivForm() {
.addCurrency('budget_frm_current_balance', 'current_balance', 'Current Balance', { groupHtml: 'style="display: none;"' })
.addCheckbox('budget_frm_active', 'is_active', 'Active?', true)
.addCheckbox('budget_frm_income', 'is_income', 'Income?')
.addCheckbox('budget_frm_skip_balance', 'skip_balance', 'Skip Balancing?')
.render();
}

Expand Down Expand Up @@ -100,6 +101,11 @@ function budgetModalDivFillAndShow(msg) {
} else {
$('#budget_frm_income').prop('checked', false);
}
if(msg['skip_balance'] === true) {
$('#budget_frm_skip_balance').prop('checked', true);
} else {
$('#budget_frm_skip_balance').prop('checked', false);
}
$("#modalDiv").modal('show');
}

Expand Down
4 changes: 4 additions & 0 deletions biweeklybudget/flaskapp/views/budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ def submit(self, data):
budget.is_income = True
else:
budget.is_income = False
if data['skip_balance'] == 'true':
budget.skip_balance = True
else:
budget.skip_balance = False
logger.info('%s: %s', action, budget.as_dict)
db_session.add(budget)
db_session.commit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_0_verify_db(self, testdb):
assert b.starting_balance == 100.00
assert b.is_active is True
assert b.is_income is False
assert b.skip_balance is False

def test_1_populate_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
Expand Down Expand Up @@ -140,6 +141,8 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id('budget_frm_active').is_selected()
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False
assert selenium.find_element_by_id(
'budget_frm_skip_balance').is_selected() is False

def test_2_update_modal(self, base_url, selenium):
# Fill in the form
Expand All @@ -159,10 +162,13 @@ def test_2_update_modal(self, base_url, selenium):
sb.clear()
sb.send_keys('2345.67')
selenium.find_element_by_id('budget_frm_active').click()
selenium.find_element_by_id('budget_frm_skip_balance').click()
assert selenium.find_element_by_id(
'budget_frm_active').is_selected() is False
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False
assert selenium.find_element_by_id(
'budget_frm_skip_balance').is_selected() is True
# submit the form
selenium.find_element_by_id('modalSaveButton').click()
self.wait_for_jquery_done(selenium)
Expand Down Expand Up @@ -191,6 +197,7 @@ def test_3_verify_db(self, testdb):
assert float(b.starting_balance) == 2345.6700
assert b.is_active is False
assert b.is_income is False
assert b.skip_balance is True


@pytest.mark.acceptance
Expand Down Expand Up @@ -223,6 +230,8 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id('budget_frm_active').is_selected()
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False
assert selenium.find_element_by_id(
'budget_frm_skip_balance').is_selected() is True


@pytest.mark.acceptance
Expand Down
3 changes: 2 additions & 1 deletion biweeklybudget/tests/fixtures/sampledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def _budgets(self):
name='Periodic2',
is_periodic=True,
description='P2desc',
starting_balance=234
starting_balance=234,
skip_balance=True
),
'Periodic3 Inactive': Budget(
name='Periodic3 Inactive',
Expand Down

0 comments on commit d7a0e66

Please sign in to comment.