ApplicationHelper#format_price and Budget#formatted_amount has the same
objective and code, but the Budget#formatted_amount method also uses the
currency of the Budget to correctly give currencies format.
By replacing usage of format_price with formatted_amount we can remove
format_price and have a single location for currency format logic.
Why:
The logic to construct the link to a heading (if it exists) is in three
different places, this is a clear candidate for a helper method.
How:
Just checking at the helper method if `assigned_heading` and `budget`
has values and composing the link if so.
Valuators should not be able to edit a finished valuation (only admins
should).
The valuation form is only shown to the valuator if he has that ability
(we've previously modified app/models/abilities/valuator.rb to be able
to rely on `valuate` over an investment to check that)
If the valuator can't see the form, we present him just the data in
plain text.
Why:
Avoid instance variables as we agreed upon with RSpec/InstanceVariable
How:
Using a let(:invsetment) and replacing all `@investment` with
`investment`, as well as adding a let(:admin) for the administrator.
The actual PR template feels more like bureaucracy than an actual guide
or checklist to help the PR author explain all important thigs that any
reviewer or changelog reader may need to understand.
We'll be moving most of the redundant things (like remembering tests are
needed, or explaning how things where implemented with a clear and
granular commit history) into a Wiki/Doc entry.
For regular contributors there is no need for reminders, we need to
improve new contributors landing with good guides and lowering the bar
for first PR's
Why:
Both Newsletters and Email Downloads need the same logic: To extract the
emails from all the users in the segment that have newsletter flag
active, removing all empty email values.
How:
1- UserSegments#user_segment_emails holds that repeated logic and is used
on both Newsletter & EmailDownload.
2- Rename Newsletter#list_of_recipients to list_of_recipient_emails as
it is more descriptive. There is no need to pass entire Users around,
only the emails are needed at Mailer#newsletter method.
3- Cleanup Newsletter#list_of_recipient_emails model spec scenario
Why:
User with an empty email value (nil) should not appear in the recipient
list for a given UserSegment at Newsletters or Email Downloads.
How:
Using Enumerable#compact and Enumerable#select to filter out empty emails
Increasing Email Download feature spec and Newsletter model spec to cover
all possible scenarios including the nil email one.