Commit Graph

21 Commits

Author SHA1 Message Date
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
Javi Martín
41c99d9b27 Let Globalize use I18n locale
This is a mistake I made in commit f2ef27d3. Back then I thought we
needed to keep Globalize.locale and I18n.locale in sync, but the truth
is it automatically happens when setting Globalize.locale to nil.

So now we can use I18n.with_locale (at least in the tests) and forget
about Globalize, which will make it easier to switch to Mobility in the
future.
2019-09-23 18:01:44 +02:00
Javi Martín
307cf24846 Use describe on feature tests
The `type: :feature` is automatically detected by RSpec because these
tests are inside the `spec/features` folder. Using `feature` re-adds a
`type: :feature` to these files, which will result in a conflict when we
upgrade to Rails 5.1's system tests.

Because of this change, we also need to change `background` to `before`
or else these tests will fail.
2019-05-28 16:36:54 +02:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Javi Martín
34e83292a9 Reload I18n after stubbing available locales
Not doing so might cause the following test to use translations for
only one locale. This scenario happens if the previous test executes
I18n.reload!, which resets I18n.config.backend's "@translations"
instance variable.

So, the sequence could be as follows:

1. The previous tests sets `@translations = nil`
2. This test stubs `available_locales` to `[:en]`
3. `@translations` gets only translations for `en`
4. The following test doesn't find translations for Spanish and fails
2018-12-10 20:37:30 +01:00
voodoorai2000
59b35156b1 Fix flaky spec
`I18n.available_locales=` does a little magic[1] and was causing some flakieness along the way, as the `:wl` locale persisted in future specs

Thanks for the heads up @javierm 👌

[1] https://www.rubydoc.info/github/svenfuchs/i18n/I18n%2FConfig:available_locales=
2018-10-09 22:15:05 +02:00
voodoorai2000
9d7042c5ae Adds missing language name translations 2018-10-05 18:08:47 +02:00
voodoorai2000
0a0261900c Display language name or language key
There where two issues with the current implementation:

- There was a possible duplication between looking up the language name in key "locale" and in key "i18n.language.name"

- The "default" option was not being picked up, as the fallback always returned the default locale's translation, "English"

With this implementation there is only a single place to put the language name: i18n.language.name. I think this place is easier to find and understand for Crowdin translators than a "locale" key hidden in general.yml

If the translation is not found we display the language key, instead of English, which makes more sense to me too 😌

Solution based on recent comments[1] on a related I18n issue

[1] https://github.com/svenfuchs/i18n/issues/365#issuecomment-419263847
2018-10-05 18:08:41 +02:00
Javi Martín
1ffaa680a3 Create correct translation when visiting root page
We set `I18n.locale = :en` before each test, and so creating a new card
will automatically create English translations.

So visiting the Spanish page won't show the card, since no Spanish
translation exists for it. If we visit the klingon page after doing so,
the last used locale (Spanish) will still be used, and so the test will
fail.

Specifically creating Spanish translations instead of the English ones
makes the translations visible when visiting the Spanish homepage.
2018-09-26 16:09:09 +02:00
decabeza
304143d051 Updates localization and home specs 2018-05-29 13:22:23 +02:00
Bertocq
34bb9d65b1 Enable RSpec/NotToNot cop and fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
2018-01-07 17:39:48 +01:00
Bertocq
c4aa2d7093 Enable RSpec/MessageExpectation cop & fix issues
There was 34 `allow` occurences and 17 `expect` occurences, so to be consistent `allow` form was chosen.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation
2018-01-07 16:36:18 +01:00
decabeza
dd0452ece6 updates texts on specs 2017-09-01 13:18:56 +02:00
kikito
b6af10a91f refactors localization spec using expect instead of global state 2015-10-20 19:08:52 +02:00
Alberto Garcia Cabeza
f1e95addaa Changes tests and comments unused keys 2015-09-10 19:29:05 +02:00
Juanjo Bazán
5af7bc1aee removes language switcher if only one locale 2015-09-03 23:47:55 +02:00
Alberto Garcia Cabeza
b0f7d74c47 Changes site language test, comment unused keys 2015-08-31 21:55:23 +02:00
kikito
934512ad7a made the locale switcher use less js, more ruby & html 2015-08-28 17:02:06 +02:00
Alberto Garcia Cabeza
42a0cffefc Adds new texts on header, debates and footer 2015-08-27 17:11:01 +02:00
Juanjo Bazán
b2f29215ee unifies localization specs 2015-08-19 22:51:58 +02:00
Fernando Seror
a89d621d1d Allow locale to be set through the front-end
* Store the last used locale in the session
* Allow home page to be identified in helpers even when containing
  parameters
* Create initializer to explicitly set the available locales, the
  default and the load_path
2015-08-05 15:43:39 -05:00