Commit Graph

246 Commits

Author SHA1 Message Date
Javi Martín
9028d82f77 Remove unnecessary enconding magic comment
This comment isn't necessary since Ruby 2.0, where UTF-8 became the
default encoding.

I've found this issue thanks to the EmptyLineAfterMagicComment rubocop
rule.
2019-10-24 17:56:03 +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
11e52dbe98 Remove kaminari_path
The main reason to use it was the `rel` attribute for previous/next
pages not being indexed correctly by certain search engines when using a
relative URL. However, AFAIK that only applied to `<link>` tags, not to
`<a>` tags, and only if a `<base>` tag was defined.

In any case, it looks like the same search engines don't use the `rel`
attribute for previous/next to index pages anymore.
2019-10-20 17:26:14 +02:00
Javi Martín
1ebfa04578 Check texts from the user's point of view
This way we also simplify the code by avoiding instance variables.
2019-09-30 14:29:15 +02:00
Javi Martín
0f80dabfe4 Compare against literal title in feature specs
We were creating records with a title we manually set, so to be
consistent with the rest of the code, in the test we check the title is
present using a string literal.

This way we can also remove useless assignments while keeping the code
vertically aligned.
2019-09-30 14:29:15 +02:00
Javi Martín
5ff1162038 Simplify creating follows in specs
While in theory we wouldn't need to use the `transient` nor the
`after(:create)` because there's already a `has_many :through`
association with followers, Factory Bot / ActiveRecord don't
automatically associate the followable, resulting in an invalid record
exception.
2019-09-30 13:34:31 +02:00
Javi Martín
818b442d52 Simplify creating voters in specs 2019-09-30 00:36:40 +02:00
Javi Martín
dcc9a6b561 Use symbols instead of constants for behaviours
This way we can be more flexible about the factory we can pass as
parameter.
2019-09-29 22:31:13 +02:00
Javi Martín
bfd39a13e0 Remove unnecessary attributes in proposals spec
These tests are only checking which proposals are not included in the
recommendations, so we don't need to sort the included ones, just like
we don't use the cached votes up attribute in the tests preceeding these
ones.
2019-09-29 22:31:13 +02:00
Javi Martín
7b0771106e Remove isolated useless assignments
These variables are not surrounded by other assignments, and so they can
safely be removed without making it harder to read the code vertically.
2019-09-25 12:43:44 +02:00
Javi Martín
5cbd160f11 Move login_as after creating data for a test
It doesn't really affect the tests, but it helps isolate useless
assignments, and we already did it this way 94% of the time.
2019-09-25 12:43:44 +02:00
Javi Martín
086e960d09 Add trait to simplify image creation in specs 2019-09-24 21:34:06 +02:00
Javi Martín
8ec8002acd Enable featured proposals when they're used
These specs were added before we disabled featured proposals by default.
After that, they were passing, but they were not testing the scenario
they were supposed to test.
2019-09-24 20:05:02 +02:00
Javi Martín
52c8691aae Don't create featured proposals if disabled
Before we disabled featured proposals by default, there were many tests
creating them because they were needed in order to create non-featured
proposals.

But now these tests don't need to create featured proposals anymore.
2019-09-24 20:04:39 +02:00
Javi Martín
2ad6ced12f Create featured proposals if enabled
We had a case where we created 5 extra records in pagination and checked
2 records were present, because the other 3 were automatically
considered featured proposals.

Explicitely creating featured proposals let us create 2 extra records
 and check 2 records are present, which is far more intuitive.
2019-09-24 20:03:52 +02:00
Javi Martín
9fcea17849 Remove useless parameter in URL
The proposal parameter was accidentally added in commit 16692c93, but
the proposals index doesn't receive a proposal as parameter.
2019-09-24 19:28:36 +02:00
Javi Martín
11d16e7aad Simplify translatable tests in the public area 2019-09-23 18:01:44 +02:00
Javi Martín
44d137a4c0 Simplify translatable tests in admin section
These feature tests were taking too long, we can't run them for every
single model.

I'm taking the approach of using one different model for each test, but
in theory only using a few models covering every possible scenario
would be enough.
2019-09-23 18:01:44 +02:00
Javi Martín
2ec176a2a8 Remove redundant feature settings enabled in tests
These settings are enabled by default.

It could be argued explicitely enabling the features makes tests more
consistent, because they'll work if we change the default setting. It
could also be argued that it makes tests more expressive because it
makes the reader realize certain things will only work if a setting is
enabled.

However, we were only doing so in a few tests. The truth is, thousands
of our tests depend on certain features being enabled. So IMHO we should
be consistent and either set them on every test, or not at all. I'm
choosing the latter option for simplicity.
2019-09-23 15:15:51 +02:00
Javi Martín
da121ebc53 Remove redundant setting resets in after blocks
Settings are stored in the database, and so any changes to the settings
done during the tests are automatically rolled back between one test and
the next one.

