Commit Graph

24 Commits

Author SHA1 Message Date
Javi Martín
a4d6e232fa Enable deprecation warnings in test and development
Now that we've got rid of all the warnings we had, we can enable them so
we'll notice new warnings when we introduce them.

This was the default option until Ruby 2.7.2 was released [1]. These
warnings were turned off by default because pretty much every Ruby gem
had dozens of warnings with Ruby 2.7 due to the changes in the way Ruby
handles keyword arguments.

[1] https://www.ruby-lang.org/en/news/2020/10/02/ruby-2-7-2-released/
2023-01-26 17:58:55 +01:00
Javi Martín
e93b693f71 Use different cache namespaces for different tenants
Since records in different tenants can have the same ID, they can share
the same `cache_key`, and so we need a namespace to differentiate them.
Without them, records from one tenant could expire the cache of a record
from another tenant.
2022-11-09 18:19:20 +01:00
Javi Martín
fcd8466ddf Allow using the lvh.me URL in development
Rails 6.0 introduced a `hosts` option which, in the development
environment, defaults to all IP addresses and the `localhost` domain.

However, we can't work with subdomains using `localhost`. For that
purpose, the `lvh.me` domain was created [1].

So we're allowing this domain and its subdomains so we can use them
while working with multitenancy in the development environment.

[1] http://railscasts.com/episodes/123-subdomains-revised
2022-10-28 14:44:57 +02:00
Javi Martín
9812757332 Set the asset host based on default_url_options
We were duplicating the asset host and the URL host in all environments,
but we can make it so the asset host uses the URL host unless we
specifically set it.

Note that, inside the `ApplicationMailer`, the `root_url` method already
uses `default_url_options` to generate the URL.

In the rare case of CONSUL installations who have changed the asset
host, this change has no effect since they'll get a conflict in the
environment files when upgrading and they'll choose to use their own
asset host.
2022-10-06 15:28:29 +02:00
Javi Martín
b7e116b53f Allow adding per-environment custom settings
Until now, when editing a specific environment, other CONSUL
installations had to edit the original file, which made it harder to
upgrade.

Now it's possible to change the default CONSUL settings using custom
files, making it easier to upgrade to versions of CONSUL which change
the original environment files (which is very common when upgrading
versions of Rails).
2022-10-05 17:25:47 +02:00
Javi Martín
ffc14e499a Upgrade to Rails 6.0
All the code in the `bin/` and the `config/` folders has been generated
running `rake app:update`. The only exception is the code in
`config/application.rb` where we've excluded the engines that Rails 6.0
has added, since we don't use them.

There are a few changes in Active Storage which aren't compatible with
the code we were using until now.

Since the method to assign an attachment in ActiveStorage has changed
and is incompatible with the hack we used to allow assigning `nil`
attachments, and since ActiveStorage now supports assigning `nil`
attachments, we're removing the mentioned hack. This makes the
HasAttachment module redundant, so we're removing it.

Another change in ActiveStorage is files are no longer saved before
saving the `ActiveStorage::Attachment` record. This means we need to
manually upload the file when using direct uploads. We also have to
change the width and height validations we used for images; however,
doing so results in very complex code, and we currently have to write
that code for both images and site customization images.

So, for now, we're just uploading the file before checking its
dimensions. Not ideal, though. We might use active_storage_validations
in the future to fix this issue (when they support a proc/lambda, as
mentioned in commit 600f5c35e).

We also need to update a couple of tests due to a small change in
response headers. Now the content disposition returns something like:

```
attachment; filename="budget_investments.csv"; filename*=UTF-8''budget_investments.csv
```

So we're updating regular expression we use to check the filename.

Finally, Rails 6.0.1 changed the way the host is set in integration
tests [1] and so both `Capybara.app_host` and `Capybara.default_host`
were ignored when generating URLs in the relationable examples. The only
way I've found to make it work is to explicitely assign the host to the
integration session. Rails 6.1 will change this setup again, so maybe
then we can remove this hack.

[1] https://github.com/rails/rails/pull/36283/commits/fe00711e9
2022-08-24 14:33:02 +02:00
Javi Martín
61cfcfcc97 Disable JavaScript debugging in development
While debugging JavaScript is certainly useful, enabling it generates
about 100 extra HTTP requests because we include about 100 JavaScript
files (including external dependencies and files written by us).
Depending on the browser configuration, this might make the browser take
a very long time processing these requests.

On my machine, with these changes, refreshing a page on Firefox takes
about 1 second, while previously it took about 6-8 seconds. With
Chromium, there doesn't seem to be much difference.

Developers are encouraged to temporarily turn debugging while debugging
JavaScript (which is a task I personally do about once a month) if that
makes debugging easier for them.

This change doesn't affect our CSS files, since for CSS we use Sass
instead of the asset pipeline. Sass already compiles all CSS files into
one in the development environment.
2021-06-22 17:11:51 +02:00
Javi Martín
3267c81ba0 Upgrade to Rails 5.2
All the code in the `bin/` and the `config/` folder has been generated
running `rake app:update`, except the `escape_javascript_fix` file,
which we've removed since the code there is already included in Rails
5.2.
2020-10-15 14:46:20 +02:00
Javi Martín
5442ca7c54 Remove redundant configuration option
This option was added by Rails 4 new application generator. However, the
`assets.digest` option is set to true by default, and recent Rails
versions don't even add this option to the environment files.
2020-10-04 15:47:20 +02:00
Javi Martín
e4346261ce Use a memory cache store in development
In commit 574133a5 we configured the development to use Dalli to cache
pages. However, cache is usually disabled in the development
environment.

When we upgraded to Rails 5 in commit eb36b7e2, we configured the
development environment to enable caching (using a memory store) when a
certain file is present, and to disable it when it's not. This
configuration makes more sense IMHO, and it was being overwritten by the
one previously mentioned.

After this change, using memcached is no longer required in the
development environment and the `DalliError: No server available` error
message is gone.
2020-05-19 19:05:03 +02:00
decabeza
cb22e6cbfb Merge branch 'master' into proposal-dashboard 2019-04-23 17:12:47 +02:00
Julian Herrero
6e88031537 Fix several rubocop warnings
Metrics/LineLength: Line is too long.
RSpec/InstanceVariable: Use let instead of an instance variable.
Layout/TrailingBlankLines: Final newline missing.
Style/StringLiterals: Prefer double-quoted strings.
2019-04-17 17:40:56 +02:00
Juanjo Bazán
eb36b7e2e5 updates config files 2019-04-16 17:28:06 +02:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Julian Herrero
c9cdc72537 Use double quotes in config/ 2019-03-15 10:29:07 +01:00
Juan Salvador Pérez García
8876b285ce Fixes #229
Adds email feature for proposals dashboard
2018-07-25 13:28:44 +02:00
Juanjo Bazán
574133a50b updates environments files to use dalli store 2015-08-31 20:38:52 +02:00
Raimond Garcia
9ab13abf20 Merge pull request #256 from AyuntamientoMadrid/improve_emails
Improve emails
2015-08-26 20:06:28 +02:00
Alberto Garcia Cabeza
4382a83c30 Fixes asset host for development 2015-08-26 19:43:12 +02:00
kikito
048f7c9b73 Adds bullet to dev & test, but makes it visible only on-demmand
The logs are always stored in log/bullet.log

If you run the specs with `BULLET=true bin/rspec`:
* Any feature test which makes bullet angry will fail

If you run rails with `BULLET=true bin/rails s`:
* It will print the bullet logs in both the rails log and the bullet log
* It will show a footer on each page with the N+1 queries etc.
2015-08-26 17:24:08 +02:00
Juanjo Bazán
7edb45b0d7 configures the null cache store in all environments
This commit allows us to use caching and Rails.cache.
Temporarily we configure the null store in all environments,
but those will probably be memcached in the future.

References #235
2015-08-24 18:51:28 +02:00
Juanjo Bazán
e2f7b9c505 adds letter_opener 2015-07-31 13:51:31 +02:00
rgarcia
f618a9f45d adds devise configuration [#6] 2015-07-16 19:47:54 +02:00
rgarcia
8db3630837 initial commit 2015-07-15 13:32:13 +02:00