Commit Graph

9967 Commits

Author SHA1 Message Date
voodoorai2000
a303a60f65 Update version number for consul.json 2018-10-31 16:40:34 +01:00
voodoorai2000
56f1ae2009 Add Changelog for release 0.17 2018-10-31 13:40:42 +01:00
Javier Martín
6c21766511 Merge pull request #2992 from consul/backport-cleanup_newsletter
Newsletter updates
2018-10-31 11:52:08 +01:00
voodoorai2000
42d4fd880f Increase delayed jobs max run time 2018-10-30 17:11:13 +01:00
voodoorai2000
7d5b57aee2 Add counter of emails sent to newsletter preview 2018-10-30 17:07:31 +01:00
Javier Martín
bc77812ae8 Merge pull request #2990 from consul/backport-remove_described_class_cop
Remove described class cop
2018-10-29 14:38:43 +01:00
Javier Martín
65dc4b2ea3 Merge pull request #2989 from consul/backport-2734_consul_related-fix_flaky_comments_spec
Fix flaky specs: proposals and legislation Voting comments Update
2018-10-29 14:16:39 +01:00
Javier Martín
c0b8bd98db Merge pull request #2987 from consul/houndci_basic
Add Hound basic configuration
2018-10-29 14:06:43 +01:00
Javi Martín
4cbe81a142 Remove described class cop
We've agreed `User.new` is easier to read than `described_class.new` and
since we are ignoring Hound's comments regarding this topic, we might as
well remove it.
2018-10-29 13:58:00 +01:00
Javi Martín
74927f4ed6 Make Capybara check the page between comment votes
As pointed out in PR consul#2734:

"After clicking the first link, there's an AJAX request which replaces
the existing `.in-favor a` and `.against a` links with new elements. So
if Capybara tries to click the existing `.against a` link at the same
moment it's being replaced, clicking the link won't generate a new
request".

Making Capybara check the page for new content before clicking the
second link solves the problem.

This commit solves issues afecting both Madrid's fork and the original
CONSUL repo.
2018-10-29 11:15:03 +01:00
Javier Martín
e7f05a5711 Merge pull request #2986 from consul/backport-migrate_globalize_data
Migrate globalize data
2018-10-26 12:23:53 +02:00
Javier Martín
f987383c14 Merge pull request #2985 from consul/backport-2875-translatable_bugs
Fix translatable bugs
2018-10-26 12:23:19 +02:00
Javi Martín
7794690b8c Enable SCSS rules in Hound 2018-10-26 12:13:06 +02:00
Javi Martín
4048d17203 Add basic rubocop configuraton for Hound
This way we can ask contributors to follow some basic guidelines like
removing trailing whitespaces while not overwhelming them with all our
rules.
2018-10-26 11:46:17 +02:00
Javi Martín
48140f74e9 Remove rubocop_todo file
No developers are maintaining it anymore.
2018-10-26 11:46:10 +02:00
Javi Martín
9404cb8b3a Fix bug with non-underscored locales
Ruby can't have hyphens in method names, so sending something like
`record.title_pt-BR` would raise an exception.

Using globalize's `localized_attr_name_for` method fixes the bug.

Thanks Marko for the tip.
2018-10-23 16:29:14 +02:00
Javi Martín
934bce5932 Don't abort the migration if the simulation fails
We think aborting the migration will generate more headaches to system
administrators, who will have to manually check and fix every invalid
record before anything can be migrated.
2018-10-23 16:29:14 +02:00
Javi Martín
7fff57a25f Add task to simulate data migration
This way we can check everything is OK before actually migrating the
data to the translations tables.
2018-10-23 16:29:14 +02:00
Javi Martín
3c48059f07 Log failed data migrations
In theory, it should never happen, but that's why exceptions exist.
2018-10-23 16:29:13 +02:00
Javi Martín
be25e5fc45 Use migrate_data option for globalize
This way the task to migrate the data doesn't have to be run manually if
these migrations weren't already executed.
2018-10-23 16:29:13 +02:00
Javi Martín
a84a0f2b7d Migrate custom pages data to their locale 2018-10-23 16:29:13 +02:00
Javi Martín
ef7be4fc55 Add task to migrate data to translation tables
We forgot to do it when we created the translation tables, and so now we
need to make sure we don't overwrite existing translations.
2018-10-23 16:29:13 +02:00
Javi Martín
ccdbdb26ba Fix poll question with non-underscored locales
Ruby can't have hyphens in method names, so sending something like
`title_pt-BR=` would raise an exception.
2018-10-23 14:23:10 +02:00
Javi Martín
b8673c1cbf Fix spec assuming German isn't available
Since we've recently added German to the available languages, and we
might support every language in the future, we're using the fictional
world language to check a locale which isn't available.

