Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
2fd4ca912e Merge pull request #4804 from consul/allowed_params
Make it easier to customize allowed parameters
2022-04-11 12:25:26 +02:00
Javi Martín
de35e93611 Remove empty paragraph in proposals search summary
We were accidentally introducing an empty paragraph because of a typo.
2022-04-10 13:51:10 +02:00
Javi Martín
b16bd2d461 Fix background style in investments search summary
The background wasn't expanding to the edge of the page because we
forgot to do this when we did the same thing for proposals and debates
in commit 4c47eab60.
2022-04-10 13:48:45 +02:00
Javi Martín
8aff5e95d6 Fix term in investments advanced search results
When using the advanced search in the debates and proposals sections, we
were not displaying the search term in the search results summary.
However, we were displaying it when using the advanced search in the
investments section.

Now we're doing the same thing everywhere.
2022-04-10 13:48:27 +02:00
Javi Martín
d0f8a678ba Simplify entrypoint configuration 2022-04-08 16:13:09 +02:00
Javi Martín
facdfa639e Remove SSH_AUTH references in docker compose
It was added in commit 1db5a00ea, probably due to the Capistrano
configuration of the developer who wrote the code. On my machine, docker
compose crashed due to these lines.
2022-04-08 16:13:09 +02:00
Javi Martín
d1b45238ba Use a better name for the database volume
Having "example" in the name is an indicator that we're supposed to
change the name :).
2022-04-08 16:13:09 +02:00
Javi Martín
0294ceba56 Remove redundant Docker Compose configuration
The same values are already defined in the Dockerfile.
2022-04-08 16:13:09 +02:00
Javi Martín
fa56a74ba0 Activate sync mode for standard output
By default, in order to increase performance during IO operations, Ruby
doesn't immediately write to the standard output but uses a buffer
internally and writes the output in chunks [1].

It looks like this results in some output being missed when running
Docker Compose [2], so we're activating the sync mode, which flushes all
output immediately.

[1] https://ruby-doc.org/core-2.6.5/IO.html#method-i-sync-3D
[2] See issue 1118 in the sinatra/sinatra repository
2022-04-08 16:13:09 +02:00
Javi Martín
6d163eb1bf Split line installing packages in Dockerfile
With one package in line and in alphabetic order, it's easier to see
which packages we're installing.

We're also applying the same formatting (taking from the Docker
documentation [1]) to other lines running multiple instructions.

