Commit Graph

14976 Commits

Author SHA1 Message Date
Javi Martín
688aa88366 Make migrations independent of globalize
There are two reasons for this change:

1. Past migrations depending on models will not work once a model is
removed, and they won't work if we remove Globalize either
2. We were getting a conflict in the schema file; when run under Rails
5.0, these migrations were generating a different schema than in Rails
5.1, due to the way the `create_translation_table!` method handles the
`id: :serial` attribute.
2020-04-24 15:43:54 +02:00
Javi Martín
37361a6f3d Replace render :nothing with head :ok
Using `render :nothing` was deprecated, but we never noticed it because
we didn't have a test for the action using it. In Rails 5.1, it raises
an exception.

Using `head :ok` and adding a test for this scenario solves the issue.
2020-04-24 15:43:54 +02:00
Javi Martín
6c0365d004 Fix moving CKEditor dialog in specs
CKEditor repositions the dialog to attach an image after showing it. If
its position changes right when Capybara is trying to click the "Upload"
link, the click does not work properly.

I haven't found a way to check the dialog has stopped moving, so I've
chosen to force its position to the top.

Without this change, this test failed a lot on my machine when using
Rails 5.1, both with an "iframe ckeditor" and an "inline ckeditor".
However, it didn't fail when using Rails 5.0.
2020-04-24 15:43:54 +02:00
Javi Martín
e316ad9c96 Bump byebug to version 11.1.1
Rails 5.1 updated the `method_source` dependency, which is incompatible
with pry 0.12.x (which some developers are using), and upgrading pry and
pry-byebug requires a more recent version of byebug.
2020-04-24 15:43:54 +02:00
Javi Martín
e6c747c96c Only load seeds once while testing
Since we use transactions now for every test, we can seed the database
at the beginning, and then it will go back to this state before a test
is executed.

Running the test suite is now considerably faster. On my machine, we
save a quarter of second per system test, meaning we save several
minutes for the whole suite.
2020-04-24 15:43:54 +02:00
Javi Martín
1c8a49615a Fix references to Capybara.app_host
We were manually setting `http://www.example.com`. However, Capybara now
uses `http://127.0.0.1`.

While we could change the code to use `127.0.0.1`, I think directly
using `Capybara.app_host` makes it easier to realize what the code is
doing. And, particularly, now it's clear the host has nothing to do with
our `Setting["url"]`, which by default points to `www.example.com` as
well.
2020-04-24 15:43:54 +02:00
Javi Martín
9427f01442 Use system specs instead of feature specs
We get rid of database cleaner, and JavaScript tests are faster because
between tests we now rollback transactions instead of truncating the
database.
2020-04-24 15:43:54 +02:00
Javi Martín
12774c7484 Replace attribute_changed? in after callbacks
This method is deprecated in Rails 5.1 because its behavior will be
different in `before` and `after` callbacks.

We're replacing the deprecated `attribute_changed?` and `attribute_was`
methods with `saved_change_to_attribute?` and
`attribute_before_last_save` during `after_save` callbacks.

https://github.com/rails/rails/pull/32835/
2020-04-24 15:43:54 +02:00
Javi Martín
c6a8aa1301 Replace attribute_changed? in before callbacks
This method is deprecated in Rails 5.1 because its behavior will be
different in `before` and `after` callbacks.

Here we're replacing the deprecated `attribute_changed?` and
`attribute_was` with `will_save_change_to_attribute?` and
`attribute_in_database` during `before_save` callbacks.

https://github.com/rails/rails/pull/32835/
2020-04-24 15:43:54 +02:00
Javi Martín
1118c732f1 Bump acts-as-taggable-on to 6.0.0
Rails 5.1 introduced certain changes in the way a record is touched when
the counter cache option is enabled in a belongs to association.

We need to upgrade acts-as-taggable-on so it keeps changing the
`updated_at` attribute when a new tag is added to a record.

Note we now need to reload the records in some cases to get the
`context_tag_list` method to return what we expect. Methods like
`context_tags` however work properly with no need to reload the record.
2020-04-23 18:49:43 +02:00
Javi Martín
3526aef1e4 Remove callback terminator initializer
We no longer need it since this is the default behavior in Rails 5.1.
2020-04-23 18:49:43 +02:00
Javi Martín
1de1cb0353 Use Rails 5.1 schema file format
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

https://github.com/rails/rails/pull/25675

We're sorry for developers who are really concerned about code
alignment.
2020-04-23 18:49:43 +02:00
Javi Martín
31fa6b8bde Upgrade Rails to 5.1
Note we need to upgrade the bullet gem, although another option would be
to remove it completely.

