Commit Graph

148 Commits

Author SHA1 Message Date
Javi Martín
9335c51cfc Include hidden users in stats
If users participated and were hidden after participating, we should
still count them in the participants stats.

In the tests, we set users' `hidden_at` attribute before they vote.
Although in real life they would vote first and then they would be
hidden, I've written the tests like this for the sake of simplicity.
2019-05-21 13:50:19 +02:00
Javi Martín
66ecb2835b Show only available budget stats phases
This way we can show statistics for the supports phase before the vote
phase is over.
2019-05-21 13:50:18 +02:00
Javi Martín
bf2292ba18 Rename budget stats "all phase" to "every phase"
"All phase" doesn't sound right in English, and we're going to refactor
the code related to the phases.
2019-05-21 13:50:18 +02:00
Javi Martín
2215971a6b Remove unused code 2019-05-21 13:50:18 +02:00
Javi Martín
ae4cd06c24 Include no geozone in no demographic data 2019-05-21 13:50:18 +02:00
Javi Martín
76c7827cf4 Use stats objects instead of hashes
It will make it far easier to call other methods on the stats object,
and we're already caching the methods.

We had to remove the view fragment caching because the stats object
isn't as easy to cache. The good thing about it is the view will
automatically be updated when we change logic regarding which stats to
show, and the methods taking long to execute are cached in the model.
2019-05-21 13:50:18 +02:00
Javi Martín
dc077bb03c Simplify budget stats in voting phase
So we only show the total number of participants, and not divided by web
participants and booth participants.
2019-05-21 13:50:17 +02:00
Javi Martín
d42454a1a8 Include booth users in participants in vote phase
We were expecting `balloters` to include `poll_ballot_voters` (that's
why we're substracting them to calculate web participants), but reality
has proven `poll_ballot_voters` aren't included in `balloters`.
2019-05-21 13:50:17 +02:00
Javi Martín
cf32cc940b Exclude nil balloters from vote phase participants
The `user_id` can be `nil` for ballots.
2019-05-21 13:50:17 +02:00
Javi Martín
0a578f2775 Create less records in budget stats specs
Creating only the necessary data for each test makes tests easier to
read. It also makes tests slightly faster.
2019-05-21 13:50:17 +02:00
Javi Martín
20b1085dc8 Simplify budget stats data generation
Configuring associations in the factories makes it easier to generate
headings, polls and ballots in the tests.
2019-05-21 13:50:17 +02:00
Javi Martín
4d520a3a47 Rename age_groups method
The name was confusing because it seemed to return a list of age groups.
2019-05-21 13:50:16 +02:00
Javi Martín
57a2945590 Use let for stats in budget stats spec
The rest of the `before` block still uses instance variables, but at
least the rest of the file doesn't use instance variables anymore.
2019-05-21 13:50:15 +02:00
Javi Martín
9a01ff5323 Refactor age groups method
We try to make the method return data which is easier to handle in the
view.
2019-05-21 13:50:15 +02:00
María Checa
fac99cfb10 Add web and booth participants in budget stats 2019-05-16 22:01:42 +02:00
Marko Lovic
70e108d593 Simplify spec 2019-05-16 22:01:42 +02:00
Marko Lovic
0c5f801c19 Keep DB clean after running budget stats spec
This spec was leaving the DB "dirty" because it was creating
records in a before(:all) hook. These records are not cleaned up
automatically when using the :transaction strategy for DatabaseCleaner.

Using before(:each), however, causes another problem. Some of the code
depends on the heading id being 1 (see app/models/budget/ballot/line.rb#L48).
Because of SQL auto-increment, this is only the case the first time the hook
is run, as different id's are assigned on subsequent runs. This is fixed
by forcing the id to always be 1.
2019-05-16 22:01:42 +02:00
María Checa
3291b3274a Added physical votes to stats 2019-05-16 22:01:42 +02:00
rgarcia
1eaa5cc77b stores the heading where the user has voted 2019-04-10 18:15:43 +02:00
lalo
237a03552f Move admin budget investments tabs filters to advanced filters component 2019-04-03 22:27:48 +02:00
Javi Martín
c5c56ad969 Use a virtual attribute to get valuation tags
It was strange to set the valuation tags using `valuation_tag_list=` but
then accessing the valuation tags using `tag_list_on(:valuation)`.
2019-02-26 14:16:10 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Julian Herrero
a963a99c55 Use correct scope to sort headings by name 2019-02-13 13:35:09 +01:00
Julian Herrero
29a704bd60 Show headings in budgets landing page when translations are missing 2019-02-13 13:35:09 +01:00
Julian Herrero
922600252c Make budget headings translatable 2019-02-13 13:35:07 +01:00
Julian Herrero
1c35ec99c1 Make budget groups translatable 2019-02-13 12:30:37 +01:00
Julian Herrero
2081269a67 fix Hound violations 2019-01-02 10:46:31 +01:00
Raimond Garcia
ea435ac56c Merge pull request #3112 from consul/rubocop_not_to
Add not_to Rubocop rule
2018-12-19 11:29:44 +01:00
voodoorai2000
7917cea676 Change to_not for not_to
Eventhough some of us sentimentals still like the syntax `to_not` the current trend is to move to the new syntax `not_to`.

In this commit we are updating the references of expectations that used `to_not` to `not_to`.
2018-12-15 12:33:28 +01:00
Julian Herrero
25e1afea48 fix map rendering for budget headings 2018-12-14 15:37:22 +01:00
Julian Nicolas Herrero
6aa54d6c62 Merge branch 'master' into content_blocks_for_headings 2018-12-11 16:40:25 +01:00
Julian Nicolas Herrero
9aab3ddd7b Merge pull request #3038 from MatheusMiranda/add_map_to_heading_page
Add map to sidebar on Heading's page
2018-12-11 16:32:35 +01:00
Marko Lovic
c0f6fa182f Make Milestones general, and not specific to Budget Investments
Generalize the Budget::Investment::Milestone model to a
polymorphic Milestone model so it can be used for entities
other than Budget::Investment.
2018-11-30 14:15:21 +01:00
Marko Lovic
81f516efd7 Change BudgetInvestmentStatus to Milestone::Status
Generalize the BudgetInvestmentStatus model to Milestone::Status so it
is not specific to budget investments, but can be used for any entity
which has milestones. This is in preparation to make the Milestone
model polymorphic and usable by entities other than budget investments.
2018-11-30 14:15:21 +01:00
Milber Champutiz Burbano
9f455b9165 Added feature to add content block to headings in sidebar -- rebase 2018-11-27 09:37:35 -05:00
Matheus Miranda
06f07b1139 Add map to sidebar on Heading's page
Signed-off-by: Matheus Miranda <matheusmirandalacerda@gmail.com>
2018-11-16 09:05:23 +01:00
Javi Martín
ab870c756a Use Date.current to find published milestones
Using `Date.today` caused some milestones to be published before/after
the date defined by `Rails.application.config.time_zone`.

See also commit AyuntamientoMadird/consul@088c76d for a more detailed
explanation.
2018-11-06 13:02:35 +01:00
Javi Martín
01a254545f Update milestones translatable fields
Note the title field was hidden since commit 01b9aa8, even though it was
required and translatable. I've removed the required validation rule,
since it doesn't seem to make much sense and made the translatable
tests harder to write.

Also note the method `I18n.localize`, which is used to set the
milestone's title, uses `I18n.locale` even if it's inside a
`Globalize.with_locale` block, and so the same format is generated for
every locale.
2018-10-22 15:44:14 +02:00
Javi Martín
f2bebca6be Bring back and fix deleted test
It was removed in 755be96 because some tags were allowed, but we can
just update it to check it doesn't remove those tags.
2018-09-12 12:35:28 +02:00
Raúl Fuentes
bf0472fd58 Fix test
now the <a> tag is permited, also the list of allowed tags is in
the configuration of ckeditor4
2018-09-12 12:35:28 +02:00
rgarcia
ab5f78120a Fix specs
Git seems to have gotten confused and some specs where duplicated
and others missing

This commits restructures commits to sync them with Madrid's fork
2018-07-26 12:52:51 +02:00
rgarcia
90bb06e684 Fix display of unfeasibility explanation
We were missing a check to make sure valuation had finished before
displaying the unfeasibility explanation
2018-07-10 17:57:41 +02:00
María Checa
fb5b993920 Add Budget::Investment::Statuses tests 2018-06-27 18:34:02 +02:00
María Checa
e8e9fcd0da Add Budget::Investment::Statuses tests 2018-06-27 16:45:58 +02:00
Bertocq
43d78c6c72 Adding Investment#by_valuator_group test scenario
Budget::Investment#by_valuator_group scope didn't had a test scenario
2018-04-06 00:22:41 +02:00
Raimond Garcia
65f5ab424b Merge pull request #2570 from consul/unfeasibility-explanation
Display unfeasibility explanation only when valuation has finished
2018-04-05 00:21:31 +02:00
rgarcia
71bb5b3dcf Fix display of unfeasibility explanation
We were missing a check to make sure valuation had finished before
displaying the unfeasibility explanation
2018-04-04 14:38:31 +02:00
rgarcia
00c965b715 Clean up 2018-04-04 13:19:01 +02:00
rgarcia
073cf74818 Fix edge case
The user was able to vote as many investments as wanted in the first
heading voted. However in the second heading voted, only one investment
could be voted

This was due to the previous implementation, where you could only vote
in one heading. Note the `first` call in method
`heading_voted_by_user?(user)`

This commits simplifies the logic and allows voting for any investment
in any heading that the user has previously voted in
2018-03-22 23:08:41 +01:00
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