[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
2022-04-08 16:13:09 +02:00
Javi Martín
8c5e7121ef Combine apt statements in Dockerfile
Quoting the Docker documentation [1]:

> Always combine RUN apt-get update with apt-get install in the same RUN
> statement.
> (...)
> Using apt-get update alone in a RUN statement causes caching issues
> and subsequent apt-get install instructions fail.
> (...)
> Docker sees the initial and modified instructions as identical and
> reuses the cache from previous steps. As a result the apt-get update
> is not executed because the build uses the cached version. Because the
> apt-get update is not run, your build can potentially get an outdated
> version of the curl and nginx packages.
>
> Using RUN apt-get update && apt-get install -y ensures your Dockerfile
> installs the latest package versions with no further coding or manual
> intervention.

[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
2022-04-08 16:13:09 +02:00
Javi Martín
54eb65b81d Don't use delegated volumes in Docker
We aren't sure why this option was added; only that it was added with
macos and windows developers in mind.

Since we aren't sure about it, we're using the default `consistent`
option instead.
2022-04-08 16:13:09 +02:00
Javi Martín
1d9d5ef0cb Don't use the --full-index option in Dockerfile
The --full-index option seemed to be causing caching issues on some
systems.

Since we don't know the reason why this option was added in the first
place, it might have some advantages. However, some people have reported
problems getting "version can no longer be found" errors for some gems
in this step, and documentation for Docker and Rails doesn't mention
this option at all.
2022-04-08 16:13:09 +02:00
Javi Martín
2bf3cb4484 Install Chromium before running bundle in Docker
This way we won't have to reinstall Chromium every time we change the
Gemfile.
2022-04-08 16:13:09 +02:00
Javi Martín
e4bc2c99bf Remove dead link in Dockerfile
The referenced URL is no longer available.
2022-04-08 16:13:09 +02:00
Javi Martín
642b7b2d75 Group Gemfile orders in Dockerfile together
The blank line between each order made it harder to read this file, and
we can use a shortcut to include all gemfiles.
2022-04-08 16:13:09 +02:00
Javi Martín
42104f2a58 Merge pull request #4765 from consul/docker_ignore
Add dockerignore file
2022-04-08 16:10:55 +02:00
Javi Martín
11832cc07d Make it easier to customize allowed parameters
When customizing CONSUL, one of the most common actions is adding a new
field to a form.

This requires modifying the permitted/allowed parameters. However, in
most cases, the method returning these parameters returned an instance
of `ActionController::Parameters`, so adding more parameters to it
wasn't easy.

So customizing the code required copying the method returning those
parameters and adding the new ones. For example:

```
def something_params
  params.require(:something).permit(
    :one_consul_attribute,
    :another_consul_attribute,
    :my_custom_attribute
  )
end
```

This meant that, if the `something_params` method changed in CONSUL, the
customization of this method had to be updated as well.

So we're extracting the logic returning the parameters to a method which
returns an array. Now this code can be customized without copying the
original method:

```
alias_method :consul_allowed_params, :allowed_params

def allowed_params
  consul_allowed_params + [:my_custom_attribute]
end
```
2022-04-07 19:35:40 +02:00
Javi Martín
3c5e168eb2 Merge pull request #4803 from consul/pending_tests
Implement or remove pending tests
2022-04-07 16:02:20 +02:00
Javi Martín
b68aa67b1d Remove unnecessary "pending" comment
The test is already working with poll question answers (which are the
only ones using `has_many_images`) as well.
2022-04-07 15:34:10 +02:00
Javi Martín
e637bce3d8 Fix error messages for question answer images
Since we were creating a new answer in the form, we weren't getting the
errors associated to the answer the administrator was trying to create,
and so we were skipping the test.

Using the answer which contains the information about validation errors
fixes the issue and so we don't have to skip the tests.
2022-04-07 15:34:10 +02:00
Javi Martín
fb99d8cb33 Remove obsolete "pending" test
I'd say this feature is actually tested in the "proposal polls specific
validations"; the empty test was probably added by accident in commit
4b8cc85c4.
2022-04-07 15:34:10 +02:00
Javi Martín
c0f71c4c8d Complete proposal notification test
We were finishing the test with the first "visit", so it was doing
nothing (other than potentially generating concurrency issues with other
tests).
2022-04-07 15:34:10 +02:00
Javi Martín
e49c32638d Use if instead of skip to skip tests
This way the tests won't appear as "pending" when running the test
suite, and so we get rid of a lot of noise in the test results. There
doesn't seem to be a way to call `skip` without the test being marked as
"pending".

Note that in the globalizable tests we need to build a factory before
deciding whether an atribute is required or not (particularly for the
milestone factory, since milestone attributes are required depending on
the presence of other attributes). This isn't possible before we're
inside the test, so we can't add an `if:` condition to the test. So
we're adding the condition inside the test instead. A minor
inconvenience of this method is the test still runs even when the
condition is `false`.
2022-04-07 15:34:10 +02:00
Javi Martín
2927174e06 Remove unnecessary locales check in specs
We define the available locales in the test environment, so Spanish is
always available in this environment even if it isn't available in the
production environment.
2022-04-07 15:34:10 +02:00
Javi Martín
702fc84391 Remove pending reportable tests
These tests are obsolete since commit 5ed308c6f.
2022-04-07 15:34:10 +02:00
Javi Martín
c5791278b2 Implement pending card image expectations 2022-04-07 15:34:10 +02:00
Javi Martín
4a8a4eacdd Remove pending tag cloud test for debates
This feature was only enabled for proposals five years ago, and it
hasn't changed since then. The pending test only gets in the way.

Implement. Or implement not. There is no pending.
2022-04-07 15:34:10 +02:00
Javi Martín
6c322e20f4 Implement tests to disable homepage settings
They were marked as pending.

Note Capybara doesn't support finding a button by its `aria-labelledby`
attribute, so we're using the ugly `click_button "Yes"`, like we did in
commit fabe97e50.
2022-04-07 15:34:10 +02:00
Javi Martín
695d5d8765 Enable passing legislation comment test
It was disabled in commit 792b15b22 for unknown reasons.
2022-04-07 15:34:10 +02:00
Javi Martín
6ddb22c1ea Enable test checking alert to finish valuation
It looks like it was disabled because it was failing sometimes for some
reason. I haven't found the reason, though; we're changing the test a
little bit to make it easier to read. Enabling it will let us find out
whether it still fails.
2022-04-07 15:34:09 +02:00
Javi Martín
fa15ac0c3b Implement pending email digest test 2022-04-07 15:34:09 +02:00
Javi Martín
d5867db2cf Remove unnecessary condition to skip tag list test
This file only has tests related to tags; if the model doesn't have
tags, we simply wouldn't include `it_behaves_as` in their tests instead
of including it and then skipping it.
2022-04-07 15:34:09 +02:00
Javi Martín
42b8729cd8 Remove duplicate map test
We were skipping the test, but there's an identical test right below it.
2022-04-07 15:34:09 +02:00
Javi Martín
0eb666db4d Allow commenting on polls as moderator/admin
So it works the same way as everywhere else.
2022-04-07 15:34:09 +02:00
Javi Martín
c77759469d Enable poll comments test
This feature was actually implemented, but the test was checking the
wrong selectors.
2022-04-07 15:34:09 +02:00
Javi Martín
3752fef6bf Remove map page in debates
The map feature was never implemented for debates (only for proposals
and budget investments) and it was crashing for debates because the page
didn't load the geozones. And we don't have a "geozone" field in the
debates form either.

So we're removing the map page alongside its (pending implementation)
tests.
2022-04-07 15:34:07 +02:00
Javi Martín
1f55be7c5e Remove obsolete pending test reference
The test "Sender email" already checks the receiver's name appears in
the copy sent to the sender.
2022-04-07 11:55:35 +02:00
Javi Martín
b89c358d03 Remove comments related to code from Madrid
CONSUL doesn't implement blank votes via web; the comment was based on
the code used in Madrid, which was actually very complex.

And the concept of "all city" was also specific to Madrid. Poll
questions aren't associated to a geozone, so the geozone will depend on
the poll they're associated to.
2022-04-07 11:55:35 +02:00
Javi Martín
1415be607e Merge pull request #4801 from consul/spec_support_custom_folder
Allow to customize tests common action modules
2022-04-06 17:27:30 +02:00
Senén Rodero Rodríguez
c086308b6f Call new common actions modules methods explicitly 2022-04-06 16:06:44 +02:00
Senén Rodero Rodríguez
7b1897b7a7 Remove method duplications as only the latest method loaded is used
The `management` variable gets its value from the caller context.
2022-04-06 16:06:44 +02:00
Senén Rodero Rodríguez
b24e49a6c8 Set a folder where to place custom spec support modules 2022-04-06 16:06:44 +02:00
Javi Martín
0b3c39d437 Add dockerignore file
Note there's a difference between gitignore and dockerignore; in
.gitignore, files without a leading slash match files in every folder,
while in .dockerignore, they match files in the root folder
2022-04-06 14:19:56 +02:00
Javi Martín
f487e9f0d0 Reorganize gitignore file
So it's easier to follow.
2022-04-06 14:19:55 +02:00
Javi Martín
fc70ba3db5 Define paths in gitignore in a consistent way
We used a slash as a prefix in some cases but not in other cases. Now
we're defining files and folders following the gitignore rules: files
starting with a slash are only ignored in the root folder, while files
not starting with it are ignored everywhere.

IMHO it makes sense to ignore all folders named `tmp`, `.bundle`, `log`,
`.DS_Store` or `.ruby-gemset` everywhere in the source code and not only
in the root folder.

We're also adding a trailing slash to all folders for consistency.
2022-04-06 14:19:55 +02:00
Javi Martín
f5152179e1 Remove references to IDEA files in gitignore
We can't cover the files for every editor out there, so we're removing
it in the name of neutrality. Developers using this editor to work with
CONSUL can add the `.idea` to their global gitignore configuration (on
GNU/Linux systems, for instance, the `~/.config/git/ignore` file).
2022-04-06 14:19:55 +02:00
Javi Martín
e98dc0923c Remove reference to beta testers file in gitignore
This feature was removed in commit 1e0ac137bb.
2022-04-06 14:19:55 +02:00
Javi Martín
1a880815dc Remove references to SQLite files in gitignore
We don't use SQLite and we don't support it, so these files shouldn't
exist in the first place.
2022-04-06 14:19:55 +02:00
Senén Rodero Rodríguez
46537cb708 Move nested_imageable helper methods to a new common actions module 2022-04-06 11:15:23 +02:00