-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
poll_question_answers_spec.rb
149 lines (104 loc) · 5.15 KB
/
poll_question_answers_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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# coding: utf-8
require 'rails_helper'
feature "Translations" do
context "Polls" do
let(:poll) { create(:poll, name_en: "Name in English",
name_es: "Nombre en Español",
summary_en: "Summary in English",
summary_es: "Resumen en Español",
description_en: "Description in English",
description_es: "Descripción en Español") }
background do
admin = create(:administrator)
login_as(admin.user)
end
context "Questions" do
let(:question) { create(:poll_question, poll: poll,
title_en: "Question in English",
title_es: "Pregunta en Español") }
context "Answers" do
let(:answer) { create(:poll_question_answer, question: question,
title_en: "Answer in English",
title_es: "Respuesta en Español",
description_en: "Description in English",
description_es: "Descripción en Español") }
before do
@edit_answer_url = edit_admin_answer_path(answer)
end
scenario "Add a translation", :js do
visit @edit_answer_url
select "Français", from: "translation_locale"
fill_in 'poll_question_answer_title_fr', with: 'Answer en Français'
fill_in_ckeditor 'poll_question_answer_description_fr', with: 'Description en Français'
click_button 'Save'
expect(page).to have_content "Changes saved"
expect(page).to have_content "Answer in English"
expect(page).to have_content "Description in English"
select('Español', from: 'locale-switcher')
expect(page).to have_content "Respuesta en Español"
expect(page).to have_content "Descripción en Español"
select('Français', from: 'locale-switcher')
expect(page).to have_content "Answer en Français"
expect(page).to have_content "Description en Français"
end
scenario "Update a translation with allowed blank translated field", :js do
visit @edit_answer_url
click_link "Español"
fill_in 'poll_question_answer_title_es', with: 'Pregunta correcta en Español'
fill_in_ckeditor 'poll_question_answer_description_es', with: ''
click_button 'Save'
expect(page).to have_content "Changes saved"
expect(page).to have_content("Answer in English")
expect(page).to have_content("Description in English")
select('Español', from: 'locale-switcher')
expect(page).to have_content("Pregunta correcta en Español")
expect(page).to_not have_content("Descripción en Español")
end
scenario "Remove a translation", :js do
visit @edit_answer_url
click_link "Español"
click_link "Remove language"
expect(page).not_to have_link "Español"
click_button "Save"
visit @edit_answer_url
expect(page).not_to have_link "Español"
end
scenario "Add a translation for a locale with non-underscored name", :js do
visit @edit_answer_url
select('Português brasileiro', from: 'translation_locale')
fill_in_ckeditor 'poll_question_answer_description_pt_br', with: 'resposta em Português'
click_button 'Save'
select('Português brasileiro', from: 'locale-switcher')
expect(page).to have_content("resposta em Português")
end
context "Globalize javascript interface" do
scenario "Highlight current locale", :js do
visit @edit_answer_url
expect(find("a.js-globalize-locale-link.is-active")).to have_content "English"
select('Español', from: 'locale-switcher')
expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español"
end
scenario "Highlight selected locale", :js do
visit @edit_answer_url
expect(find("a.js-globalize-locale-link.is-active")).to have_content "English"
click_link "Español"
expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español"
end
scenario "Show selected locale form", :js do
visit @edit_answer_url
expect(page).to have_field('poll_question_answer_title_en', with: 'Answer in English')
click_link "Español"
expect(page).to have_field('poll_question_answer_title_es', with: 'Respuesta en Español')
end
scenario "Select a locale and add it to the poll form", :js do
visit @edit_answer_url
select "Français", from: "translation_locale"
expect(page).to have_link "Français"
click_link "Français"
expect(page).to have_field('poll_question_answer_title_fr')
end
end
end
end
end
end