Commit Graph

952 Commits

Author SHA1 Message Date
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
6d6eb1f849 Fix ambiguous field in test 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
3b5a12b0ab Don't force translations for the current locale
Globalize creates a translation for the current locale, and the only way
I've found to change this behaviour is to monkey-patch it.

The original code uses `translation.locale` instead of
`Globalize.locale`. Since `translation.locale` loads the translation
with empty attributes. It both makes the record invalid if there are
validations and it makes it almost impossible to create a record with
translations which don't include the current locale.

See also the following convertations:

https://github.com/globalize/globalize/pull/328
https://github.com/globalize/globalize/issues/468
https://github.com/globalize/globalize/pull/578
https://github.com/shioyama/mobility/wiki/Migrating-from-Globalize#blank-translations
2018-10-22 16:28:53 +02:00
Javi Martín
139cf769c6 Update widget cards translatable fields 2018-10-22 16:28:49 +02:00
Javi Martín
3c170f47d2 Update site customization pages translatable fields 2018-10-22 16:13:48 +02:00
Javi Martín
e0b9c1bfdd Update poll question answers translatable fields
We needed to bring back support for CKEditor in our translatable form,
which we had temporarily remove.

And now we support CKEditor in our translatable specs, and so we can
remove the duplicated specs for poll question answers.
2018-10-22 16:13:48 +02:00
Javi Martín
d1249d0b4f Update poll questions translatable fields
We need to replace ".title=" by ".title_#{locale}=" in one place because
for some reason globalize builds a new translation record when using the
latter but it doesn't build one when using the former.
2018-10-22 16:13:30 +02:00
Javi Martín
759de935ee Update polls translatable fields
The `:name` attribute is still allowed in the controller because some
forks use it when creating a poll from a budget.
2018-10-22 15:52:58 +02:00
Javi Martín
85701bd754 Update legislation questions translatable fields 2018-10-22 15:46:24 +02:00
Javi Martín
5bfc7ca2e3 Update legislation process translatable fields 2018-10-22 15:46:16 +02:00
Javi Martín
6278175f57 Update legislation drafts translatable fields
Updating it required reorganizing the form so translatable fields are
together.

We also needed to add a `hint` option to the form label and input
methods so the hint wouldn't show up for every language.

Finally, the markdown editor needed to use the same globalize attributes
as inputs, labels and hints, which adds a bit of duplication.
2018-10-22 15:44:14 +02:00
Javi Martín
01a254545f Update milestones translatable fields
Note the title field was hidden since commit 01b9aa8, even though it was
required and translatable. I've removed the required validation rule,
since it doesn't seem to make much sense and made the translatable
tests harder to write.

Also note the method `I18n.localize`, which is used to set the
milestone's title, uses `I18n.locale` even if it's inside a
`Globalize.with_locale` block, and so the same format is generated for
every locale.
2018-10-22 15:44:14 +02:00
Javi Martín
a326bcb0a1 Update admin notifications translatable fields
The same way we did for banners.

We needed to add new translation keys so the labels are displayed in the
correct language. I've kept the original `title` and `body` attributes
so they can be used in other places.

While backporting, we also added the original translations because they
hadn't been backported yet.
2018-10-22 15:43:56 +02:00
Javi Martín
71601bd3f8 Validate translations in banners
This change forces us to use nested attributes for translations, instead
of using the more convenient `:"title_#{locale}"` methods.

On the other hand, we can use Rails' native `_destroy` attribute to
remove existing translations, so we don't have to use our custom
`delete_translations`, which was a bit buggy since it didn't consider
failed updates.
2018-10-22 15:43:28 +02:00
decabeza
546105d989 Merge branch 'master' into dashboard-master 2018-10-19 01:48:37 +02:00
Alberto
3878946c9e Merge pull request #2823 from consul/remove-guides
Removes guide feature
2018-10-18 13:19:33 +02:00
Javier Martín
e117218d68 Merge pull request #2977 from consul/backport-reenable_ckeditor_images
Bring back CKEditor images button
2018-10-17 20:21:18 +02:00
Javi Martín
6f96265a0b Bring back CKEditor images button
It was accidentally deleted in commit 914bfa6.

Note the following spec passes on my machine if we add a `sleep 0.1`
call in the `:wait_readable` part of ruby's `Net::Protocol#rbuf_fill`.
Otherwise, it hangs forever after clicking the `.fileupload-file` div,
which closes its window. It might be solved when upgrading rails,
capybara, selenium or chromedriver.

scenario "Allows images in CKEditor", :js do
  visit edit_admin_site_customization_page_path(custom_page)

  within(".ckeditor") do
    within_frame(0) { expect(page).not_to have_css("img") }

    expect(page).to have_css(".cke_toolbar .cke_button__image_icon")
    find(".cke_toolbar .cke_button__image_icon").click
  end

  within_window(window_opened_by { click_link "Browse Server" }) do
    attach_file :file,
                Rails.root.join('spec/fixtures/files/clippy.jpg'),
                visible: false
    find(".fileupload-file").click
  end

  click_link "OK"

  within(".ckeditor") do
    within_frame(0) { expect(page).to have_css("img") }
  end
