Commit Graph

29 Commits

Author SHA1 Message Date
taitus
45d82d6e6b Move comments form to component 2024-03-25 07:59:39 +01:00
taitus
260196ca54 Use comments component for legislation annotations and questions 2024-03-22 08:56:13 +01:00
Javi Martín
a1439d0790 Apply Layout/LineLength rubocop rule
Note we're excluding a few files:

* Configuration files that weren't generated by us
* Migration files that weren't generated by us
* The Gemfile, since it includes an important comment that must be on
  the same line as the gem declaration
* The Budget::Stats class, since the heading statistics are a mess and
  having shorter lines would require a lot of refactoring
2023-08-30 14:46:35 +02:00
Javi Martín
ff93f5a591 Use "resolve" for polymorphic hierarchy paths
In the past, we couldn't use `polymorphic_path` in many places. For
instance, `polymorphic_path(budget, investment)` would return
`budget_budget_investment_path`, while in our routes we had defined
`budget_investment_path`.

With the `resolve` method, introduced in Rails 5.1, we can use symbols
to define we want it to use `investment` instead of `budget_investment`.
It also works with nested resources, so now we can write
`polymorphic_path(investment)`.

This makes the code for `resource_hierarchy_for` almost impossible to
understand. I reached this result after having a look at the internals
of the `resolve` method in order to get its results and then remove the
symbols we include.

Note using this method will not make admin routes compatible with
`polymorphic_path`. Quoting from the Rails documentation:

> This custom behavior only applies to simple polymorphic URLs where a
> single model instance is passed and not more complicated forms, e.g:
> [example showing admin routes won't work]

Also note that now the `admin_polymorphic_path` method will not work for
every model due to inconsistencies in our admin routes. For instance, we
define `groups` and `budget_investments`; we should either use the
`budget_` prefix in all places or remove it everywhere. Right now the
code only works for items with the prefix; it isn't a big deal because
we never call it with an item without the prefix.

Finally, for unknown reasons some routing tests fail if we use
`polymorphic_path`, so we need to redefine that method in those tests
and force the `only_path: true` option.
2020-06-15 11:54:05 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
a64a290392 Extract commentable_path to an initializer
By doing so and including it in ActionDispatch::Routing::UrlFor, we make
it available in controllers, helpers and specs, and so we can remove the
duplication we had there with methods dealing with the same problem.

Even if monkey-patching is ugly, using a different module and executing
ActionDispatch::Routing::UrlFor.send(:include, MyModule) wouldn't make
the method available in the controller.
2018-09-17 20:28:55 +02:00
Bertocq
ea089c1b87 Add missing legislation proposal commentable path 2018-02-03 23:54:22 +01:00
taitus
c5cb463a2e Refactor helpers. 2017-09-06 13:47:29 +02:00
taitus
4539c5fa00 Refactor and tests. 2017-09-05 12:52:14 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
decabeza
5e0d5fc8c3 Merge branch 'legislation-module-stable' of https://github.com/medialab-prado/consul into medialab-legislation 2017-05-22 18:43:49 +02:00
Juanjo Bazán
c81b8550f0 adds Question case for commentable route 2017-02-15 14:27:09 +01:00
Amaia Castro
3009706b0d Don’t allow comments on questions for unverified users and when the phase is closed 2017-02-08 18:19:10 +01:00
Amaia Castro
9c8102b9f3 Refactor path helpers for comments 2017-01-18 16:58:16 +01:00
Amaia Castro
53e9837db3 Change texts for legislation questions comments 2017-01-17 15:42:42 +01:00
Juanjo Bazán
ad435040bd adds helper to fix links to commentable 2017-01-10 13:54:50 +01:00
rgarcia
bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00
rgarcia
816a95b7b7 adds comment show view 2016-01-07 15:18:28 +01:00
kikito
60b3c65b05 Refactor comment tree calculation using a PORO 2015-10-30 17:00:32 +01:00
kikito
b2918621ab Refactors in children count when rendering comments 2015-10-28 17:33:24 +01:00
Sergio Arbeo
4e7493c75c Refactor comment body
Refactor the body of the comment to use a couple of helpers instead of a long
list of `if`s in the html.
2015-10-26 14:51:34 +01:00
David Gil
31cf51f07a adds text_with_links helper and use that in any comment.body in views, adds test to check for malicious injections in comment body 2015-09-10 18:28:10 +02:00
Juanjo Bazán
dfc1ccb108 renames helper method 2015-09-03 17:13:19 +02:00
Juanjo Bazán
136c1e73ed uses ancestry to retrieve debate comments 2015-09-03 16:32:54 +02:00
Juanjo Bazán
dee2d0196b ancestries
moves to ancestry from acts_as_commentable_with_threading
2015-09-02 19:23:09 +02:00
Juanjo Bazán
eb689d7c7e refactors comment form 2015-09-02 17:22:21 +02:00
Juanjo Bazán
df5ef2dc29 makes helper independent of commentable class 2015-09-02 17:06:11 +02:00
Juanjo Bazán
927f79fd78 adds i18n to comments_helper 2015-07-31 15:13:00 +02:00
rgarcia
b674e109a5 adds appropriate text for comment replies 2015-07-25 18:56:52 +02:00