-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
localization_spec.rb
77 lines (59 loc) · 2.1 KB
/
localization_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'rails_helper'
feature 'Localization' do
scenario 'Wrong locale' do
Globalize.with_locale(:es) do
create(:widget_card, title: 'Bienvenido a CONSUL',
description: 'Software libre para la participación ciudadana.',
link_text: 'Más información',
link_url: 'http:https://consulproject.org/',
header: true)
end
visit root_path(locale: :es)
visit root_path(locale: :klingon)
expect(page).to have_text('Bienvenido a CONSUL')
end
scenario 'Available locales appear in the locale switcher' do
visit '/'
within('.locale-form .js-location-changer') do
expect(page).to have_content 'Español'
expect(page).to have_content 'English'
end
end
scenario 'The current locale is selected' do
visit '/'
expect(page).to have_select('locale-switcher', selected: 'English')
end
scenario 'Changing the locale', :js do
visit '/'
expect(page).to have_content('Language')
select('Español', from: 'locale-switcher')
expect(page).to have_content('Idioma')
expect(page).not_to have_content('Language')
expect(page).to have_select('locale-switcher', selected: 'Español')
end
scenario 'Locale switcher not present if only one locale' do
allow(I18n).to receive(:available_locales).and_return([:en])
visit '/'
expect(page).not_to have_content('Language')
expect(page).not_to have_css('div.locale')
end
context "Missing language names" do
let!(:default_enforce) { I18n.enforce_available_locales }
let!(:default_locales) { I18n.available_locales }
before do
I18n.enforce_available_locales = false
I18n.available_locales << :wl
I18n.locale = :wl
end
after do
I18n.enforce_available_locales = default_enforce
I18n.available_locales = default_locales
end
scenario 'Available locales without language translation display locale key' do
visit '/'
within('.locale-form .js-location-changer') do
expect(page).to have_content 'wl'
end
end
end
end