end
2018-10-17 19:39:37 +02:00
Javi Martín
893f29a27a Fix flaky legislation question spec
The test was failing sometimes because of the sequence:

within('#side_menu') do
  click_link "Collaborative Legislation"
end

click_link "All"
expect(page).to have_content 'An example legislation process'
click_link 'An example legislation process'

Right after clicking the "Collaborative Legislation" link, the link 'An
example legislation process' is already available. So sometimes Capybara
might click the links "All" and 'An example legislation process' at more
or less the same time, causing the second link not to be correctly
clicked.

Making sure the "All" link doesn't exist anymore we guarantee Capybara
will wait for the previous AJAX request to finish before clicking the
next link.

Note the test to "Create Valid legislation question" is almost identical
but it doesn't fail because it doesn't use Capybara's JavaScript driver.
2018-10-17 15:54:59 +02:00
decabeza
dbf41421ed Removes guide feature 2018-10-17 14:58:29 +02:00
Pierre Mesure
f586190651 Removed icon_home and fixed corresponding test 2018-10-12 09:52:53 +02:00
decabeza
2dae197eaa Updates i18n 2018-10-11 17:54:03 +02:00
Javi Martín
0945f046a3 Avoid using xpath in specs
Using xpath is usually harder to read and more fragile.
2018-10-04 16:31:00 +02:00
Javi Martín
959270b0bb Separate setup, actions and expections in specs 2018-10-04 16:31:00 +02:00
Javi Martín
2fb5fb5fb2 Add missing newline characters 2018-10-04 16:31:00 +02:00
Javi Martín
81871a56f8 Simplify legislation process specs
We kill two birds with one stone and also make each line less than 100
characters long.
2018-10-04 16:30:59 +02:00
Javi Martín
7d69f2aaab Properly test order by ID
By default records are already ordered by ID, so we weren't checking the
ordering by ID functionality was working properly.

Making the records be ordered by title first makes the test a bit more
reliable.
2018-10-04 16:29:01 +02:00
Javi Martín
dc9cf5da55 Order by supports in descending order
Just as we do with confidence score, and as admins expect when they
order by received supports: the ones with more supports appear first.
2018-10-04 16:29:01 +02:00
Javi Martín
75d1ab1e52 Use AJAX requests to select legislation proposals
Now the interface is more similar to the one in budget investments.
2018-10-04 16:29:01 +02:00
Raúl Fuentes
a859de5d16 Test the selectable proposals 2018-10-04 16:29:01 +02:00
Javier Martín
132fea9c94 Merge pull request #2913 from papayalabs/2741-updates-translatable-custom-pages-reloaded
Updates translatable custom pages
2018-10-03 13:23:13 +02:00
Papaya Labs
3f9dea080b Check title and slug in spec 2018-09-28 09:43:00 +02:00
Papaya Labs
914bfa645e Updates translatable custom pages 2018-09-27 13:46:17 +02:00
Juan Salvador Pérez García
488e7e081f Merge branch 'dashboard' into rebase_consul_master 2018-09-27 09:18:27 +02:00
Javi Martín
5bb5cfa7fb Make Widget::Card translatable 2018-09-26 16:09:09 +02:00
Raimond Garcia
4086220ebf Merge pull request #2914 from microweb10/make_polls_translatable
Make polls translatable
2018-09-26 13:19:17 +02:00
Raimond Garcia
1fbb428004 Merge pull request #2898 from papayalabs/2889-show-active-tab-in-custom-info-texts
Show active tab in custom info texts
2018-09-24 21:11:25 +02:00
Papaya Labs
45da512ce9 Add Spec 2018-09-24 20:38:42 +02:00
Javier Martín
ef0192c3ff Merge pull request #2912 from consul/backport-make-collaborative-legislation-translatable
Make collaborative legislation translatable
2018-09-24 17:45:59 +02:00
Javier Martín
758d3f8541 Merge pull request #2911 from consul/backport-fix_time_related_specs
Fix time related specs
2018-09-24 17:43:22 +02:00
Julian Herrero
df9955e0c6 make use of the new spec helper it_behaves_like translatable 2018-09-21 20:52:35 +02:00
Julian Herrero
673ec075eb Make answers translatable 2018-09-20 17:13:40 +02:00
Julian Herrero
5e6248d2ac Make questions translatable 2018-09-20 17:11:53 +02:00
Julian Herrero
9495208518 Make polls translatable 2018-09-20 17:07:43 +02:00
Javi Martín
4d238c5d07 Fix crash updating legislation process categories
We were expecting translation parameters in legislation processes
`update` action. However, those parameters aren't sent when we get to
that action through the "proposals" tab.
2018-09-19 14:54:52 +02:00
Javi Martín
58ad333791 Remove duplicate lines 2018-09-19 14:54:52 +02:00
Marko Lovic
64d72ca8e7 Enable JS in shared translatable test
Due to its markdown editor, the admin draft version page
requires JS to correctly render the draft version form.
2018-09-19 14:54:24 +02:00
Marko Lovic
05bfa193cd Make Legislation Draft Versions translatable 2018-09-19 14:54:24 +02:00