Commit Graph

987 Commits

Author SHA1 Message Date
rgarcia
5c6eaa76ff Add headings_voted_by_user
This method was used only in Madrid’s fork, but it is now needed to
complete the backport for voting in multiple headings

There wasn’t a test in Madrid, so here goes one too. Even though, the
responsibility should probably be moved soon to the `Budget::Heading`.
For consistency with the related methods and tests it has been left in
the investment_spec
2018-03-22 22:24:58 +01:00
rgarcia
bdffb9765e Allow voting in multiple headings
Now that we have the option of voting in multiple headings per group,
the method of voting in a “different heading assigned” has become
deprecated and thus removed
2018-03-22 22:24:58 +01:00
Alberto García
eba4a3c6cb Merge pull request #2528 from consul/budgets-message
Heading link on budgets message
2018-03-09 13:25:39 +01:00
Alberto Calderón Queimadelos
a55218ad9f Merge pull request #2443 from consul/fix_currency_locale
Use user locale instead of default locale to format currencies
2018-03-08 18:03:52 +01:00
decabeza
0e9190bc43 Adds heading link on different heading message 2018-03-08 11:50:09 +01:00
Bertocq
f0dc2a02a5 Add Budget#formatted_amount unit test 2018-03-08 11:42:22 +01:00
Bertocq
1ef2789640 Trim valuator investment valuation ability scope
Valuators shouldn't be able to valuate an investment which valuation has
already been finished (only admins can)
2018-03-06 20:18:05 +01:00
Bertocq
6b41b6487b Add UserSegments#user_segment_emails helper method
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
2018-03-01 20:59:20 +01:00
Bertocq
99851e9588 Remove empty emails from users segments recipients
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.
2018-03-01 20:09:32 +01:00
Bertocq
c3a3e76304 Improve newsletter model spec list_of_recipients 2018-02-22 18:24:36 +01:00
Bertocq
e3eeca4f06 Improve newsletter model spec with valid_segment_recipient? 2018-02-22 18:24:18 +01:00
Bertocq
bdbb32e824 Move newsletter User scope outside UserSegments
Why:

UserSegments are not only used for Newsletters or Email downloads, but
also for internal Global Notifications. We don't want to have that scope
hardcoded inside UserSegments as users that have opted-out from the
newsletter should still be recipients of global notifications.

How:

Removing the scope from the UserSegments `all_users` method that acts as
base for all the other segments. Including that `newsletter` scope only
on the places that is relevant:
* When listing recipients for a newsletter
* When downloading a listing emails that can be newsletter recipients

Also updated relevant tests
2018-02-21 11:45:38 +01:00
María Checa
e8c797766a Added newsletter specs 2018-02-14 16:06:33 +01:00
Bertocq
198ff0cd1f Use updatable slug factory trait to sluggable concern
Slugs should only be updated on certain conditions, we need a trait that
meets that conditions and the name of the trait passed as a mandatory &
named argument on the sluggable concern
2018-02-04 23:04:48 +01:00
Bertocq
2eab6a476e Refactor sluggable concern spec 2018-02-04 22:36:23 +01:00
Bertocq
24b1e64113 Validate MapLocation lat/long/zoom have numeric values 2018-02-02 21:37:50 +01:00
Bertocq
6f87f4b07c Correctly check map location attr presence validations 2018-02-02 21:37:05 +01:00
BertoCQ
59b600dd1a Merge pull request #2390 from wairbut-m2c/aperez-user-permissions-specs
Add specs to check users permissions to delete images & documents
2018-02-02 19:42:27 +01:00
BertoCQ
38b66e8c6c Merge pull request #2295 from wairbut-m2c/aperez-mappable-objects
Improvements for Mappable objects
2018-02-02 19:26:47 +01:00
Bertocq
56fc5c9583 Filter internal valuation comments from public api
Why:

Internal valuation comments are only for admins and valuators,
not for the public view.

How:

Adding a `not_valuations` scope and use it at the `public_for_api` one
2018-01-30 19:22:27 +01:00
Bertocq
093b191f16 Small rubocop autocorrections 2018-01-30 03:07:52 +01:00
Angel Perez
665a5b57ab Empty instances of MapLocation won't result in a new DB record (#2220) 2018-01-26 09:26:48 -04:00
Angel Perez
88a5e8b1d2 Spec: Admins/users can destroy only their authored documentables/imageables (#2375) 2018-01-26 09:10:58 -04:00
Bertocq
43c8506f84 Remove deprecated expecations about admin image&doc destroyal 2018-01-24 21:42:20 +01:00
iagirre
c37496601c Budget and phases specs updated (model specs) to include the new 'Information' phase 2018-01-23 15:42:01 +01:00
Raúl Fuentes
93268fc5d6 changed advanced filter from budgets to budgets/investments 2018-01-22 09:59:09 +01:00
Bertocq
8b469c5d98 Fix conflicts with merged branch, Budget::PHASES have moved, and described_class usage is a must 2018-01-16 18:44:21 +01:00
BertoCQ
d44db9cec4 Merge branch 'master' into feature/budget_phases 2018-01-16 17:47:47 +01:00
Bertocq
313d8d2e11 Adjust date ranges of prev/next phases when enabling/disabling a Budget::Phase, with model specs 2018-01-16 15:20:18 +01:00
Bertocq
601351d160 Validate next/prev phases before saving a Budget::Phase, with model specs 2018-01-16 15:20:17 +01:00
Bertocq
d505cda949 Add description sanitization to Budget::Phase with model specs 2018-01-16 12:18:13 +01:00
Bertocq
21b62106e5 Add next/prev enabled phase helper functions to Budget::Phase with model specs 2018-01-16 12:18:13 +01:00
Bertocq
59fb0b562c Create all Phases after a Budget creation 2018-01-16 12:18:13 +01:00
Bertocq
ca3d759d9f Refactor Budget publishing prices phases constant to Budget::Phase model 2018-01-16 12:18:13 +01:00
Bertocq
66691b644a Refactor Budget::PHASES constant to Budget::Phase::PHASE_KINDS 2018-01-16 12:18:13 +01:00
Bertocq
36e74d0ef2 Add Budget::Phase model, spec and factory
Create a new Budget::Phase model that:
* Stablishes a relation with its budget
* Stablishes relation with two other Budget::Phases (previous and next)
* Validates basic dates range, kind and description rules.
* Adds scopes to get the ones enabled as well as each individual phase

Create a factory that generates a basic and valid Budget::Phase

Create a model spec that checks kind, date range and budget validations.
2018-01-16 12:18:13 +01:00
rgarcia
349780922d Add Budget.open scope
Before Budget.current could return multiple budgets, now there can only
be a single current_budget.

Adding the concept of open, which better reflects what the admin sees
in this page: A tab for open budgets and a tab for finished budgets
2018-01-15 22:01:59 +01:00
rgarcia
9176de949a Refactor concept of current budget
When there was only one budget this implementation worked fine

Nowadays there can be multiple budgets, and therefore the definition of
the current_budget has changed. It is no longer a budget that has not
finished, but rather, the last budget created that is not in the
initial drafting phase.

Budgets in the drafting phase are not considered the current_budget,
but rather a budget that is still being prepared and that soon will
become the current_budget
2018-01-15 19:13:37 +01:00
Bertocq
7179dbbba0 Remove deprecated on hold budget phase group, no longer used in code 2018-01-14 20:41:24 +01:00
Raimond Garcia
b0bd7792be Merge pull request #1917 from wairbut-m2c/iagirre-admin-budget-heading-action
Actions for budgets' headings added. Edit headings, delete headings i…
2018-01-11 13:47:27 +01:00
iagirre
0e11e21b2a Merged with master and solved conflicts 2018-01-10 13:23:39 +01:00
iagirre
f0724ce13a Changes suggested in the PR made 2018-01-10 13:13:05 +01:00
Bertocq
3563b87399 Increase Budget Investment model spec for should_show_price & explantion methods 2018-01-10 01:14:23 +01:00
Bertocq
cb1151f1d6 Increase Budget model spec for new publishing_prices phase 2018-01-10 01:04:32 +01:00
Bertocq
1f0eb49ddc Increase budget model spec for drafting phase 2018-01-08 22:53:14 +01:00
Bertocq
830bb37189 Enable RSpec/VerifiedDoubles cop, fix issues & stash one
Can't figureout solution for offense at spec/models/verification/management/email_spec.rb
 so its stashed at .rubocop_todo.yml

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
2018-01-07 18:47:19 +01:00
Bertocq
3762fd347e Enable RSpec/ScatteredSetup & fix issue
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
2018-01-07 18:46:58 +01:00
Bertocq
f8fb32db76 Enable RSpec/ScatteredLet cop & fix issue
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
2018-01-07 18:46:58 +01:00
Bertocq
16eae689f9 Enable RSpec/RepeatedExample cop & fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample
2018-01-07 18:46:32 +01:00
Bertocq
4f6597b200 Enable RSpec/RepeatedDescription cop & fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedDescription
2018-01-07 17:45:34 +01:00