Another option could be to set the available locales in the test
environment (or the rspec helper), but then we'd have to make sure it's
executed before the call to `globalize_accessors` in the model, and it
might be confusing for developers.
2018-10-23 13:58:22 +02:00
Javi Martín
2a1b50beba Extract method to render form fields for a locale 2018-10-22 16:36:18 +02:00
Javi Martín
361a15640f Use detect instead of select.first 2018-10-22 16:36:18 +02:00
Javi Martín
93a7cb6c0f Simplify code checking whether to enable a locale 2018-10-22 16:36:18 +02:00
Javi Martín
f5bb3c64a1 Don't run specs if there are custom fallbacks
This spec depends on French falling back to Spanish and was failing on
forks using a different fallback.
2018-10-22 16:36:18 +02:00
Javi Martín
2e6644d513 Fix crash with no translation for default locale
When we were visiting a page showing the content of a record which uses
globalize and our locale was the default one and there was no
translation for the default locale, the application was crashing in some
places because there are no fallbacks for the default locale.

For example, when visiting a legislation process, the line with
`CGI.escape(title)` was crashing because `title` was `nil` for the
default locale.

We've decided to solve this issue by using any available translations as
globalize fallbacks instead of showing a 404 error or a translation
missing error because these solutions would (we thinkg) either require
modifying many places in the application or making the translatable
logic even more complex.

Initially we tried to add this solution to an initializer, but it must
be called after initializing the application so I18n.fallbacks[locale]
gets the value defined in config.i18n.fallbacks.

Also note the line:

fallbacks[locale] = I18n.fallbacks[locale] + I18n.available_locales

Doesn't mention `I18n.default_locale` because the method
`I18n.fallbacks[locale]` automatically adds the default locale.
2018-10-22 16:36:18 +02:00
Javi Martín
5e8746f026 Remove question option uniqueness validation
Having translations makes this validation too complex and not worth the
effort, since now we can't just scope in a single column but we need to
scope in the translations locale and the question ID.
2018-10-22 16:36:18 +02:00
Javi Martín
9105ac3a69 Prefix classes used in JavaScript with "js-"
The same way it's done in the rest of the application.
2018-10-22 16:36:18 +02:00
Javi Martín
1895e2dd2f Make it easier to know destroy_field is an input
By using the input and finding it by its name, it's easier to see the
difference between this input and the delete-language link.
2018-10-22 16:36:18 +02:00
Javi Martín
dbea577062 Follow naming conventions for HTML classes and IDs
We use underscores for IDs and hyphens for classes.
2018-10-22 16:36:18 +02:00
Javi Martín
08c043425a Remove reference to site customization page locale
We don't use that attribute since we added translations for this model.
2018-10-22 16:36:18 +02:00
Javi Martín
5511a3a194 Fix "Add option" link position
The new options were being added inside the `.column` div, when they
needed to be added before it.
2018-10-22 16:36:17 +02:00
Javi Martín
01315f2695 Fix rubocop line too long warning 2018-10-22 16:36:17 +02:00
Javi Martín
0505028d77 Extract method in translatable builder
This way we fix the rubocop warning for line too long and make the code
a bit easier to read.
2018-10-22 16:36:17 +02:00
Javi Martín
f1ccdb87b1 Fix removing an option for legislation questions
We were allowing the `_destroy` field for translations, but not for the
options themselves.
2018-10-22 16:36:17 +02:00
Javi Martín
6952c9c9db Fix legislation options not being updated
We broke this behaviour by introducing translations and not allowing the
`id` parameter anymore.
2018-10-22 16:36:17 +02:00
Javi Martín
3db145d5db Simplify creating a process in questions specs 2018-10-22 16:36:17 +02:00
Javi Martín
34b5a88564 Fix updating translatables without current locale
The current locale wasn't being marked for destruction and so saving
the record tried to create a new translation for the current locale.
2018-10-22 16:36:17 +02:00
Javi Martín
21cf39d5ed Fix alignment in last translatable fields
When we grouped the fields together, the last one turned into a
`last-child`, which foundation automatically aligns to the right.

The markdown editor also needed to be tweaked a little bit.
2018-10-22 16:36:17 +02:00
Javi Martín
6d6eb1f849 Fix ambiguous field in test 2018-10-22 16:36:17 +02:00
Javi Martín
1255aa5032 Make private methods private 2018-10-22 16:36:17 +02:00
Javi Martín
7479223d59 Wrap translation fields in a div
This way we can show/hide that div when displaying translations, and we
can remove the duplication applying the same logic to the label, the
input, the error and the CKEditor.

This way we also solve the problem of the textarea of the CKEditor
taking space when we switch locales, as well as CKEditor itself taking
space even when not displayed.
2018-10-22 16:36:17 +02:00
Javi Martín
ffb8207f84 Show error message for just the displayed locale
Unfortunately the builder didn't offer any options for the error message
and we just had to overwrite the `error_for` methods.
2018-10-22 16:36:17 +02:00
Javi Martín
00983200d4 Update information texts translatable fields
This part used the code we deleted in order to make it easier to
refactor the rest of the translatable models. Now we add the code back.
2018-10-22 16:36:12 +02:00
Javi Martín
387b345f77 Refactor globalize_locales partials to increase DRYness 2018-10-22 16:35:01 +02:00
Angel Perez
074eb872a4 Improve I18nContent#flat_hash readability using concise variable names 2018-10-22 16:35:01 +02:00
Angel Perez
1835bac7e4 Avoid ternary operator usage when appending/creating I18n keys
When using the OR operator, if the left side of the expression evaluates
to false, its right side is taken into consideration. Since in Ruby nil
is false, we can avoid using conditionals for this particular scenario
2018-10-22 16:35:01 +02:00