Now we don't need the rubocop rules for deprecated methods, since using
them will raise an error and we'll be notified immediately.
2020-04-23 18:49:43 +02:00
Javier Martín
f56306ff7d Merge pull request #3983 from rockandror/ckeditor-table-plugin-addons
Add ckeditor tabletools plugin
2020-04-23 18:49:26 +02:00
Senén Rodero Rodríguez
103726f24a Add ckeditor tabletools plugin
This plugin provides more control over tables and solves a JS error thrown
when user clicks on "Cell properties" ckeditor feature.

https://ckeditor.com/cke4/addon/tabletools
2020-04-23 18:18:26 +02:00
Javier Martín
082fc1a1b6 Merge pull request #3981 from rockandror/disable-ckeditor-unused-plugins
Disable ckeditor unused plugins
2020-04-23 13:06:50 +02:00
Javier Martín
2e4ff552c6 Merge pull request #3977 from consul/fix_ckeditor_drag_drop
Fix attaching images in CKEditor via drag and drop
2020-04-23 13:03:48 +02:00
Senén Rodero Rodríguez
9fd9ef8a54 Explicitly disable not used ckeditor plugins
All of these plugins are not used anywhere.

Change introduced at ckeditor initializer will ommit unneeded
precompilation of plugins assets on production environments.

Change introduced at ckeditor config file adresses the problem with assets
pipeline fallback on testing environments described here: #2711. Now plugins
that are explicitly disabled will not be precomiled when running ckeditor
javascript enabled feature specs.
2020-04-23 10:37:26 +02:00
Javier Martín
b2d64b20ed Merge pull request #3979 from rockandror/ckeditor-recover-copy-paste
Allow to paste formatted content into ckeditors
2020-04-22 14:57:12 +02:00
Javier Martín
5a80548fc8 Merge pull request #3973 from consul/cards-height
Replace equalizer to display flex on cards
2020-04-21 14:00:02 +02:00
decabeza
caedd21da8 Move cards to shared partials 2020-04-21 12:54:16 +02:00
Senén Rodero Rodríguez
58645d0146 Enable pastefromword plugin 2020-04-20 22:12:28 +02:00
Senén Rodero Rodríguez
1e3f7e0062 Allow to paste formatted content into ckeditors 2020-04-20 20:27:00 +02:00
Javi Martín
8e4f9d5173 Fix attaching images in CKEditor via drag and drop
The URL used for the generated request was
`/ckeditor/pictures&responseType=json`. This is a known issue in the
ckeditor gem, and it's suggested to add a `?` at the end of the URL in
order to fix it.

I haven't added a test for this case since simulating dropping a file in
the browser with Selenium/Capybara seems to be quite tricky and I
haven't found a solution guaranteed to correctly emulate what users do.
2020-04-18 12:39:30 +02:00
Javier Martín
56bc0c6e41 Merge pull request #3976 from rockandror/deactivate-ckeditor-file-attachment
Deactivate ckeditor file attachments feature
2020-04-18 12:38:31 +02:00
Senén Rodero Rodríguez
7466148408 Deactivate ckeditor file uploads feature
This feature was not working so its better to disable it completely.

By removing attachment_files endpoints related buttons and tabs from ckeditor UI are not shown to users anymore.
2020-04-18 09:21:25 +02:00
Javier Martín
87e6ed5bfb Merge pull request #3972 from consul/icon-comments
Replaces icons of expand/collapse comments
2020-04-17 19:44:43 +02:00
decabeza
111e3d3083 Replaces icons of expand/collapse comments 2020-04-16 23:22:14 +02:00
Javier Martín
526d161e2d Merge pull request #3975 from consul/fix_check_for_nil
Fix checking for nil in page content
2020-04-16 13:17:30 +02:00
Javi Martín
1c471d2f98 Fix checking for nil in page content
We were getting a warning: "Checking for expected text of nil is
confusing and/or pointless since it will always match. Please specify a
string or regexp instead" because we were checking for values which were
set to `nil` in the tests.
2020-04-16 12:51:17 +02:00
Javier Martín
cd8c74c7e1 Merge pull request #3974 from consul/action_view_in_specs
Don't include unneeded helpers in tests
2020-04-16 12:35:50 +02:00
Javi Martín
95a90b1895 Simplify method to calculate document max size
Since we're only doing the convertion from bytes to megabytes in one
place, IMHO adding an extra method makes the code harder to read.