There were also a few places where we weren't using an `after` block but
changing the setting at the end of the test.
2019-09-23 13:47:45 +02:00
decabeza
0ff7a327b7 Refactor selected proposals specs 2019-09-11 22:18:56 +02:00
decabeza
8440208597 Hide comments count on selected proposals 2019-09-11 22:18:43 +02:00
decabeza
1a0f0215a7 Hide related content on selected proposals 2019-09-11 22:18:42 +02:00
decabeza
b15048ec7d Hide proposal code on selected proposals 2019-09-11 22:17:40 +02:00
decabeza
e879fddba4 Hide view mode on selected proposals list 2019-09-11 22:17:40 +02:00
Javi Martín
c05b9c2aac Apply Capybara/CurrentPathExpectation rubocop rule 2019-09-10 21:43:39 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
57bda006b5 Don't click two places at the same time
When clicking the button "Search", the link "newest" is already present,
so capybara might click the "newest" link before the "Search" request is
finished, leading to unexpected results.

Checking the page to make sure the "Search" request has finished before
clicking the "newest" link solves the problem.
2019-08-07 14:18:50 +02:00
Senén Rodero Rodríguez
b2d8851bcc Add the option to disable languages managment to cover special cases
We understand languages management as the ability to add new languages
or remove existing ones. When no option is passed it will allow language
manipulation by default.

There are 3 special places where we want block languages management:
- admin legislation processes homepage
- admin legislation processes milestones summary
- proposals retired form

Co-Authored-By: Sebastia <sebastia.roig@gmail.com>
2019-07-01 15:03:48 +02:00
taitus
c1f3a4ad3b Add remote translations to debates and proposals
Include RemotelyTranslatable concern on commentable actions to detect
remote translations on index and show controllers actions.
2019-06-27 09:21:19 +02:00
Senén Rodero Rodríguez
264b3f0f82 Simpler calls to *_translatable shared specs
Enable translations interface setting inside shared specs when needed.

Co-Authored-By: javierm <javim@elretirao.net>
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
7e3f0b5c18 Add translation interface feature setting
Allow to enable/disable translation interface at frontend
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
3176be43d9 Rename "translatable" shared example to "edit_translatable"
Also rename all specs calls
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
d0bf0f8857 Add "new_translatable" shared example to proposals feature specs 2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
0f4fcfb20e Fix proposals suggest feature
Now we need one suggest placeholder for each translation. This also
fixes invalid usage of id HTML attribute.
2019-06-27 09:19:37 +02:00
Senén Rodero Rodríguez
bd3bb72370 Add proposals translation interface
* Convert proposal form into translatable one.
 * Adapt translatable shared spec to define an owner when running at
   frontend feature specs.
 * Remove old attributes from strong parameters.
2019-06-27 09:19:37 +02:00
Senén Rodero Rodríguez
78c2f54c5d Fix proposal specs
After adding proposal translatable fields to forms, they will be generated with nested translations names and ids so we can no longer
use standard id locator.

Using input label text to fill in fields works with both types of forms.
2019-06-27 09:19:36 +02:00
Senén Rodero Rodríguez
02be0c61f9 Add proposal translations
Adapt retire form to include needed translations and move validations
from controller to model.

Also change sanitizable concern to sanitize not marked for destruction
translations.
2019-06-27 09:19:36 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
Julian Nicolas Herrero
3ba7bd1cab Merge pull request #3567 from consul/select_proposals_by_admins
Make proposals to be selected by administrators
2019-05-31 15:30:39 +02:00
decabeza
a3799aa87c Update link to selected proposals on proposals spec 2019-05-31 12:25:01 +02:00
decabeza
7ed80d7883 Move link to selected proposals on proposals index 2019-05-31 12:24:10 +02:00
Julian Herrero
d4ec750428 Show archived proposals in selected proposals list 2019-05-30 11:19:38 +02:00
Julian Herrero
4be4d96710 Don't show order links in selected proposals list 2019-05-30 11:19:38 +02:00
Julian Herrero
6e905c517f Don't show recommented proposals in selected proposals list 2019-05-30 11:19:38 +02:00
Julian Herrero
dfe3764616 Don't show featured proposals in selected proposals list 2019-05-30 11:19:38 +02:00
Julian Herrero
5952c2664d Show a 'Selected proposal' message in the show view 2019-05-30 11:19:38 +02:00
Julian Herrero
a852696eeb Remove not selected proposals from other lists 2019-05-30 11:19:38 +02:00
Julian Herrero
6beb11f0a9 Show completed progress bar for successful proposals
Show a completed progress bar with total supports intead of showing
a message telling the proposal has reached the needed supports.
2019-05-30 11:19:38 +02:00