best_in_place 2.1.0 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -5
- data/.rspec +1 -0
- data/.travis.yml +12 -5
- data/Appraisals +17 -0
- data/CHANGELOG.md +51 -30
- data/Gemfile +15 -2
- data/README.md +52 -105
- data/best_in_place.gemspec +13 -11
- data/config.ru +7 -0
- data/gemfiles/rails_3.2.gemfile +24 -0
- data/gemfiles/rails_4.0.gemfile +23 -0
- data/gemfiles/rails_4.1.gemfile +23 -0
- data/gemfiles/rails_edge.gemfile +25 -0
- data/lib/assets/javascripts/best_in_place.jquery-ui.js +57 -0
- data/lib/assets/javascripts/best_in_place.js +551 -650
- data/lib/assets/javascripts/best_in_place.purr.js +16 -6
- data/lib/best_in_place.rb +29 -9
- data/lib/best_in_place/controller_extensions.rb +10 -13
- data/lib/best_in_place/display_methods.rb +26 -21
- data/lib/best_in_place/engine.rb +2 -2
- data/lib/best_in_place/helper.rb +145 -87
- data/lib/best_in_place/railtie.rb +5 -2
- data/lib/best_in_place/test_helpers.rb +0 -1
- data/lib/best_in_place/utils.rb +20 -12
- data/lib/best_in_place/version.rb +1 -1
- data/spec/{helpers/best_in_place_spec.rb → helper_spec.rb} +134 -99
- data/spec/integration/double_init_spec.rb +3 -5
- data/spec/integration/js_spec.rb +193 -123
- data/spec/integration/live_spec.rb +3 -4
- data/spec/integration/text_area_spec.rb +4 -4
- data/spec/internal/app/assets/images/info.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/no.png +0 -0
- data/spec/internal/app/assets/images/purrBottom.png +0 -0
- data/spec/internal/app/assets/images/purrClose.png +0 -0
- data/spec/internal/app/assets/images/purrTop.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/red_pen.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-icons_222222_256x240.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-icons_228ef1_256x240.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-icons_ef8c08_256x240.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-icons_ffd27a_256x240.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/ui-icons_ffffff_256x240.png +0 -0
- data/{test_app → spec/internal}/app/assets/images/yes.png +0 -0
- data/spec/internal/app/assets/javascripts/application.js +37 -0
- data/{test_app → spec/internal}/app/assets/stylesheets/.gitkeep +0 -0
- data/{test_app → spec/internal}/app/assets/stylesheets/jquery-ui-1.8.16.custom.css.erb +1 -2
- data/{test_app → spec/internal}/app/assets/stylesheets/scaffold.css +1 -1
- data/{test_app → spec/internal}/app/assets/stylesheets/style.css.erb +2 -4
- data/{test_app → spec/internal}/app/controllers/admin/users_controller.rb +8 -3
- data/{test_app → spec/internal}/app/controllers/application_controller.rb +0 -0
- data/{test_app → spec/internal}/app/controllers/cuca/cars_controller.rb +0 -0
- data/{test_app → spec/internal}/app/controllers/users_controller.rb +8 -40
- data/{test_app → spec/internal}/app/helpers/application_helper.rb +0 -0
- data/spec/internal/app/helpers/users_helper.rb +29 -0
- data/{test_app → spec/internal}/app/models/cuca/car.rb +0 -0
- data/{test_app → spec/internal}/app/models/user.rb +5 -1
- data/{test_app → spec/internal}/app/views/admin/users/show.html.erb +2 -2
- data/{test_app → spec/internal}/app/views/cuca/cars/show.html.erb +0 -0
- data/{test_app → spec/internal}/app/views/layouts/application.html.erb +1 -1
- data/{test_app → spec/internal}/app/views/users/_form.html.erb +2 -2
- data/{test_app → spec/internal}/app/views/users/double_init.html.erb +4 -10
- data/spec/internal/app/views/users/edit.html.erb +5 -0
- data/{test_app → spec/internal}/app/views/users/email_field.html.erb +0 -0
- data/{test_app → spec/internal}/app/views/users/index.html.erb +0 -0
- data/{test_app → spec/internal}/app/views/users/new.html.erb +0 -0
- data/{test_app → spec/internal}/app/views/users/show.html.erb +32 -24
- data/{test_app → spec/internal}/app/views/users/show_ajax.html.erb +0 -0
- data/spec/internal/config/database.yml +5 -0
- data/{test_app → spec/internal}/config/initializers/countries.rb +0 -0
- data/{test_app → spec/internal}/config/initializers/default_date_format.rb +0 -0
- data/spec/internal/config/initializers/development.rb +8 -0
- data/{test_app → spec/internal}/config/routes.rb +1 -2
- data/spec/internal/db/schema.rb +26 -0
- data/{test_app → spec/internal}/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +21 -0
- data/spec/support/retry_on_timeout.rb +4 -7
- data/spec/utils_spec.rb +21 -0
- data/vendor/assets/javascripts/jquery.autosize.js +272 -0
- data/{lib → vendor}/assets/javascripts/jquery.purr.js +1 -1
- metadata +92 -175
- data/lib/best_in_place/check_version.rb +0 -8
- data/spec/spec_helper.rb +0 -23
- data/test_app/Gemfile +0 -16
- data/test_app/README +0 -256
- data/test_app/Rakefile +0 -7
- data/test_app/app/assets/javascripts/application.js +0 -35
- data/test_app/app/helpers/users_helper.rb +0 -29
- data/test_app/config.ru +0 -4
- data/test_app/config/application.rb +0 -51
- data/test_app/config/boot.rb +0 -13
- data/test_app/config/database.yml +0 -22
- data/test_app/config/environment.rb +0 -5
- data/test_app/config/environments/development.rb +0 -25
- data/test_app/config/environments/production.rb +0 -49
- data/test_app/config/environments/test.rb +0 -35
- data/test_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test_app/config/initializers/inflections.rb +0 -10
- data/test_app/config/initializers/mime_types.rb +0 -5
- data/test_app/config/initializers/secret_token.rb +0 -7
- data/test_app/config/initializers/session_store.rb +0 -8
- data/test_app/config/locales/en.yml +0 -5
- data/test_app/db/migrate/20101206205922_create_users.rb +0 -18
- data/test_app/db/migrate/20101212170114_add_receive_email_to_user.rb +0 -9
- data/test_app/db/migrate/20110115204441_add_description_to_user.rb +0 -9
- data/test_app/db/migrate/20111210084202_add_favorite_color_to_users.rb +0 -5
- data/test_app/db/migrate/20111210084251_add_favorite_books_to_users.rb +0 -5
- data/test_app/db/migrate/20111217215935_add_birth_date_to_users.rb +0 -5
- data/test_app/db/migrate/20111224181356_add_money_to_user.rb +0 -5
- data/test_app/db/migrate/20120513003308_create_cars.rb +0 -11
- data/test_app/db/migrate/20120607172609_add_favorite_movie_to_users.rb +0 -5
- data/test_app/db/migrate/20120616170454_add_money_proc_to_users.rb +0 -6
- data/test_app/db/migrate/20120620165212_add_height_to_user.rb +0 -5
- data/test_app/db/migrate/20130213224102_add_favorite_locale_to_users.rb +0 -5
- data/test_app/db/schema.rb +0 -41
- data/test_app/db/seeds.rb +0 -19
- data/test_app/doc/README_FOR_APP +0 -2
- data/test_app/lib/tasks/.gitkeep +0 -0
- data/test_app/lib/tasks/cron.rake +0 -7
- data/test_app/public/404.html +0 -26
- data/test_app/public/422.html +0 -26
- data/test_app/public/500.html +0 -26
- data/test_app/public/robots.txt +0 -5
- data/test_app/script/rails +0 -6
- data/test_app/test/fixtures/users.yml +0 -17
- data/test_app/test/functional/users_controller_test.rb +0 -49
- data/test_app/test/performance/browsing_test.rb +0 -9
- data/test_app/test/test_helper.rb +0 -13
- data/test_app/test/unit/helpers/users_helper_test.rb +0 -4
- data/test_app/test/unit/user_test.rb +0 -8
- data/test_app/vendor/plugins/.gitkeep +0 -0
@@ -1,9 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
2
|
|
4
3
|
describe "Double initialization bug", :js => true do
|
5
4
|
before do
|
6
|
-
@user = User.
|
5
|
+
@user = User.create :name => "Lucia",
|
7
6
|
:last_name => "Napoli",
|
8
7
|
:email => "lucianapoli@gmail.com",
|
9
8
|
:height => "5' 5\"",
|
@@ -16,18 +15,17 @@ describe "Double initialization bug", :js => true do
|
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should be able to change a boolean value" do
|
19
|
-
@user.save!
|
20
18
|
visit double_init_user_path(@user)
|
21
19
|
|
22
20
|
within("#receive_email") do
|
23
|
-
page.
|
21
|
+
expect(page).to have_content("No thanks")
|
24
22
|
end
|
25
23
|
|
26
24
|
bip_bool @user, :receive_email
|
27
25
|
|
28
26
|
visit double_init_user_path(@user)
|
29
27
|
within("#receive_email") do
|
30
|
-
page.
|
28
|
+
expect(page).to have_content("Yes of course")
|
31
29
|
end
|
32
30
|
|
33
31
|
end
|
data/spec/integration/js_spec.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
2
|
|
4
3
|
describe "JS behaviour", :js => true do
|
5
4
|
before do
|
6
5
|
@user = User.new :name => "Lucia",
|
7
6
|
:last_name => "Napoli",
|
8
7
|
:email => "lucianapoli@gmail.com",
|
9
|
-
:height => "
|
8
|
+
:height => "h51",
|
10
9
|
:address => "Via Roma 99",
|
11
10
|
:zip => "25123",
|
12
11
|
:country => "2",
|
13
12
|
:receive_email => false,
|
14
13
|
:birth_date => Time.now.utc,
|
15
|
-
:description => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a lectus et lacus ultrices auctor. Morbi aliquet convallis tincidunt. Praesent enim libero, iaculis at commodo nec, fermentum a dolor. Quisque eget eros id felis lacinia faucibus feugiat et ante. Aenean justo nisi, aliquam vel egestas vel, porta in ligula. Etiam molestie, lacus eget tincidunt accumsan, elit justo rhoncus urna, nec pretium neque mi et lorem. Aliquam posuere, dolor quis pulvinar luctus, felis dolor tincidunt leo, eget pretium orci purus ac nibh. Ut enim sem, suscipit ac elementum vitae, sodales vel sem.",
|
16
14
|
:money => 100,
|
17
15
|
:money_proc => 100,
|
18
16
|
:favorite_color => 'Red',
|
@@ -26,10 +24,20 @@ describe "JS behaviour", :js => true do
|
|
26
24
|
@user.save!
|
27
25
|
visit admin_user_path(@user)
|
28
26
|
|
29
|
-
within("#last_name") { page.
|
27
|
+
within("#last_name") { expect(page).to have_content("Napoli") }
|
30
28
|
bip_text @user, :last_name, "Other thing"
|
31
29
|
|
32
|
-
within("#last_name") { page.
|
30
|
+
within("#last_name") { expect(page).to have_content("Other thing") }
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should be able to use another url' do
|
34
|
+
@user.save!
|
35
|
+
visit admin_user_path(@user)
|
36
|
+
|
37
|
+
within('#name') { expect(page).to have_content("Lucia") }
|
38
|
+
bip_text @user, :name, 'Other thing'
|
39
|
+
|
40
|
+
within('#name') { expect(page).to have_content('Other thing') }
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
@@ -40,7 +48,7 @@ describe "JS behaviour", :js => true do
|
|
40
48
|
visit user_path(@user)
|
41
49
|
|
42
50
|
within("#name") do
|
43
|
-
page.
|
51
|
+
expect(page).to have_content('-')
|
44
52
|
end
|
45
53
|
end
|
46
54
|
|
@@ -52,7 +60,7 @@ describe "JS behaviour", :js => true do
|
|
52
60
|
bip_text @user, :money, "abcd"
|
53
61
|
|
54
62
|
within("#money") do
|
55
|
-
page.
|
63
|
+
expect(page).to have_content('-')
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
@@ -62,20 +70,20 @@ describe "JS behaviour", :js => true do
|
|
62
70
|
visit user_path(@user)
|
63
71
|
|
64
72
|
within("#last_name") do
|
65
|
-
page.
|
73
|
+
expect(page).to have_content("Nothing to show")
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
69
|
-
it
|
77
|
+
it 'should render html content for placeholder option' do
|
70
78
|
@user.favorite_color = ""
|
71
79
|
@user.save!
|
72
80
|
visit user_path(@user)
|
73
81
|
within("#favorite_color") do
|
74
|
-
page.
|
82
|
+
expect(page).to have_xpath("//span[@class='placeholder']")
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
78
|
-
it
|
86
|
+
it 'should render html content for placeholder option after edit' do
|
79
87
|
@user.favorite_color = "Blue"
|
80
88
|
@user.save!
|
81
89
|
visit user_path(@user)
|
@@ -83,7 +91,7 @@ describe "JS behaviour", :js => true do
|
|
83
91
|
bip_text @user, :favorite_color, ""
|
84
92
|
|
85
93
|
within("#favorite_color") do
|
86
|
-
page.
|
94
|
+
expect(page).to have_xpath("//span[@class='placeholder']")
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
@@ -93,7 +101,7 @@ describe "JS behaviour", :js => true do
|
|
93
101
|
visit user_path(@user)
|
94
102
|
|
95
103
|
within("#favorite_locale") do
|
96
|
-
page.
|
104
|
+
expect(page).to have_content("N/A")
|
97
105
|
end
|
98
106
|
|
99
107
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_locale
|
@@ -102,7 +110,7 @@ describe "JS behaviour", :js => true do
|
|
102
110
|
JS
|
103
111
|
|
104
112
|
text = page.find("##{id} input").value
|
105
|
-
text.
|
113
|
+
expect(text).to eq("")
|
106
114
|
|
107
115
|
page.execute_script <<-JS
|
108
116
|
$("##{id} input[name='favorite_locale']").blur();
|
@@ -115,7 +123,7 @@ describe "JS behaviour", :js => true do
|
|
115
123
|
JS
|
116
124
|
|
117
125
|
text = page.find("##{id} input").value
|
118
|
-
text.
|
126
|
+
expect(text).to eq("")
|
119
127
|
end
|
120
128
|
end
|
121
129
|
|
@@ -138,10 +146,9 @@ describe "JS behaviour", :js => true do
|
|
138
146
|
:description => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a lectus et lacus ultrices auctor. Morbi aliquet convallis tincidunt. Praesent enim libero, iaculis at commodo nec, fermentum a dolor. Quisque eget eros id felis lacinia faucibus feugiat et ante. Aenean justo nisi, aliquam vel egestas vel, porta in ligula. Etiam molestie, lacus eget tincidunt accumsan, elit justo rhoncus urna, nec pretium neque mi et lorem. Aliquam posuere, dolor quis pulvinar luctus, felis dolor tincidunt leo, eget pretium orci purus ac nibh. Ut enim sem, suscipit ac elementum vitae, sodales vel sem."
|
139
147
|
|
140
148
|
visit users_path
|
141
|
-
|
142
149
|
within("tr#user_#{@user.id} > .name > span") do
|
143
|
-
page.
|
144
|
-
page.
|
150
|
+
expect(page).to have_content("Lucia")
|
151
|
+
expect(page).to have_xpath("//a[contains(@href,'#{user_path(@user)}')]")
|
145
152
|
end
|
146
153
|
|
147
154
|
id = BestInPlace::Utils.build_best_in_place_id @user, :name
|
@@ -152,7 +159,7 @@ describe "JS behaviour", :js => true do
|
|
152
159
|
JS
|
153
160
|
|
154
161
|
within("tr#user_#{@user.id} > .name > span") do
|
155
|
-
page.
|
162
|
+
expect(page).to have_content('Lisa')
|
156
163
|
end
|
157
164
|
end
|
158
165
|
|
@@ -160,14 +167,14 @@ describe "JS behaviour", :js => true do
|
|
160
167
|
@user.save!
|
161
168
|
visit user_path(@user)
|
162
169
|
within("#email") do
|
163
|
-
page.
|
170
|
+
expect(page).to have_content("lucianapoli@gmail.com")
|
164
171
|
end
|
165
172
|
|
166
173
|
bip_text @user, :email, "new@email.com"
|
167
174
|
|
168
175
|
visit user_path(@user)
|
169
176
|
within("#email") do
|
170
|
-
page.
|
177
|
+
expect(page).to have_content("new@email.com")
|
171
178
|
end
|
172
179
|
end
|
173
180
|
|
@@ -178,18 +185,18 @@ describe "JS behaviour", :js => true do
|
|
178
185
|
bip_text @user, :email, "new@email.com"
|
179
186
|
|
180
187
|
within("#email") do
|
181
|
-
page.
|
188
|
+
expect(page).to have_content("new@email.com")
|
182
189
|
end
|
183
190
|
|
184
191
|
bip_text @user, :email, "new_two@email.com"
|
185
192
|
|
186
193
|
within("#email") do
|
187
|
-
page.
|
194
|
+
expect(page).to have_content("new_two@email.com")
|
188
195
|
end
|
189
196
|
|
190
197
|
visit user_path(@user)
|
191
198
|
within("#email") do
|
192
|
-
page.
|
199
|
+
expect(page).to have_content("new_two@email.com")
|
193
200
|
end
|
194
201
|
end
|
195
202
|
|
@@ -198,16 +205,16 @@ describe "JS behaviour", :js => true do
|
|
198
205
|
visit user_path(@user)
|
199
206
|
|
200
207
|
bip_text @user, :email, "wrong format"
|
201
|
-
page.
|
208
|
+
expect(page).to have_content("Email has wrong email format")
|
202
209
|
|
203
210
|
bip_text @user, :email, "another@email.com"
|
204
211
|
within("#email") do
|
205
|
-
page.
|
212
|
+
expect(page).to have_content("another@email.com")
|
206
213
|
end
|
207
214
|
|
208
215
|
visit user_path(@user)
|
209
216
|
within("#email") do
|
210
|
-
page.
|
217
|
+
expect(page).to have_content("another@email.com")
|
211
218
|
end
|
212
219
|
end
|
213
220
|
|
@@ -215,14 +222,14 @@ describe "JS behaviour", :js => true do
|
|
215
222
|
@user.save!
|
216
223
|
visit user_path(@user)
|
217
224
|
within("#country") do
|
218
|
-
page.
|
225
|
+
expect(page).to have_content("Italy")
|
219
226
|
end
|
220
227
|
|
221
228
|
bip_select @user, :country, "France"
|
222
229
|
|
223
230
|
visit user_path(@user)
|
224
231
|
within("#country") do
|
225
|
-
page.
|
232
|
+
expect(page).to have_content("France")
|
226
233
|
end
|
227
234
|
end
|
228
235
|
|
@@ -231,7 +238,7 @@ describe "JS behaviour", :js => true do
|
|
231
238
|
visit user_path(@user)
|
232
239
|
|
233
240
|
find('#country span').click
|
234
|
-
find('#country').
|
241
|
+
expect(find('#country')).to have_css('select.some_class')
|
235
242
|
end
|
236
243
|
|
237
244
|
it "should be able to use bip_text to change a date field" do
|
@@ -239,14 +246,14 @@ describe "JS behaviour", :js => true do
|
|
239
246
|
today = Time.now.utc.to_date
|
240
247
|
visit user_path(@user)
|
241
248
|
within("#birth_date") do
|
242
|
-
page.
|
249
|
+
expect(page).to have_content(today)
|
243
250
|
end
|
244
251
|
|
245
252
|
bip_text @user, :birth_date, (today - 1.days)
|
246
253
|
|
247
254
|
visit user_path(@user)
|
248
255
|
within("#birth_date") do
|
249
|
-
page.
|
256
|
+
expect(page).to have_content(today - 1.days)
|
250
257
|
end
|
251
258
|
end
|
252
259
|
|
@@ -255,7 +262,7 @@ describe "JS behaviour", :js => true do
|
|
255
262
|
today = Time.now.utc.to_date
|
256
263
|
visit user_path(@user)
|
257
264
|
within("#birth_date") do
|
258
|
-
page.
|
265
|
+
expect(page).to have_content(today)
|
259
266
|
end
|
260
267
|
|
261
268
|
id = BestInPlace::Utils.build_best_in_place_id @user, :birth_date
|
@@ -266,7 +273,7 @@ describe "JS behaviour", :js => true do
|
|
266
273
|
|
267
274
|
visit user_path(@user)
|
268
275
|
within("#birth_date") do
|
269
|
-
page.
|
276
|
+
expect(page).to have_content(today.beginning_of_month)
|
270
277
|
end
|
271
278
|
end
|
272
279
|
|
@@ -275,7 +282,7 @@ describe "JS behaviour", :js => true do
|
|
275
282
|
today = Time.now.utc.to_date
|
276
283
|
visit user_path(@user)
|
277
284
|
within("#birth_date") do
|
278
|
-
page.
|
285
|
+
expect(page).to have_content(today)
|
279
286
|
end
|
280
287
|
|
281
288
|
id = BestInPlace::Utils.build_best_in_place_id @user, :birth_date
|
@@ -285,7 +292,7 @@ describe "JS behaviour", :js => true do
|
|
285
292
|
JS
|
286
293
|
|
287
294
|
within("#birth_date") do
|
288
|
-
page.
|
295
|
+
expect(page).to have_content(today.beginning_of_month.strftime("%d-%m-%Y"))
|
289
296
|
end
|
290
297
|
end
|
291
298
|
|
@@ -294,14 +301,14 @@ describe "JS behaviour", :js => true do
|
|
294
301
|
visit user_path(@user)
|
295
302
|
|
296
303
|
within("#receive_email") do
|
297
|
-
page.
|
304
|
+
expect(page).to have_content("No thanks")
|
298
305
|
end
|
299
306
|
|
300
307
|
bip_bool @user, :receive_email
|
301
308
|
|
302
309
|
visit user_path(@user)
|
303
310
|
within("#receive_email") do
|
304
|
-
page.
|
311
|
+
expect(page).to have_content("Yes of course")
|
305
312
|
end
|
306
313
|
end
|
307
314
|
|
@@ -310,14 +317,14 @@ describe "JS behaviour", :js => true do
|
|
310
317
|
visit user_path(@user)
|
311
318
|
|
312
319
|
within("#receive_email_image") do
|
313
|
-
page.
|
320
|
+
expect(page).to have_xpath("//img[contains(@src,'no.png')]")
|
314
321
|
end
|
315
322
|
|
316
323
|
bip_bool @user, :receive_email
|
317
324
|
|
318
325
|
visit user_path(@user)
|
319
326
|
within("#receive_email_image") do
|
320
|
-
page.
|
327
|
+
expect(page).to have_xpath("//img[contains(@src,'yes.png')]")
|
321
328
|
end
|
322
329
|
end
|
323
330
|
|
@@ -326,7 +333,7 @@ describe "JS behaviour", :js => true do
|
|
326
333
|
visit user_path(@user)
|
327
334
|
|
328
335
|
within("#favorite_color") do
|
329
|
-
page.
|
336
|
+
expect(page).to have_content('Red')
|
330
337
|
end
|
331
338
|
|
332
339
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_color
|
@@ -335,8 +342,8 @@ describe "JS behaviour", :js => true do
|
|
335
342
|
$("##{id} input[name='favorite_color']").val('Blue');
|
336
343
|
JS
|
337
344
|
|
338
|
-
page.find("##{id} input[type='submit']").value.
|
339
|
-
page.
|
345
|
+
expect(page.find("##{id} input[type='submit']").value).to eq('Do it!')
|
346
|
+
expect(page).to have_css("##{id} input[type='submit'].custom-submit.other-custom-submit")
|
340
347
|
|
341
348
|
page.execute_script <<-JS
|
342
349
|
$("##{id} input[type='submit']").click();
|
@@ -344,7 +351,7 @@ describe "JS behaviour", :js => true do
|
|
344
351
|
|
345
352
|
visit user_path(@user)
|
346
353
|
within("#favorite_color") do
|
347
|
-
page.
|
354
|
+
expect(page).to have_content('Blue')
|
348
355
|
end
|
349
356
|
end
|
350
357
|
|
@@ -353,7 +360,7 @@ describe "JS behaviour", :js => true do
|
|
353
360
|
visit user_path(@user)
|
354
361
|
|
355
362
|
within("#favorite_color") do
|
356
|
-
page.
|
363
|
+
expect(page).to have_content('Red')
|
357
364
|
end
|
358
365
|
|
359
366
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_color
|
@@ -362,8 +369,8 @@ describe "JS behaviour", :js => true do
|
|
362
369
|
$("##{id} input[name='favorite_color']").val('Blue');
|
363
370
|
JS
|
364
371
|
|
365
|
-
page.find("##{id} input[type='button']").value.
|
366
|
-
page.
|
372
|
+
expect(page.find("##{id} input[type='button']").value).to eq('Nope')
|
373
|
+
expect(page).to have_css("##{id} input[type='button'].custom-cancel.other-custom-cancel")
|
367
374
|
|
368
375
|
page.execute_script <<-JS
|
369
376
|
$("##{id} input[type='button']").click();
|
@@ -371,7 +378,7 @@ describe "JS behaviour", :js => true do
|
|
371
378
|
|
372
379
|
visit user_path(@user)
|
373
380
|
within("#favorite_color") do
|
374
|
-
page.
|
381
|
+
expect(page).to have_content('Red')
|
375
382
|
end
|
376
383
|
end
|
377
384
|
|
@@ -386,9 +393,9 @@ describe "JS behaviour", :js => true do
|
|
386
393
|
$("##{id} input[type='button']").click();
|
387
394
|
JS
|
388
395
|
|
389
|
-
|
396
|
+
expect { page.driver.browser.switch_to.alert }.to raise_exception(Selenium::WebDriver::Error::NoAlertPresentError)
|
390
397
|
within("#favorite_movie") do
|
391
|
-
page.
|
398
|
+
expect(page).to have_content("The Hitchhiker's Guide to the Galaxy")
|
392
399
|
end
|
393
400
|
end
|
394
401
|
|
@@ -397,7 +404,7 @@ describe "JS behaviour", :js => true do
|
|
397
404
|
visit user_path(@user)
|
398
405
|
|
399
406
|
within("#favorite_color") do
|
400
|
-
page.
|
407
|
+
expect(page).to have_content('Red')
|
401
408
|
end
|
402
409
|
|
403
410
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_color
|
@@ -410,7 +417,7 @@ describe "JS behaviour", :js => true do
|
|
410
417
|
|
411
418
|
visit user_path(@user)
|
412
419
|
within("#favorite_color") do
|
413
|
-
page.
|
420
|
+
expect(page).to have_content('Red')
|
414
421
|
end
|
415
422
|
end
|
416
423
|
|
@@ -419,12 +426,12 @@ describe "JS behaviour", :js => true do
|
|
419
426
|
visit user_path(@user, :suppress_ok_button => 1)
|
420
427
|
|
421
428
|
within("#favorite_color") do
|
422
|
-
page.
|
429
|
+
expect(page).to have_content('Red')
|
423
430
|
end
|
424
431
|
|
425
432
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_color
|
426
433
|
page.execute_script %{$("##{id}").click();}
|
427
|
-
page.
|
434
|
+
expect(page).to have_no_css("##{id} input[type='submit']")
|
428
435
|
page.execute_script <<-JS
|
429
436
|
$("##{id} input[name='favorite_color']").val('Blue');
|
430
437
|
$("##{id} input[name='favorite_color']").blur();
|
@@ -434,7 +441,7 @@ describe "JS behaviour", :js => true do
|
|
434
441
|
|
435
442
|
visit user_path(@user)
|
436
443
|
within("#favorite_color") do
|
437
|
-
page.
|
444
|
+
expect(page).to have_content('Blue')
|
438
445
|
end
|
439
446
|
end
|
440
447
|
|
@@ -443,7 +450,7 @@ describe "JS behaviour", :js => true do
|
|
443
450
|
visit user_path(@user)
|
444
451
|
|
445
452
|
within("#favorite_books") do
|
446
|
-
page.
|
453
|
+
expect(page).to have_content('The City of Gold and Lead')
|
447
454
|
end
|
448
455
|
|
449
456
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_books
|
@@ -455,7 +462,7 @@ describe "JS behaviour", :js => true do
|
|
455
462
|
|
456
463
|
visit user_path(@user)
|
457
464
|
within("#favorite_books") do
|
458
|
-
page.
|
465
|
+
expect(page).to have_content('1Q84')
|
459
466
|
end
|
460
467
|
end
|
461
468
|
|
@@ -464,7 +471,7 @@ describe "JS behaviour", :js => true do
|
|
464
471
|
visit user_path(@user)
|
465
472
|
|
466
473
|
within("#favorite_books") do
|
467
|
-
page.
|
474
|
+
expect(page).to have_content('The City of Gold and Lead')
|
468
475
|
end
|
469
476
|
|
470
477
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_books
|
@@ -473,11 +480,10 @@ describe "JS behaviour", :js => true do
|
|
473
480
|
$("##{id} textarea").val('1Q84');
|
474
481
|
$("##{id} input[type='button']").click();
|
475
482
|
JS
|
476
|
-
page.driver.browser.switch_to.alert.accept
|
477
483
|
|
478
484
|
visit user_path(@user)
|
479
485
|
within("#favorite_books") do
|
480
|
-
page.
|
486
|
+
expect(page).to have_content('The City of Gold and Lead')
|
481
487
|
end
|
482
488
|
end
|
483
489
|
|
@@ -486,7 +492,7 @@ describe "JS behaviour", :js => true do
|
|
486
492
|
visit user_path(@user)
|
487
493
|
|
488
494
|
within("#favorite_books") do
|
489
|
-
page.
|
495
|
+
expect(page).to have_content('The City of Gold and Lead')
|
490
496
|
end
|
491
497
|
|
492
498
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_books
|
@@ -497,11 +503,10 @@ describe "JS behaviour", :js => true do
|
|
497
503
|
$("##{id} textarea").blur();
|
498
504
|
JS
|
499
505
|
sleep 1 # Increase if browser is slow
|
500
|
-
page.driver.browser.switch_to.alert.accept
|
501
506
|
|
502
507
|
visit user_path(@user)
|
503
508
|
within("#favorite_books") do
|
504
|
-
page.
|
509
|
+
expect(page).to have_content('The City of Gold and Lead')
|
505
510
|
end
|
506
511
|
end
|
507
512
|
|
@@ -510,12 +515,12 @@ describe "JS behaviour", :js => true do
|
|
510
515
|
visit user_path(@user, :suppress_ok_button => 1)
|
511
516
|
|
512
517
|
within("#favorite_books") do
|
513
|
-
page.
|
518
|
+
expect(page).to have_content('The City of Gold and Lead')
|
514
519
|
end
|
515
520
|
|
516
521
|
id = BestInPlace::Utils.build_best_in_place_id @user, :favorite_books
|
517
522
|
page.execute_script %{$("##{id}").click();}
|
518
|
-
page.
|
523
|
+
expect(page).to have_no_css("##{id} input[type='submit']")
|
519
524
|
page.execute_script <<-JS
|
520
525
|
$("##{id} textarea").val('1Q84');
|
521
526
|
$("##{id} textarea").blur();
|
@@ -525,7 +530,7 @@ describe "JS behaviour", :js => true do
|
|
525
530
|
|
526
531
|
visit user_path(@user)
|
527
532
|
within("#favorite_books") do
|
528
|
-
page.
|
533
|
+
expect(page).to have_content('1Q84')
|
529
534
|
end
|
530
535
|
end
|
531
536
|
|
@@ -534,9 +539,9 @@ describe "JS behaviour", :js => true do
|
|
534
539
|
visit user_path(@user)
|
535
540
|
|
536
541
|
bip_text @user, :address, ""
|
537
|
-
page.
|
542
|
+
expect(page).to have_content("Address can't be blank")
|
538
543
|
within("#address") do
|
539
|
-
page.
|
544
|
+
expect(page).to have_content("Via Roma 99")
|
540
545
|
end
|
541
546
|
end
|
542
547
|
|
@@ -549,9 +554,9 @@ describe "JS behaviour", :js => true do
|
|
549
554
|
$("##{id}").bind('best_in_place:update', function() { $('body').append('Last name was updated!') });
|
550
555
|
JS
|
551
556
|
|
552
|
-
page.
|
557
|
+
expect(page).to have_no_content('Last name was updated!')
|
553
558
|
bip_text @user, :last_name, 'Another'
|
554
|
-
page.
|
559
|
+
expect(page).to have_content('Last name was updated!')
|
555
560
|
end
|
556
561
|
|
557
562
|
it "should fire off a callback when retrieve success with empty data" do
|
@@ -563,9 +568,9 @@ describe "JS behaviour", :js => true do
|
|
563
568
|
$("##{id}").bind('best_in_place:success', function() { $('body').append('Updated successfully!') });
|
564
569
|
JS
|
565
570
|
|
566
|
-
page.
|
571
|
+
expect(page).to have_no_content('Updated successfully!')
|
567
572
|
bip_text @user, :last_name, 'Empty'
|
568
|
-
page.
|
573
|
+
expect(page).to have_content('Updated successfully!')
|
569
574
|
end
|
570
575
|
|
571
576
|
describe "display_as" do
|
@@ -574,7 +579,7 @@ describe "JS behaviour", :js => true do
|
|
574
579
|
visit user_path(@user)
|
575
580
|
|
576
581
|
within("#address") do
|
577
|
-
page.
|
582
|
+
expect(page).to have_content("addr => [Via Roma 99]")
|
578
583
|
end
|
579
584
|
end
|
580
585
|
|
@@ -585,7 +590,7 @@ describe "JS behaviour", :js => true do
|
|
585
590
|
bip_text @user, :address, "inva"
|
586
591
|
|
587
592
|
within("#address") do
|
588
|
-
page.
|
593
|
+
expect(page).to have_content("addr => [Via Roma 99]")
|
589
594
|
end
|
590
595
|
end
|
591
596
|
|
@@ -596,10 +601,34 @@ describe "JS behaviour", :js => true do
|
|
596
601
|
bip_text @user, :address, "New address"
|
597
602
|
|
598
603
|
within("#address") do
|
599
|
-
page.
|
604
|
+
expect(page).to have_content("addr => [New address]")
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
608
|
+
it "should show default em-dash when the new result with the custom format is nil after an update" do
|
609
|
+
@user.save
|
610
|
+
visit user_path(@user)
|
611
|
+
|
612
|
+
bip_text @user, :zip, ""
|
613
|
+
|
614
|
+
within("#zip") do
|
615
|
+
expect(page).to have_content("-")
|
600
616
|
end
|
601
617
|
end
|
602
618
|
|
619
|
+
it "should be editable after the new result with the custom format is nil because of an update" do
|
620
|
+
@user.save
|
621
|
+
visit user_path(@user)
|
622
|
+
|
623
|
+
bip_text @user, :zip, ""
|
624
|
+
|
625
|
+
id = BestInPlace::Utils.build_best_in_place_id @user, :zip
|
626
|
+
find("##{id}").click
|
627
|
+
|
628
|
+
text = page.find("##{id} input").value
|
629
|
+
expect(text).to eq("")
|
630
|
+
end
|
631
|
+
|
603
632
|
it "should display the original content when editing the form" do
|
604
633
|
@user.save!
|
605
634
|
retry_on_timeout do
|
@@ -611,7 +640,7 @@ describe "JS behaviour", :js => true do
|
|
611
640
|
JS
|
612
641
|
|
613
642
|
text = page.find("##{id} input").value
|
614
|
-
text.
|
643
|
+
expect(text).to eq("Via Roma 99")
|
615
644
|
end
|
616
645
|
end
|
617
646
|
|
@@ -632,20 +661,20 @@ describe "JS behaviour", :js => true do
|
|
632
661
|
sleep 1
|
633
662
|
|
634
663
|
text = page.find("##{id} input").value
|
635
|
-
text.
|
664
|
+
expect(text).to eq("New address")
|
636
665
|
end
|
637
666
|
end
|
638
667
|
|
639
668
|
it "should quote properly the data-original-content attribute" do
|
640
669
|
@user.address = "A's & B's"
|
641
670
|
@user.save!
|
671
|
+
|
642
672
|
retry_on_timeout do
|
643
673
|
visit user_path(@user)
|
644
|
-
|
645
674
|
id = BestInPlace::Utils.build_best_in_place_id @user, :address
|
646
675
|
|
647
|
-
text = page.find("##{id}")[
|
648
|
-
text.
|
676
|
+
text = page.find("##{id}")['data-bip-original-content']
|
677
|
+
expect(text).to eq("A's & B's")
|
649
678
|
end
|
650
679
|
end
|
651
680
|
end
|
@@ -657,7 +686,7 @@ describe "JS behaviour", :js => true do
|
|
657
686
|
|
658
687
|
visit user_path(@user)
|
659
688
|
|
660
|
-
within("#dw_description") { page.
|
689
|
+
within("#dw_description") { expect(page).to have_content('-') }
|
661
690
|
end
|
662
691
|
|
663
692
|
it "should render the money using number_to_currency" do
|
@@ -665,7 +694,7 @@ describe "JS behaviour", :js => true do
|
|
665
694
|
visit user_path(@user)
|
666
695
|
|
667
696
|
within("#money") do
|
668
|
-
page.
|
697
|
+
expect(page).to have_content("$100.00")
|
669
698
|
end
|
670
699
|
end
|
671
700
|
|
@@ -673,11 +702,11 @@ describe "JS behaviour", :js => true do
|
|
673
702
|
@user.save!
|
674
703
|
visit user_path(@user)
|
675
704
|
|
676
|
-
page.
|
705
|
+
expect(page).to have_content("100.0 €")
|
677
706
|
bip_text @user, :money_custom, "250"
|
678
707
|
|
679
708
|
within("#money_custom") do
|
680
|
-
page.
|
709
|
+
expect(page).to have_content("250.0 €")
|
681
710
|
end
|
682
711
|
end
|
683
712
|
|
@@ -687,10 +716,10 @@ describe "JS behaviour", :js => true do
|
|
687
716
|
|
688
717
|
bip_text @user, :money, "string"
|
689
718
|
|
690
|
-
page.
|
719
|
+
expect(page).to have_content("Money is not a number")
|
691
720
|
|
692
721
|
within("#money") do
|
693
|
-
page.
|
722
|
+
expect(page).to have_content("$100.00")
|
694
723
|
end
|
695
724
|
end
|
696
725
|
|
@@ -701,7 +730,19 @@ describe "JS behaviour", :js => true do
|
|
701
730
|
bip_text @user, :money, "240"
|
702
731
|
|
703
732
|
within("#money") do
|
704
|
-
page.
|
733
|
+
expect(page).to have_content("$240.00")
|
734
|
+
end
|
735
|
+
end
|
736
|
+
|
737
|
+
it "should show the new value using the helper after a successful update if original value is nil" do
|
738
|
+
@user.money = nil
|
739
|
+
@user.save!
|
740
|
+
visit user_path(@user)
|
741
|
+
|
742
|
+
bip_text @user, :money, "240"
|
743
|
+
|
744
|
+
within("#money") do
|
745
|
+
expect(page).to have_content("$240.00")
|
705
746
|
end
|
706
747
|
end
|
707
748
|
|
@@ -716,7 +757,7 @@ describe "JS behaviour", :js => true do
|
|
716
757
|
JS
|
717
758
|
|
718
759
|
text = page.find("##{id} input").value
|
719
|
-
text.
|
760
|
+
expect(text).to eq("100.0")
|
720
761
|
end
|
721
762
|
end
|
722
763
|
|
@@ -738,7 +779,7 @@ describe "JS behaviour", :js => true do
|
|
738
779
|
sleep 1
|
739
780
|
|
740
781
|
text = page.find("##{id} input").value
|
741
|
-
text.
|
782
|
+
expect(text).to eq("40")
|
742
783
|
end
|
743
784
|
end
|
744
785
|
|
@@ -746,19 +787,19 @@ describe "JS behaviour", :js => true do
|
|
746
787
|
@user.save!
|
747
788
|
visit double_init_user_path(@user)
|
748
789
|
|
749
|
-
within("#alt_money") { page.
|
790
|
+
within("#alt_money") { expect(page).to have_content("€100.00") }
|
750
791
|
|
751
792
|
bip_text @user, :money, 58
|
752
793
|
|
753
|
-
within("#alt_money") { page.
|
794
|
+
within("#alt_money") { expect(page).to have_content("€58.00") }
|
754
795
|
end
|
755
796
|
|
756
797
|
it "should keep link after edit with display_with :link_to" do
|
757
798
|
@user.save!
|
758
799
|
visit users_path
|
759
800
|
within("tr#user_#{@user.id} > .name > span") do
|
760
|
-
page.
|
761
|
-
page.
|
801
|
+
expect(page).to have_content("Lucia")
|
802
|
+
expect(page).to have_xpath("//a[contains(@href,'#{user_path(@user)}')]")
|
762
803
|
end
|
763
804
|
id = BestInPlace::Utils.build_best_in_place_id @user, :name
|
764
805
|
page.execute_script <<-JS
|
@@ -767,8 +808,8 @@ describe "JS behaviour", :js => true do
|
|
767
808
|
jQuery("##{id} form").submit();
|
768
809
|
JS
|
769
810
|
within("tr#user_#{@user.id} > .name > span") do
|
770
|
-
page.
|
771
|
-
page.
|
811
|
+
expect(page).to have_content("Maria Lucia")
|
812
|
+
expect(page).to have_xpath("//a[contains(@href,'#{user_path(@user)}')]")
|
772
813
|
end
|
773
814
|
end
|
774
815
|
|
@@ -776,8 +817,8 @@ describe "JS behaviour", :js => true do
|
|
776
817
|
@user.save!
|
777
818
|
visit users_path
|
778
819
|
within("tr#user_#{@user.id} > .name > span") do
|
779
|
-
page.
|
780
|
-
page.
|
820
|
+
expect(page).to have_content("Lucia")
|
821
|
+
expect(page).to have_xpath("//a[contains(@href,'#{user_path(@user)}')]")
|
781
822
|
end
|
782
823
|
id = BestInPlace::Utils.build_best_in_place_id @user, :name
|
783
824
|
page.execute_script <<-JS
|
@@ -786,25 +827,21 @@ describe "JS behaviour", :js => true do
|
|
786
827
|
jQuery("##{id} input[name='name']").blur();
|
787
828
|
JS
|
788
829
|
within("tr#user_#{@user.id} > .name > span") do
|
789
|
-
page.
|
790
|
-
page.
|
830
|
+
expect(page).to have_content("Lucia")
|
831
|
+
expect(page).to have_xpath("//a[contains(@href,'#{user_path(@user)}')]")
|
791
832
|
end
|
792
833
|
end
|
793
834
|
|
794
835
|
describe "display_with using a lambda" do
|
795
|
-
|
796
|
-
|
797
836
|
it "should render the money" do
|
798
837
|
@user.save!
|
799
838
|
visit user_path(@user)
|
800
839
|
|
801
840
|
within("#money_proc") do
|
802
|
-
page.
|
841
|
+
expect(page).to have_content("$100.00")
|
803
842
|
end
|
804
843
|
end
|
805
844
|
|
806
|
-
|
807
|
-
|
808
845
|
it "should show the new value using the helper after a successful update" do
|
809
846
|
@user.save!
|
810
847
|
visit user_path(@user)
|
@@ -812,7 +849,7 @@ describe "JS behaviour", :js => true do
|
|
812
849
|
bip_text @user, :money_proc, "240"
|
813
850
|
|
814
851
|
within("#money_proc") do
|
815
|
-
page.
|
852
|
+
expect(page).to have_content("$240.00")
|
816
853
|
end
|
817
854
|
end
|
818
855
|
|
@@ -827,7 +864,7 @@ describe "JS behaviour", :js => true do
|
|
827
864
|
JS
|
828
865
|
|
829
866
|
text = page.find("##{id} input").value
|
830
|
-
text.
|
867
|
+
expect(text).to eq("100.0")
|
831
868
|
end
|
832
869
|
end
|
833
870
|
|
@@ -847,9 +884,8 @@ describe "JS behaviour", :js => true do
|
|
847
884
|
JS
|
848
885
|
|
849
886
|
sleep 1
|
850
|
-
|
851
887
|
text = page.find("##{id} input").value
|
852
|
-
text.
|
888
|
+
expect(text).to eq("40")
|
853
889
|
end
|
854
890
|
end
|
855
891
|
|
@@ -857,6 +893,23 @@ describe "JS behaviour", :js => true do
|
|
857
893
|
|
858
894
|
end
|
859
895
|
|
896
|
+
describe 'value' do
|
897
|
+
it 'should use custom value in input' do
|
898
|
+
@user.save!
|
899
|
+
visit user_path(@user)
|
900
|
+
|
901
|
+
page.find('#money_value .best_in_place').click
|
902
|
+
expect(page).to have_field('money', with: 'Custom Value')
|
903
|
+
end
|
904
|
+
it 'should not use default value in input with value set' do
|
905
|
+
@user.save!
|
906
|
+
visit user_path(@user)
|
907
|
+
|
908
|
+
page.find('#money_value .best_in_place').click
|
909
|
+
expect(page).not_to have_field('money', with: @user.money)
|
910
|
+
end
|
911
|
+
end
|
912
|
+
|
860
913
|
it "should display strings with quotes correctly in fields" do
|
861
914
|
@user.last_name = "A last name \"with double quotes\""
|
862
915
|
@user.save!
|
@@ -870,11 +923,11 @@ describe "JS behaviour", :js => true do
|
|
870
923
|
JS
|
871
924
|
|
872
925
|
text = page.find("##{id} input").value
|
873
|
-
text.
|
926
|
+
expect(text).to eq("A last name \"with double quotes\"")
|
874
927
|
end
|
875
928
|
end
|
876
929
|
|
877
|
-
it
|
930
|
+
it 'should texts with quotes with raw => true' do
|
878
931
|
@user.save!
|
879
932
|
|
880
933
|
retry_on_timeout do
|
@@ -883,7 +936,24 @@ describe "JS behaviour", :js => true do
|
|
883
936
|
bip_area @user, :description, "A <a href=\"http://google.es\">link in this text</a> not sanitized."
|
884
937
|
visit double_init_user_path(@user)
|
885
938
|
|
886
|
-
page.
|
939
|
+
expect(page).to have_link("link in this text", :href => "http://google.es")
|
940
|
+
end
|
941
|
+
end
|
942
|
+
|
943
|
+
it "should show the input with not-scaped ampersands with raw => true" do
|
944
|
+
@user.description = "A text with an & and a <b>Raw html</b>"
|
945
|
+
@user.save!
|
946
|
+
|
947
|
+
retry_on_timeout do
|
948
|
+
visit double_init_user_path(@user)
|
949
|
+
|
950
|
+
id = BestInPlace::Utils.build_best_in_place_id @user, :description
|
951
|
+
page.execute_script <<-JS
|
952
|
+
$("##{id}").click();
|
953
|
+
JS
|
954
|
+
|
955
|
+
text = page.find("##{id} textarea").value
|
956
|
+
expect(text).to eq("A text with an & and a <b>Raw html</b>")
|
887
957
|
end
|
888
958
|
end
|
889
959
|
|
@@ -896,14 +966,14 @@ describe "JS behaviour", :js => true do
|
|
896
966
|
bip_area @user, :description, "A <a href=\"http://google.es\">link in this text</a> not sanitized."
|
897
967
|
visit double_init_user_path(@user)
|
898
968
|
|
899
|
-
page.
|
969
|
+
expect(page).to have_link("link in this text", :href => "http://google.es")
|
900
970
|
|
901
971
|
id = BestInPlace::Utils.build_best_in_place_id @user, :description
|
902
972
|
page.execute_script <<-JS
|
903
973
|
$("##{id}").click();
|
904
974
|
JS
|
905
975
|
|
906
|
-
page.find("##{id} textarea").value.
|
976
|
+
expect(page.find("##{id} textarea").value).to eq("A <a href=\"http://google.es\">link in this text</a> not sanitized.")
|
907
977
|
end
|
908
978
|
end
|
909
979
|
|
@@ -919,7 +989,7 @@ describe "JS behaviour", :js => true do
|
|
919
989
|
$("##{id}").click();
|
920
990
|
JS
|
921
991
|
|
922
|
-
page.find("##{id} select").value.
|
992
|
+
expect(page.find("##{id} select").value).to eq(%{5' 6"})
|
923
993
|
end
|
924
994
|
end
|
925
995
|
|
@@ -941,7 +1011,7 @@ describe "JS behaviour", :js => true do
|
|
941
1011
|
sleep 1
|
942
1012
|
|
943
1013
|
@user.reload
|
944
|
-
@user.height.
|
1014
|
+
expect(@user.height).to eq(%{5' 7"})
|
945
1015
|
end
|
946
1016
|
end
|
947
1017
|
|
@@ -955,7 +1025,7 @@ describe "JS behaviour", :js => true do
|
|
955
1025
|
sleep 1
|
956
1026
|
|
957
1027
|
@user.reload
|
958
|
-
@user.last_name.
|
1028
|
+
expect(@user.last_name).to eq("Other '); alert('hi');")
|
959
1029
|
end
|
960
1030
|
end
|
961
1031
|
|
@@ -969,7 +1039,7 @@ describe "JS behaviour", :js => true do
|
|
969
1039
|
sleep 1
|
970
1040
|
|
971
1041
|
@user.reload
|
972
|
-
@user.last_name.
|
1042
|
+
expect(@user.last_name).to eq("Other \"thing\"")
|
973
1043
|
end
|
974
1044
|
end
|
975
1045
|
|
@@ -980,7 +1050,7 @@ describe "JS behaviour", :js => true do
|
|
980
1050
|
visit user_path(@user)
|
981
1051
|
|
982
1052
|
bip_text @user, :last_name, "<script>alert('hi');</script>"
|
983
|
-
within("#last_name") { page.
|
1053
|
+
within("#last_name") { expect(page).to have_content("<script>alert('hi');</script>") }
|
984
1054
|
|
985
1055
|
visit user_path(@user)
|
986
1056
|
|
@@ -989,7 +1059,7 @@ describe "JS behaviour", :js => true do
|
|
989
1059
|
$("##{id}").click();
|
990
1060
|
JS
|
991
1061
|
|
992
|
-
page.find("##{id} input").value.
|
1062
|
+
expect(page.find("##{id} input").value).to eq("<script>alert('hi');</script>")
|
993
1063
|
end
|
994
1064
|
end
|
995
1065
|
|
@@ -997,7 +1067,7 @@ describe "JS behaviour", :js => true do
|
|
997
1067
|
@user.save!
|
998
1068
|
visit user_path(@user)
|
999
1069
|
within("#country") do
|
1000
|
-
page.
|
1070
|
+
expect(page).to have_content("Italy")
|
1001
1071
|
end
|
1002
1072
|
|
1003
1073
|
id = BestInPlace::Utils.build_best_in_place_id @user, :country
|
@@ -1005,14 +1075,14 @@ describe "JS behaviour", :js => true do
|
|
1005
1075
|
$("##{id}").click();
|
1006
1076
|
JS
|
1007
1077
|
|
1008
|
-
page.
|
1078
|
+
expect(page).to have_css("##{id} select option[value='2'][selected='selected']")
|
1009
1079
|
end
|
1010
1080
|
|
1011
1081
|
it "should generate the select with the proper current option without reloading the page" do
|
1012
1082
|
@user.save!
|
1013
1083
|
visit user_path(@user)
|
1014
1084
|
within("#country") do
|
1015
|
-
page.
|
1085
|
+
expect(page).to have_content("Italy")
|
1016
1086
|
end
|
1017
1087
|
|
1018
1088
|
bip_select @user, :country, "France"
|
@@ -1023,6 +1093,6 @@ describe "JS behaviour", :js => true do
|
|
1023
1093
|
$("##{id}").click();
|
1024
1094
|
JS
|
1025
1095
|
|
1026
|
-
page.
|
1096
|
+
expect(page).to have_css("##{id} select option[value='4'][selected='selected']")
|
1027
1097
|
end
|
1028
1098
|
end
|