This way we don't have do include the DocumentsHelper in the specs
anymore, reducing the risk of possible method naming collisions.
2020-04-16 12:08:09 +02:00
Javi Martín
ca2dc10ee9 Simplify method to check an image max size
We were converting megabytes to bytes with the `megabytes` method and
then adding a `bytes_to_megabytes` method to convert it back to bytes,
which is the same as not doing anything at all :).
2020-04-16 12:08:09 +02:00
Javi Martín
2cd4696244 Don't include unneeded helpers in tests
Including them might lead to conflicts since two methods might have the
same name. For example, we're getting some exceptions when taking
screenshots of a failing test, because the method `image_path` from
`ActionView::Helpers::AssetUrlHelper` has the same name as a method used
to save the screenshot.

Besides, we were including all helpers in places were only the `dom_id`
method is used, and in other places where no helper methods were used at
all. So we can just invoke `ActionView::RecordIdentifier.dom_id`
directly.
2020-04-16 12:08:09 +02:00
Javi Martín
7491f44d54 Remove unused shared specs
These tests aren't used since commit 4db54092.
2020-04-16 00:00:38 +02:00
decabeza
a8537f7e19 Replace equalizer to display flex on cards 2020-04-14 17:14:52 +02:00
Paweł Świątkowski
d99875cde2 Get search dictionary based on I18n.default_locale (merge pull request #3856)
Implementation tries to be open for further extensions, such as deciding on
search dictionary based on configuration option or by locale set for
given user.
2020-04-12 14:22:36 +02:00
Javier Martín
426c1c5fd2 Merge pull request #3969 from consul/fix_legislation_tag_order
Order legislation process tags alphabetically
2020-04-10 21:14:29 +02:00
Javi Martín
4b043f2207 Order legislation process tags alphabetically
The method `tag_list_on` doesn't add an `ORDER_BY` clause to the SQL
query it generates, and so results may come in any order.

However, in the tests we were assuming the tags were ordered by ID in
descending order. Since that isn't always the case, the tests were
failing sometimes.

Ordering the tags alphabetically solves the problem. We could also use
the same order admins used when adding the tags:

```
@process.customs.order("taggings.created_at").pluck(:name).join(", ")
```

However, I'm not sure it improves the user experience, and it makes the
code more complicated.
benefit to administratos.
2020-04-10 20:36:17 +02:00
Javier Martín
c9a95c1818 Merge pull request #3968 from consul/fix_flaky_ckeditor_spec
Fix flaky spec: Admin Active polls Add
2020-04-10 17:47:49 +02:00
Javi Martín
2cdc6a1b1b Check CKEditor is filled properly in tests
It looks like sometimes, particularly when the first thing we do after
loading a page is filling the CKEditor fields and submitting the form,
CKEditor doesn't have enough time to format the text, and so it's sent
as plain text instead of HTML. This behaviour can be reproduced on my
local machine after upgrading to Rails 5.1, with the test "Admin Active
polls Add" failing 100% of the time.

Checking CKEditor has been filled in correctly solves the issue.
2020-04-10 17:11:56 +02:00
Javi Martín
a0ea1f6ecb Simplify CKEditor translatable fields in specs
We've simplified the way CKEditor is handled in tests; probably due to
that, we don't need this method anymore.
2020-04-10 15:14:15 +02:00
Javier Martín
06bc72cc66 Merge pull request #3959 from consul/i18n-custom-translations
Fix custom translations with options
2020-04-10 12:51:23 +02:00
decabeza
af1e11838c Fix custom translations with options 2020-04-10 12:17:27 +02:00
Javier Martín
afea0feb96 Merge pull request #3967 from consul/duplicate_by_tag
Fix duplicate records in investments by tag
2020-04-09 21:47:35 +02:00
Javi Martín
958d373247 Fix duplicate records in investments by tag
When an investment had been assigned a user tag and a valuation tag with
the same name, it appeared twice when filtering by tag.

This is because by design, in order to provide compatibility with scopes
using "select" or "distinct", the method `tagged_with` doesn't select
unique records.

Forcing the query to return unique records solves the issue.
2020-04-09 21:09:28 +02:00
Javier Martín
b5682362b7 Merge pull request #3966 from consul/remove_unused_filter
Remove unused tag filter
2020-04-09 21:08:42 +02:00
Javier Martín
54095c4765 Merge pull request #3940 from andrewcameronsims/feature/3557-add_title_to_differentiate_signature_sheets
Add title to differentiate signature sheets
2020-04-09 12:46:33 +02:00
Andrew Sims
95c82d8777 Changes following PR review
* Internationalisation for admin fields
* Correct typos
* Additional tests
* Replace ternary with if-then statement
2020-04-09 07:11:53 +10:00
Cassiano Sampaio
1e4f539104 Add title to differentiate signature sheets 2020-04-09 07:11:52 +10:00