Commit Graph

62 Commits

Author SHA1 Message Date
Javi Martín
e7b271fb47 Remove obsolete comment in environment files
We removed the assets initializer in commit 91cd1ce1b.
2022-07-19 23:13:35 +02:00
Javi Martín
7b91adb16f Use the same config for staging and preproduction
We were already doing so by duplicating the code; now we're doing it
explicitly.

This is going to help because we're going to do a few changes in the
environment files, and this way we don't have to do everything twice.

Note that, after we're finished with these changes, the staging and
production environments will be mostly identical and we could simply
require the production environment configuration in the `staging.rb`
file. We aren't doing so because some Consul installations might have
customized these files and it'd be hard for them to deal with all these
changes at once. So, for now, they'll only have to deal with the
possible differences between their staging and preproduction
environments.

Changes to the preproduction environment that won't be applied to the
staging environment can be added like this:

require Rails.root.join("config", "environments", "staging")

Rails.application.configure do
  config.log_level = :warn
end
2022-07-19 23:13:08 +02:00
Javi Martín
73a0a21001 Configure Active Storage 2021-09-24 13:39:15 +02:00
Javi Martín
65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00
Javi Martín
e01a94d7bd Use mem_cache_store instead of dalli_store
`dalli_store` is deprecated since dalli 2.7.11.

We can now enable cache_versioning. We didn't enable it when upgrading
to Rails 5.2 because of possible incompatibility with `dalli_store` [1],
even though apparently some the issues were fixed in dalli 2.7.9 and
dalli 2.7.10 [2].

Since using cache versioning makes cache expiration more efficient, and
I'm not sure whether the options we were passing to the dalli store are
valid with memcache store (documentation here is a bit lacking), I'm
just removing the option we used to double the default cache size on
production.

[1] https://www.schneems.com/2018/10/17/cache-invalidation-complexity-rails-52-and-dalli-cache-store
[2] https://github.com/petergoldstein/dalli/blob/master/History.md
2021-08-15 19:42:22 +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
4bb1b3a6c3 Use Harmony mode in uglifier for ES2015+ support
Recent versions of graphql-rails updated React to a version which
requires this mode so it can be compiled on production.

So we enable this mode is described in the Uglifier README [2].

[1] https://github.com/lautis/uglifier/tree/v4.2.0#es6--es2015--harmony-mode
2020-10-02 14:07:05 +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
Pierre Mesure
40ecbe0348 Remove fallbacks = true from staging, preprod and prod 2020-02-20 11:09:55 +01:00
Julian Herrero
df4f8810c5 Define force_ssl configuration in secrets file
this is usually configured in the production.rb file (which is under
version control), the natural place to configure it is the secrets.yml
file.

Until now we were using the capistrano shared folder, but that's a bit
inconvenient since changes we've done to the production.rb file (like
changing eager_load_paths when we upgraded to Rails 5) won't take effect
after a deployment.
2019-11-12 14:47:28 +01:00
Javi Martín
bc9471b49e Define SMTP configuration in the secrets file
Since SMTP passwords should not be in a file under version control, and
they're usually configured in the production.rb file (which is under
version control), the natural place to configure it is the secrets.yml
file.

Until now we were using the capistrano shared folder, but that's a bit
inconvenient since changes we've done to the production.rb file (like
changing eager_load_paths when we upgraded to Rails 5) won't take effect
after a deployment.
2019-11-11 12:11:20 +01: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
Javier Martín
cb6539d170 Merge pull request #3537 from PierreMesure/set-locales-in-test-environment
Set locales in test environment to avoid failed specs
2019-09-11 18:43:03 +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
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Pierre Mesure
7fc4106780 Cleaning a few lines 2019-09-08 22:39:01 +02:00
Pierre Mesure
d317af572c Set locales in test environment to avoid failed specs 2019-09-08 22:39:00 +02:00
German Galia
85722eb7c4 Rename admin/debates and admin/comments to hidden 2019-06-02 19:12:26 +02:00
Julian Herrero
2ba7355b00 Add lib folder path to eager_load_paths
Because autoloading is disabled in production with Rails 5,
using autoload_paths will not load needed classes from
specified paths. The solution to this, is to ask Rails
to eager load classes.

https://sipsandbits.com/2017/02/14/upgrading-a-ruby-on-rails-application/
2019-04-29 17:45:58 -05:00
Javi Martín
825367145c Remove redundant test order option
The test order is now random by default.
2019-04-29 13:08:43 -05:00
decabeza
cb22e6cbfb Merge branch 'master' into proposal-dashboard 2019-04-23 17:12:47 +02:00
Julian Herrero
b36fdb5604 Add lib folder path to eager_load_paths
Because autoloading is disabled in production with Rails 5,
using autoload_paths will not load needed classes from
specified paths. The solution to this, is to ask Rails
to eager load classes.

https://sipsandbits.com/2017/02/14/upgrading-a-ruby-on-rails-application/
2019-04-17 17:40:56 +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
decabeza
546105d989 Merge branch 'master' into dashboard-master 2018-10-19 01:48:37 +02:00
voodoorai2000
2892d0e1d5 Add placeholder configuration for SMTP 2018-09-13 20:38:42 +02:00
rgarcia
2995734762 Increase max cache size to 2MB
We have lots of votes in this edition of participatory budgets and the
default cache size (1MB) is not enough to hold certain cache fragments
2018-07-27 12:08:20 +02:00
Juan Salvador Pérez García
8876b285ce Fixes #229
Adds email feature for proposals dashboard
2018-07-25 13:28:44 +02:00
Semyon Pupkov
65b13f4476 Change log level in production to warn
ref: https://github.com/AyuntamientoMadrid/consul/pull/828
2017-08-08 23:42:52 +05: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
Alberto Garcia Cabeza
d24efbad60 Changes .com urls examples to .consul 2016-07-06 12:32:07 +02:00
kikito
eda47effc4 Configures tests to minimize flackyness
Reference: https://bibwild.wordpress.com/2016/02/18/struggling-towards-reliable-capybara-javascript-testing/

The only thing I did not do was removing the random order in the tests.
2016-02-24 11:37:07 +01:00
rgarcia
91f9d5e6af removes unique language for production env 2015-11-10 10:57:39 +01:00
Juanjo Bazán
cb6949e918 disables english locale in production
(temporary change until texts are ready)
2015-09-03 23:48:25 +02:00
rgarcia
7af1bc526a adds preproduction environment 2015-09-01 19:54:21 +02:00
rgarcia
0fc51bee60 adds mailer asset host for staging and production envs 2015-09-01 17:31:28 +02:00
Juanjo Bazán
574133a50b updates environments files to use dalli store 2015-08-31 20:38:52 +02:00
kikito
599ea9a19f force ssl in production 2015-08-27 14:23:34 +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
rgarcia
e219e5be4d adds force ssl to staging 2015-08-26 12:22:58 +02:00
rgarcia
c13aea5f1d removes force ssl from staging 2015-08-26 12:03:28 +02:00
rgarcia
30d996da84 force ssl in staging 2015-08-26 12:00:34 +02:00
rgarcia
1a806db80d removes ssl from production env 2015-08-26 11:46:09 +02:00
rgarcia
98c6f6561c removes force ssl in staging env 2015-08-26 11:37:41 +02:00