Commit Graph

20 Commits

Author SHA1 Message Date
Javi Martín
5983006657 Use a custom method to detect the current tenant
The subdomain elevator we were using, which is included in apartment,
didn't work on hosts already including a subdomain (like
demo.consul.dev, for instance). In those cases, we would manually add
the subdomain to the list of excluded subdomains. Since these subdomains
will be different for different CONSUL installations, it meant each
installation had to customize the code. Furthermore, existing
installations using subdomains would stop working.

So we're using a custom method to find the current tenant, based on the
host defined in `default_url_options`.

In order to avoid any side-effects on single-tenant applications, we're
adding a new configuration option to enable multitenancy

We're enabling two ways to handle this configuration option:

a) Change the application_custom.rb file, which is under version control
b) Change the secrets.yml file, which is not under version control

This way people prefering to handle configuration options through
version control can do so, while people who prefer handling
configuration options through te secrets.yml file can do so as well.

We're also disabling the super-annoying warnings mentioning there are no
tenants which we got every time we run migrations on single-tenant
applications. These messages will only be enabled when the multitenancy
feature is enabled too. For this reason, we're also disabling the
multitenancy feature in the development environment by default.
2022-11-09 18:19:20 +01: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
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
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
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
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
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
Juanjo Bazán
eb36b7e2e5 updates config files 2019-04-16 17:28:06 +02:00
Julian Herrero
c9cdc72537 Use double quotes in config/ 2019-03-15 10:29:07 +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
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
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
0ca3d2501f fixes build 2015-07-31 14:54:49 +02:00
rgarcia
8db3630837 initial commit 2015-07-15 13:32:13 +02:00