Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly show finished budgets at budget index #2369

Merged
merged 8 commits into from Jan 30, 2018

Conversation

bertocq
Copy link
Collaborator

@bertocq bertocq commented Jan 23, 2018

What

Currently we're showing all budgets at the "Finished Budgets" section of the Budget's index page. That's not right, only finished ones should be listed there!

How

As a bonus: renaming @Budget usage to @current_budget for extra descriptive variable name 547970e

Screenshots

If you run rake db:dev_seeds you'll be able to see both finished budgets listed, but not the accepting one:

screen shot 2018-01-24 at 00 44 55

Test

  • I started by refactoring the budget feature spec as we're no longer listing all budget's but only finished ones fe90ecb

  • Then added expectations to see the finished budget at the list but not the current or drafting ones 4e854c0

  • Removed Drafting budget scenarios no longer valid b24bb2d

  • And finally made rubocop 🤖 smile by making the file 100 linelength compliant 59e5854

Deployment

As usual

Warnings

Maybe too much refactoring for just 4 lines of code, right? But I'm doing the boyscout here and cleaning as I pass by... Should we start doing separate-but-related PR's to make important changes easier to read? I tried to with the commit history and PR description 🙇

@@ -7,9 +7,9 @@
<div class="row" data-equalizer data-equalizer-on="medium">
<div class="small-12 medium-9 column padding" data-equalizer-watch>

<h1><%= @budget.name %></h1>
<h1><%= current_budget.name %></h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some instance variables @current_budget 😱

Copy link
Contributor

@MariaCheca MariaCheca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the comment I left 👍

Budget's home page has changed, no longer we'll be showing a list of
active budgets, but only one current (open) budget and a list of
finished ones.

So no need to create 3 budgets in a row, but a finished budget (because
we already have a valid budget created)
@bertocq bertocq force-pushed the fix_finished_budgets_list branch 2 times, most recently from bc53862 to 075e2ef Compare January 24, 2018 22:41
But only finished budgets should be listed here, not drafting ones,
neither current ones.
Drafting budgets will no longer be listed under any conditions at the
budget index... not even as "current" budget.
We only need finished budget's at budget's index "Finished budgets"
section. So we add the `finished` scope to @budgets variable, and rename
it so its clear what it contains.

Also avoid showing the "Finished budgets" section if there is none
Clear instance variable names help understand what's going around when
you're deep 2 or 3 partials. In this case @Budget is only used to carry
around the current_budget so @current_budget is more descriptive.

Using `current_budget` directly around would be an alternative, but
maybe not as maintainable in case we want to change which budget is
being shown (for example the drafting one if you're admin).
@bertocq bertocq merged commit dab1562 into master Jan 30, 2018
@bertocq bertocq deleted the fix_finished_budgets_list branch January 30, 2018 01:25
clairezed pushed a commit to CDJ11/CDJ that referenced this pull request Jun 26, 2018
…ets_list

Correctly show finished budgets at budget index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants