refinerycms-pages 4.0.4 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/refinery/admin/page_parts_controller.rb +2 -1
- data/app/controllers/refinery/admin/pages_controller.rb +12 -11
- data/app/controllers/refinery/admin/pages_dialogs_controller.rb +8 -8
- data/app/controllers/refinery/pages/admin/preview_controller.rb +7 -0
- data/app/controllers/refinery/pages_controller.rb +4 -1
- data/app/helpers/refinery/admin/pages_helper.rb +29 -7
- data/app/models/refinery/page.rb +39 -51
- data/app/models/refinery/page_part.rb +12 -6
- data/app/presenters/refinery/pages/menu_presenter.rb +2 -2
- data/app/views/refinery/admin/pages/_form.html.erb +10 -10
- data/app/views/refinery/admin/pages/_page.html.erb +17 -45
- data/app/views/refinery/admin/pages/_sortable_list.html.erb +1 -1
- data/app/views/refinery/admin/pages/children.html.erb +1 -1
- data/app/views/refinery/admin/pages_dialogs/_page_link.html.erb +1 -1
- data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +28 -21
- data/config/locales/en.yml +3 -3
- data/config/locales/sk.yml +4 -2
- data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +27 -30
- data/db/seeds.rb +1 -1
- data/lib/generators/refinery/pages/pages_generator.rb +1 -1
- data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +10 -3
- data/lib/refinery/pages/configuration.rb +8 -5
- data/lib/refinery/pages/engine.rb +2 -1
- data/lib/refinery/pages/finder.rb +95 -96
- data/lib/refinery/pages/instance_methods.rb +6 -4
- data/lib/refinery/pages.rb +3 -3
- data/lib/refinerycms/pages.rb +1 -0
- data/refinerycms-pages.gemspec +16 -17
- data/spec/controllers/refinery/pages_controller_spec.rb +23 -6
- data/spec/factories/page_parts.rb +2 -2
- data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +8 -18
- data/spec/models/refinery/page_menu_spec.rb +2 -2
- data/spec/models/refinery/page_url_spec.rb +4 -4
- data/spec/support/refinery/pages/caching_helpers.rb +1 -1
- data/spec/support/selector_helpers.rb +43 -0
- data/spec/{features → system}/refinery/admin/pages_spec.rb +172 -155
- data/spec/{features → system}/refinery/pages_spec.rb +10 -10
- metadata +45 -73
|
@@ -15,16 +15,16 @@ end
|
|
|
15
15
|
|
|
16
16
|
def switch_page_form_locale(locale)
|
|
17
17
|
within "#switch_locale_picker" do
|
|
18
|
-
find("a",
|
|
18
|
+
find("a", id: locale.downcase).click
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# make sure that the locale change has taken effect
|
|
22
|
-
expect(page).to have_selector("#switch_locale_picker
|
|
22
|
+
expect(page).to have_selector("#switch_locale_picker a.selected##{locale.downcase}")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
module Refinery
|
|
26
26
|
module Admin
|
|
27
|
-
describe "Pages", :
|
|
27
|
+
describe "Pages", type: :system do
|
|
28
28
|
refinery_login
|
|
29
29
|
|
|
30
30
|
context "when no pages" do
|
|
@@ -45,6 +45,7 @@ module Refinery
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
context "when no pages" do
|
|
48
|
+
|
|
48
49
|
it "doesn't show reorder pages link" do
|
|
49
50
|
visit refinery.admin_pages_path
|
|
50
51
|
|
|
@@ -86,15 +87,14 @@ module Refinery
|
|
|
86
87
|
end
|
|
87
88
|
|
|
88
89
|
context "when sub pages exist" do
|
|
89
|
-
let!(:company) { Page.create :
|
|
90
|
-
let!(:team) { company.children.create :
|
|
91
|
-
let!(:locations) { company.children.create :
|
|
92
|
-
let!(:location) { locations.children.create :
|
|
90
|
+
let!(:company) { Page.create title: 'Our Company' }
|
|
91
|
+
let!(:team) { company.children.create title: 'Our Team' }
|
|
92
|
+
let!(:locations) { company.children.create title: 'Our Locations' }
|
|
93
|
+
let!(:location) { locations.children.create title: 'New York' }
|
|
93
94
|
|
|
94
95
|
context "with auto expand option turned off" do
|
|
95
96
|
before do
|
|
96
97
|
allow(Refinery::Pages).to receive(:auto_expand_admin_tree).and_return(false)
|
|
97
|
-
|
|
98
98
|
visit refinery.admin_pages_path
|
|
99
99
|
end
|
|
100
100
|
|
|
@@ -109,15 +109,15 @@ module Refinery
|
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "expands children", js: true do
|
|
112
|
-
find("#page_#{company.id} .
|
|
112
|
+
find("#page_#{company.id} .icon.toggle").click
|
|
113
113
|
|
|
114
114
|
expect(page).to have_content(team.title)
|
|
115
115
|
expect(page).to have_content(locations.title)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
it "expands children when nested multiple levels deep", js: true do
|
|
119
|
-
find("#page_#{company.id} .
|
|
120
|
-
find("#page_#{locations.id} .
|
|
119
|
+
find("#page_#{company.id} .icon.toggle").click
|
|
120
|
+
find("#page_#{locations.id} .icon.toggle").click
|
|
121
121
|
|
|
122
122
|
expect(page).to have_content("New York")
|
|
123
123
|
end
|
|
@@ -125,8 +125,8 @@ module Refinery
|
|
|
125
125
|
|
|
126
126
|
context "with auto expand option turned on" do
|
|
127
127
|
before do
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
Refinery::Pages.auto_expand_admin_tree = true
|
|
129
|
+
Rails.cache.clear
|
|
130
130
|
visit refinery.admin_pages_path
|
|
131
131
|
end
|
|
132
132
|
|
|
@@ -134,17 +134,27 @@ module Refinery
|
|
|
134
134
|
expect(page).to have_content(team.title)
|
|
135
135
|
expect(page).to have_content(locations.title)
|
|
136
136
|
end
|
|
137
|
+
|
|
138
|
+
it "refreshes the cache if sub_children change", js: true do
|
|
139
|
+
expect(page).to have_content(location.title)
|
|
140
|
+
|
|
141
|
+
within page.find("#page_#{location.id}") do
|
|
142
|
+
first(title_link_selector).click
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
fill_in "page_title", with: 'Las Vegas'
|
|
146
|
+
click_button "Save"
|
|
147
|
+
expect(page).to have_content('Las Vegas')
|
|
148
|
+
end
|
|
137
149
|
end
|
|
138
150
|
end
|
|
139
151
|
end
|
|
140
152
|
|
|
141
|
-
describe "new/create" do
|
|
142
|
-
it "Creates a page", js:true do
|
|
153
|
+
describe " new / create " do
|
|
154
|
+
it " Creates a page ", js: true do
|
|
143
155
|
visit refinery.admin_pages_path
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
fill_in "Title", :with => "My first page"
|
|
156
|
+
find('a', text: 'Add new page').click
|
|
157
|
+
fill_in "Title", with: "My first page"
|
|
148
158
|
expect { click_button "Save" }.to change(Refinery::Page, :count).from(0).to(1)
|
|
149
159
|
|
|
150
160
|
expect(page).to have_content("'My first page' was successfully added.")
|
|
@@ -161,11 +171,11 @@ module Refinery
|
|
|
161
171
|
it "includes menu title field", js: true do
|
|
162
172
|
visit refinery.new_admin_page_path
|
|
163
173
|
|
|
164
|
-
fill_in "Title", :
|
|
174
|
+
fill_in "Title", with: "My first page"
|
|
165
175
|
|
|
166
|
-
find('#toggle_advanced_options').
|
|
176
|
+
find('#toggle_advanced_options').click
|
|
167
177
|
|
|
168
|
-
fill_in "Menu title", :
|
|
178
|
+
fill_in "Menu title", with: "The first page"
|
|
169
179
|
|
|
170
180
|
# For some reason the first click doesn't always work?
|
|
171
181
|
begin
|
|
@@ -179,17 +189,25 @@ module Refinery
|
|
|
179
189
|
end
|
|
180
190
|
|
|
181
191
|
it "allows to easily create nested page" do
|
|
182
|
-
parent_page = Page.create! :
|
|
192
|
+
parent_page = Page.create! title: "Rails 4"
|
|
183
193
|
|
|
184
194
|
visit refinery.admin_pages_path
|
|
185
195
|
|
|
186
|
-
find("a[href='#{refinery.new_admin_page_path(:
|
|
196
|
+
find("a[href='#{refinery.new_admin_page_path(parent_id: parent_page.id)}']").click
|
|
187
197
|
|
|
188
|
-
fill_in "Title", :
|
|
198
|
+
fill_in "Title", with: "Parent page"
|
|
189
199
|
click_button "Save"
|
|
190
200
|
|
|
191
201
|
expect(page).to have_content("'Parent page' was successfully added.")
|
|
192
202
|
end
|
|
203
|
+
|
|
204
|
+
it "names the field in validation errors" do
|
|
205
|
+
visit refinery.new_admin_page_path
|
|
206
|
+
|
|
207
|
+
click_button "Save"
|
|
208
|
+
|
|
209
|
+
expect(page).to have_content("Title can't be blank")
|
|
210
|
+
end
|
|
193
211
|
end
|
|
194
212
|
|
|
195
213
|
describe "edit/update" do
|
|
@@ -205,9 +223,9 @@ module Refinery
|
|
|
205
223
|
|
|
206
224
|
context 'when saving and returning to index' do
|
|
207
225
|
it "updates page", js: true do
|
|
208
|
-
|
|
226
|
+
first(edit_selector(slug: updateable_page.slug)).click
|
|
209
227
|
|
|
210
|
-
fill_in "Title", :
|
|
228
|
+
fill_in "Title", with: "Updated"
|
|
211
229
|
find("#submit_button").click
|
|
212
230
|
|
|
213
231
|
expect(page).to have_content("'Updated' was successfully updated.")
|
|
@@ -216,10 +234,10 @@ module Refinery
|
|
|
216
234
|
|
|
217
235
|
context 'when saving and continuing to edit', js: true do
|
|
218
236
|
before :each do
|
|
219
|
-
expect(page).to have_selector(
|
|
220
|
-
|
|
237
|
+
expect(page).to have_selector(edit_selector(slug: updateable_page.slug), visible: true)
|
|
238
|
+
first(edit_selector(slug: updateable_page.slug)).click
|
|
221
239
|
|
|
222
|
-
fill_in "Title", :
|
|
240
|
+
fill_in "Title", with: "Updated you"
|
|
223
241
|
find("#submit_continue_button").click
|
|
224
242
|
find('#flash').visible?
|
|
225
243
|
end
|
|
@@ -249,12 +267,12 @@ module Refinery
|
|
|
249
267
|
describe 'Previewing', js: true do
|
|
250
268
|
let(:preview_content) { "Some changes I'm unsure what they will look like".freeze }
|
|
251
269
|
context "an existing page" do
|
|
252
|
-
before { Page.create :
|
|
270
|
+
before { Page.create title: 'Preview me' }
|
|
253
271
|
|
|
254
272
|
it 'will show the preview changes in a new window' do
|
|
255
273
|
visit refinery.admin_pages_path
|
|
256
274
|
|
|
257
|
-
|
|
275
|
+
first(edit_selector).click
|
|
258
276
|
fill_in "Title", with: preview_content
|
|
259
277
|
window = window_opened_by do
|
|
260
278
|
click_button "Preview"
|
|
@@ -268,7 +286,7 @@ module Refinery
|
|
|
268
286
|
it 'will not show the site bar' do
|
|
269
287
|
visit refinery.admin_pages_path
|
|
270
288
|
|
|
271
|
-
|
|
289
|
+
first(edit_selector).click
|
|
272
290
|
fill_in "Title", with: preview_content
|
|
273
291
|
window = window_opened_by do
|
|
274
292
|
click_button "Preview"
|
|
@@ -277,11 +295,11 @@ module Refinery
|
|
|
277
295
|
expect_window_without_content(
|
|
278
296
|
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
279
297
|
window: window
|
|
280
|
-
|
|
298
|
+
)
|
|
281
299
|
expect_window_without_content(
|
|
282
300
|
::I18n.t('switch_to_website_editor', scope: 'refinery.site_bar'),
|
|
283
301
|
window: window
|
|
284
|
-
|
|
302
|
+
)
|
|
285
303
|
|
|
286
304
|
window.close
|
|
287
305
|
end
|
|
@@ -289,7 +307,7 @@ module Refinery
|
|
|
289
307
|
it 'will not save the preview changes' do
|
|
290
308
|
visit refinery.admin_pages_path
|
|
291
309
|
|
|
292
|
-
|
|
310
|
+
first(edit_selector).click
|
|
293
311
|
fill_in "Title", with: preview_content
|
|
294
312
|
window = window_opened_by do
|
|
295
313
|
click_button "Preview"
|
|
@@ -298,7 +316,7 @@ module Refinery
|
|
|
298
316
|
expect_window_with_content(
|
|
299
317
|
preview_content,
|
|
300
318
|
window: window
|
|
301
|
-
|
|
319
|
+
)
|
|
302
320
|
|
|
303
321
|
window.close
|
|
304
322
|
|
|
@@ -309,8 +327,8 @@ module Refinery
|
|
|
309
327
|
it 'will show the preview in a new window after save-and-continue' do
|
|
310
328
|
visit refinery.admin_pages_path
|
|
311
329
|
|
|
312
|
-
|
|
313
|
-
fill_in "Title", :
|
|
330
|
+
first(edit_selector).click
|
|
331
|
+
fill_in "Title", with: "Save this"
|
|
314
332
|
click_button "Save & continue editing"
|
|
315
333
|
expect(page).to have_content("'Save this' was successfully updated")
|
|
316
334
|
|
|
@@ -320,9 +338,9 @@ module Refinery
|
|
|
320
338
|
|
|
321
339
|
expect_window_with_content("Save this", window: window)
|
|
322
340
|
expect_window_without_content(
|
|
323
|
-
::I18n.t('switch_to_website', :
|
|
341
|
+
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
324
342
|
window: window
|
|
325
|
-
|
|
343
|
+
)
|
|
326
344
|
|
|
327
345
|
window.close
|
|
328
346
|
end
|
|
@@ -332,8 +350,8 @@ module Refinery
|
|
|
332
350
|
it 'will save-and-continue after show the preview in a new window' do
|
|
333
351
|
visit refinery.admin_pages_path
|
|
334
352
|
|
|
335
|
-
|
|
336
|
-
fill_in "Title", :
|
|
353
|
+
first(title_link_selector).click
|
|
354
|
+
fill_in "Title", with: "Save this"
|
|
337
355
|
|
|
338
356
|
window = window_opened_by do
|
|
339
357
|
click_button "Preview"
|
|
@@ -341,23 +359,26 @@ module Refinery
|
|
|
341
359
|
|
|
342
360
|
expect_window_with_content("Save this", window: window)
|
|
343
361
|
expect_window_without_content(
|
|
344
|
-
::I18n.t('switch_to_website', :
|
|
362
|
+
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
345
363
|
window: window
|
|
346
364
|
)
|
|
347
365
|
|
|
348
366
|
window.close
|
|
349
367
|
|
|
368
|
+
# Wait for JavaScript setTimeout to restore form action after preview
|
|
369
|
+
expect(page).to have_no_css("form[action*='/preview/']", wait: 1)
|
|
370
|
+
|
|
350
371
|
click_button "Save & continue editing"
|
|
351
372
|
expect(page).to have_content("'Save this' was successfully updated")
|
|
352
373
|
end
|
|
353
374
|
|
|
354
|
-
it 'will show pages with inherited templates', js:true do
|
|
375
|
+
it 'will show pages with inherited templates', js: true do
|
|
355
376
|
visit refinery.admin_pages_path
|
|
356
377
|
|
|
357
|
-
|
|
358
|
-
fill_in 'Title', :
|
|
359
|
-
find('#toggle_advanced_options').
|
|
360
|
-
select 'Searchable', :
|
|
378
|
+
first(edit_selector).click
|
|
379
|
+
fill_in 'Title', with: 'Searchable'
|
|
380
|
+
find('#toggle_advanced_options').click
|
|
381
|
+
select 'Searchable', from: 'View template'
|
|
361
382
|
Timeout::timeout(5) do
|
|
362
383
|
click_button 'Preview'
|
|
363
384
|
sleep 0.1 and redo unless windows.many?
|
|
@@ -367,11 +388,11 @@ module Refinery
|
|
|
367
388
|
end
|
|
368
389
|
|
|
369
390
|
context 'a brand new page' do
|
|
370
|
-
it "will not save when just previewing", js:true do
|
|
391
|
+
it "will not save when just previewing", js: true do
|
|
371
392
|
visit refinery.admin_pages_path
|
|
372
393
|
|
|
373
|
-
find('a', text: 'Add new page').
|
|
374
|
-
fill_in "Title", :
|
|
394
|
+
find('a', text: 'Add new page').click
|
|
395
|
+
fill_in "Title", with: "My first page"
|
|
375
396
|
window = window_opened_by do
|
|
376
397
|
click_button "Preview"
|
|
377
398
|
end
|
|
@@ -384,34 +405,36 @@ module Refinery
|
|
|
384
405
|
end
|
|
385
406
|
|
|
386
407
|
context 'a nested page' do
|
|
387
|
-
let!(:parent_page) { Page.create :
|
|
388
|
-
let!(:nested_page) { parent_page.children.create :
|
|
408
|
+
let!(:parent_page) { Page.create title: "Our Parent Page" }
|
|
409
|
+
let!(:nested_page) { parent_page.children.create title: 'Preview Me' }
|
|
389
410
|
|
|
390
|
-
it "works like an un-nested page" do
|
|
411
|
+
it "works like an un-nested page", js: true do
|
|
391
412
|
visit refinery.admin_pages_path
|
|
392
413
|
|
|
393
|
-
within "#page_#{nested_page.id}" do
|
|
394
|
-
|
|
414
|
+
within "#page_#{nested_page.id} .item" do
|
|
415
|
+
first(title_link_selector).click
|
|
395
416
|
end
|
|
396
417
|
|
|
397
418
|
fill_in "Title", with: preview_content
|
|
398
|
-
window = window_opened_by do
|
|
419
|
+
window = page.window_opened_by do
|
|
399
420
|
click_button "Preview"
|
|
400
421
|
end
|
|
401
422
|
|
|
402
|
-
expect_window_with_content(preview_content)
|
|
423
|
+
expect_window_with_content(preview_content, window: window)
|
|
403
424
|
end
|
|
404
425
|
end
|
|
405
426
|
end
|
|
406
427
|
|
|
407
428
|
describe "destroy" do
|
|
408
|
-
context "when page can be deleted", js:true do
|
|
409
|
-
before { Page.create :
|
|
429
|
+
context "when page can be deleted", js: true do
|
|
430
|
+
before { Page.create title: "Delete me" }
|
|
410
431
|
|
|
411
432
|
it "will show delete button" do
|
|
412
433
|
visit refinery.admin_pages_path
|
|
413
434
|
|
|
414
|
-
find('a[tooltip="Remove this page forever"]').
|
|
435
|
+
find('a[tooltip="Remove this page forever"]').click
|
|
436
|
+
|
|
437
|
+
page.accept_alert
|
|
415
438
|
|
|
416
439
|
expect(page).to have_content("'Delete me' was successfully removed.")
|
|
417
440
|
|
|
@@ -420,7 +443,7 @@ module Refinery
|
|
|
420
443
|
end
|
|
421
444
|
|
|
422
445
|
context "when page can't be deleted" do
|
|
423
|
-
before { Page.create :
|
|
446
|
+
before { Page.create title: "Indestructible", deletable: false }
|
|
424
447
|
|
|
425
448
|
it "wont show delete button" do
|
|
426
449
|
visit refinery.admin_pages_path
|
|
@@ -432,12 +455,12 @@ module Refinery
|
|
|
432
455
|
end
|
|
433
456
|
|
|
434
457
|
context "duplicate page titles" do
|
|
435
|
-
before { Page.create :
|
|
458
|
+
before { Page.create title: "I was here first" }
|
|
436
459
|
|
|
437
460
|
it "will append nr to url path" do
|
|
438
461
|
visit refinery.new_admin_page_path
|
|
439
462
|
|
|
440
|
-
fill_in "Title", :
|
|
463
|
+
fill_in "Title", with: "I was here first"
|
|
441
464
|
click_button "Save"
|
|
442
465
|
|
|
443
466
|
expect(Refinery::Page.last.url[:path].first).to match(%r{\Ai-was-here-first-.+?})
|
|
@@ -447,25 +470,27 @@ module Refinery
|
|
|
447
470
|
context "with translations" do
|
|
448
471
|
before do
|
|
449
472
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
|
|
473
|
+
end
|
|
450
474
|
|
|
475
|
+
before do
|
|
451
476
|
# Create a home page in both locales (needed to test menus)
|
|
452
|
-
home_page =
|
|
453
|
-
Page.create :
|
|
454
|
-
|
|
455
|
-
|
|
477
|
+
home_page = Mobility.with_locale(:en) do
|
|
478
|
+
Page.create title: 'Home',
|
|
479
|
+
link_url: '/',
|
|
480
|
+
menu_match: "^/$"
|
|
456
481
|
end
|
|
457
482
|
|
|
458
|
-
|
|
483
|
+
Mobility.with_locale(:ru) do
|
|
459
484
|
home_page.title = 'Домашняя страница'
|
|
460
485
|
home_page.save
|
|
461
486
|
end
|
|
462
487
|
end
|
|
463
488
|
|
|
464
|
-
describe "add a page with title for default locale", js:true do
|
|
489
|
+
describe "add a page with title for default locale", js: true do
|
|
465
490
|
before do
|
|
466
491
|
visit refinery.admin_pages_path
|
|
467
|
-
find('a', text: "Add new page").
|
|
468
|
-
fill_in "Title", :
|
|
492
|
+
find('a', text: "Add new page").click
|
|
493
|
+
fill_in "Title", with: "News"
|
|
469
494
|
click_button "Save"
|
|
470
495
|
end
|
|
471
496
|
|
|
@@ -474,24 +499,21 @@ module Refinery
|
|
|
474
499
|
expect(Refinery::Page.count).to eq(2)
|
|
475
500
|
end
|
|
476
501
|
|
|
477
|
-
it "
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
expect(page).
|
|
481
|
-
expect(page).to have_content('EN')
|
|
502
|
+
it "doesn't show locale for default frontend locale" do
|
|
503
|
+
within "#page_#{::Refinery::Page.by_slug('news').first.id}" do
|
|
504
|
+
expect(page).not_to have_selector(".locales")
|
|
505
|
+
expect(page).not_to have_selector(locale_link_selector(locale: 'en'))
|
|
482
506
|
end
|
|
483
507
|
end
|
|
484
508
|
|
|
485
509
|
it "shows title in the admin menu" do
|
|
486
|
-
|
|
487
|
-
within "#page_#{p.id}" do
|
|
510
|
+
within "#page_#{::Refinery::Page.by_slug('news').first.id}" do
|
|
488
511
|
expect(page).to have_content('News')
|
|
489
|
-
expect(page.
|
|
512
|
+
expect(page.first(title_link_selector)[:text]).to have_content('News')
|
|
490
513
|
end
|
|
491
514
|
end
|
|
492
515
|
|
|
493
516
|
it "shows in frontend menu for 'en' locale" do
|
|
494
|
-
# page.driver.debug
|
|
495
517
|
visit "/"
|
|
496
518
|
|
|
497
519
|
within "#menu" do
|
|
@@ -505,7 +527,7 @@ module Refinery
|
|
|
505
527
|
|
|
506
528
|
within "#menu" do
|
|
507
529
|
# we should only have the home page in the menu
|
|
508
|
-
expect(page).to have_css('li', :
|
|
530
|
+
expect(page).to have_css('li', count: 1)
|
|
509
531
|
end
|
|
510
532
|
end
|
|
511
533
|
end
|
|
@@ -516,17 +538,12 @@ module Refinery
|
|
|
516
538
|
let(:ru_page_title) { 'Новости' }
|
|
517
539
|
let(:ru_page_slug_encoded) { '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8' }
|
|
518
540
|
let!(:news_page) do
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
Globalize.with_locale(:ru) do
|
|
525
|
-
_page.title = ru_page_title
|
|
526
|
-
_page.save
|
|
541
|
+
Mobility.with_locale(:en) { Page.create(title: en_page_title) }.tap do |localised_page|
|
|
542
|
+
Mobility.with_locale(:ru) do
|
|
543
|
+
localised_page.title = ru_page_title
|
|
544
|
+
localised_page.save
|
|
545
|
+
end
|
|
527
546
|
end
|
|
528
|
-
|
|
529
|
-
_page
|
|
530
547
|
end
|
|
531
548
|
|
|
532
549
|
it "can have a title for each locale" do
|
|
@@ -536,7 +553,7 @@ module Refinery
|
|
|
536
553
|
click_link "Add new page"
|
|
537
554
|
switch_page_form_locale "RU"
|
|
538
555
|
|
|
539
|
-
fill_in "Title", :
|
|
556
|
+
fill_in "Title", with: ru_page_title
|
|
540
557
|
click_button "Save"
|
|
541
558
|
expect(page).to have_selector("#page_#{Page.last.id} .actions")
|
|
542
559
|
|
|
@@ -545,20 +562,23 @@ module Refinery
|
|
|
545
562
|
end
|
|
546
563
|
|
|
547
564
|
switch_page_form_locale "EN"
|
|
548
|
-
fill_in "Title", :
|
|
565
|
+
fill_in "Title", with: en_page_title
|
|
549
566
|
find("#submit_button").click
|
|
550
567
|
|
|
551
568
|
expect(page).to have_content("'#{en_page_title}' was successfully updated.")
|
|
552
569
|
expect(Refinery::Page.count).to eq(2)
|
|
553
570
|
end
|
|
554
571
|
|
|
555
|
-
it "is shown with
|
|
572
|
+
it "is shown with only the non-default locale in the index" do
|
|
556
573
|
visit refinery.admin_pages_path
|
|
557
574
|
|
|
558
|
-
within "#page_#{news_page.id}
|
|
559
|
-
expect(page).to
|
|
560
|
-
|
|
561
|
-
|
|
575
|
+
within "#page_#{news_page.id}" do
|
|
576
|
+
expect(page).to have_selector(".locales")
|
|
577
|
+
|
|
578
|
+
within ".locales" do
|
|
579
|
+
expect(page).to have_selector(locale_link_selector(locale: 'ru'))
|
|
580
|
+
expect(page).to have_no_selector(locale_link_selector(locale: 'en'))
|
|
581
|
+
end
|
|
562
582
|
end
|
|
563
583
|
end
|
|
564
584
|
|
|
@@ -574,7 +594,7 @@ module Refinery
|
|
|
574
594
|
visit refinery.admin_pages_path
|
|
575
595
|
|
|
576
596
|
within "#page_#{news_page.id}" do
|
|
577
|
-
expect(page.
|
|
597
|
+
expect(page.first(title_link_selector)[:href]).to match(en_page_slug)
|
|
578
598
|
end
|
|
579
599
|
end
|
|
580
600
|
|
|
@@ -595,10 +615,10 @@ module Refinery
|
|
|
595
615
|
end
|
|
596
616
|
end
|
|
597
617
|
|
|
598
|
-
describe "add a page with title only for secondary locale", js:true do
|
|
618
|
+
describe "add a page with title only for secondary locale", js: true do
|
|
599
619
|
let(:ru_page) {
|
|
600
|
-
|
|
601
|
-
Page.create :
|
|
620
|
+
Mobility.with_locale(:ru) {
|
|
621
|
+
Page.create title: ru_page_title
|
|
602
622
|
}
|
|
603
623
|
}
|
|
604
624
|
let(:ru_page_id) { ru_page.id }
|
|
@@ -612,10 +632,10 @@ module Refinery
|
|
|
612
632
|
|
|
613
633
|
it "lets you add a Russian title without an English title" do
|
|
614
634
|
ru_page.destroy!
|
|
615
|
-
find('a', text: 'Add new page').
|
|
635
|
+
find('a', text: 'Add new page').click
|
|
616
636
|
switch_page_form_locale "RU"
|
|
617
637
|
|
|
618
|
-
fill_in "Title", :
|
|
638
|
+
fill_in "Title", with: ru_page_title
|
|
619
639
|
click_button "Save"
|
|
620
640
|
|
|
621
641
|
expect(page).to have_content("'#{ru_page_title}' was successfully added.")
|
|
@@ -624,13 +644,13 @@ module Refinery
|
|
|
624
644
|
|
|
625
645
|
it "shows locale indicator for page" do
|
|
626
646
|
within "#page_#{ru_page_id}" do
|
|
627
|
-
expect(page).to have_selector(
|
|
647
|
+
expect(page).to have_selector(locale_link_selector(locale: 'ru'))
|
|
628
648
|
end
|
|
629
649
|
end
|
|
630
650
|
|
|
631
651
|
it "doesn't show locale indicator for primary locale" do
|
|
632
652
|
within "#page_#{ru_page_id}" do
|
|
633
|
-
expect(page).to_not have_selector('
|
|
653
|
+
expect(page).to_not have_selector(locale_picker('en'))
|
|
634
654
|
end
|
|
635
655
|
end
|
|
636
656
|
|
|
@@ -640,9 +660,9 @@ module Refinery
|
|
|
640
660
|
end
|
|
641
661
|
end
|
|
642
662
|
|
|
643
|
-
it "uses slug in admin" do
|
|
663
|
+
it "uses secondary locale slug in admin" do
|
|
644
664
|
within "#page_#{ru_page_id}" do
|
|
645
|
-
expect(page.find(
|
|
665
|
+
expect(page.find(title_link_selector)[:href]).to match(ru_page_slug_encoded)
|
|
646
666
|
end
|
|
647
667
|
end
|
|
648
668
|
|
|
@@ -660,23 +680,23 @@ module Refinery
|
|
|
660
680
|
|
|
661
681
|
within "#menu" do
|
|
662
682
|
# we should only have the home page in the menu
|
|
663
|
-
expect(page).to have_css('li', :
|
|
683
|
+
expect(page).to have_css('li', count: 1)
|
|
664
684
|
end
|
|
665
685
|
end
|
|
666
686
|
|
|
667
687
|
context "when page is a child page" do
|
|
668
688
|
it 'succeeds' do
|
|
669
689
|
ru_page.destroy!
|
|
670
|
-
parent_page = Page.create(:
|
|
671
|
-
sub_page =
|
|
672
|
-
Page.create :
|
|
690
|
+
parent_page = Page.create(title: "Parent page")
|
|
691
|
+
sub_page = Mobility.with_locale(:ru) {
|
|
692
|
+
Page.create title: ru_page_title, parent_id: parent_page.id
|
|
673
693
|
}
|
|
674
694
|
expect(sub_page.parent).to eq(parent_page)
|
|
675
695
|
visit refinery.admin_pages_path
|
|
676
696
|
within "#page_#{sub_page.id}" do
|
|
677
|
-
|
|
697
|
+
first(edit_selector).click
|
|
678
698
|
end
|
|
679
|
-
fill_in "Title", :
|
|
699
|
+
fill_in "Title", with: ru_page_title
|
|
680
700
|
click_button "Save"
|
|
681
701
|
expect(page).to have_content("'#{ru_page_title}' was successfully updated")
|
|
682
702
|
end
|
|
@@ -691,10 +711,10 @@ module Refinery
|
|
|
691
711
|
|
|
692
712
|
it "adds new page part", js: true do
|
|
693
713
|
visit refinery.new_admin_page_path
|
|
694
|
-
find("#add_page_part").
|
|
714
|
+
find("#add_page_part").click
|
|
695
715
|
|
|
696
716
|
within "#new_page_part_dialog" do
|
|
697
|
-
fill_in "new_page_part_title", :
|
|
717
|
+
fill_in "new_page_part_title", with: "testy"
|
|
698
718
|
click_button "Save"
|
|
699
719
|
end
|
|
700
720
|
|
|
@@ -705,12 +725,12 @@ module Refinery
|
|
|
705
725
|
end
|
|
706
726
|
|
|
707
727
|
describe "delete existing page part" do
|
|
708
|
-
let!(:some_page) { Page.create! :
|
|
728
|
+
let!(:some_page) { Page.create! title: "Some Page" }
|
|
709
729
|
|
|
710
730
|
before do
|
|
711
|
-
some_page.parts.create! :
|
|
712
|
-
some_page.parts.create! :
|
|
713
|
-
some_page.parts.create! :
|
|
731
|
+
some_page.parts.create! title: "First Part", slug: "first_part", position: 1
|
|
732
|
+
some_page.parts.create! title: "Second Part", slug: "second_part", position: 2
|
|
733
|
+
some_page.parts.create! title: "Third Part", slug: "third_part", position: 3
|
|
714
734
|
|
|
715
735
|
allow(Refinery::Pages).to receive(:new_page_parts).and_return(true)
|
|
716
736
|
end
|
|
@@ -725,7 +745,7 @@ module Refinery
|
|
|
725
745
|
end
|
|
726
746
|
|
|
727
747
|
2.times do
|
|
728
|
-
find("#delete_page_part").
|
|
748
|
+
find("#delete_page_part").click
|
|
729
749
|
# Poltergeist automatically accepts dialogues.
|
|
730
750
|
if Capybara.javascript_driver != :poltergeist
|
|
731
751
|
page.driver.browser.switch_to.alert.accept
|
|
@@ -757,16 +777,16 @@ module Refinery
|
|
|
757
777
|
allow(Refinery::Pages).to receive(:use_layout_templates).and_return(true)
|
|
758
778
|
allow(Refinery::Pages).to receive(:layout_template_whitelist).and_return(['abc', 'refinery'])
|
|
759
779
|
allow(Refinery::Pages).to receive(:valid_templates).and_return(['abc', 'refinery'])
|
|
760
|
-
parent_page = Page.create :
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
@page = parent_page.children.create :
|
|
780
|
+
parent_page = Page.create title: 'Parent Page',
|
|
781
|
+
view_template: 'refinery',
|
|
782
|
+
layout_template: 'refinery'
|
|
783
|
+
@page = parent_page.children.create title: 'Child Page'
|
|
764
784
|
end
|
|
765
785
|
|
|
766
786
|
specify 'sub page should inherit them', js: true do
|
|
767
787
|
visit refinery.edit_admin_page_path(@page.id)
|
|
768
788
|
|
|
769
|
-
find('#toggle_advanced_options').
|
|
789
|
+
find('#toggle_advanced_options').click
|
|
770
790
|
|
|
771
791
|
within '#page_layout_template' do
|
|
772
792
|
expect(page.find('option[value=refinery]')).to be_selected
|
|
@@ -783,7 +803,7 @@ module Refinery
|
|
|
783
803
|
# regression spec for https://github.com/refinery/refinerycms/issues/1891
|
|
784
804
|
describe "a page part with HTML" do
|
|
785
805
|
before do
|
|
786
|
-
page = Refinery::Page.create! :
|
|
806
|
+
page = Refinery::Page.create! title: "test"
|
|
787
807
|
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
|
788
808
|
page.parts.create(
|
|
789
809
|
title: default_page_part[:title],
|
|
@@ -794,37 +814,35 @@ module Refinery
|
|
|
794
814
|
end
|
|
795
815
|
end
|
|
796
816
|
|
|
797
|
-
specify "should retain the html", js:true do
|
|
817
|
+
specify "should retain the html", js: true do
|
|
798
818
|
visit refinery.admin_pages_path
|
|
799
|
-
|
|
800
|
-
Capybara.ignore_hidden_elements
|
|
801
|
-
|
|
802
|
-
|
|
819
|
+
first(edit_selector(slug: 'test')).click
|
|
820
|
+
Capybara.ignore_hidden_elements do
|
|
821
|
+
expect(page).to have_content("header class='regression'")
|
|
822
|
+
end
|
|
803
823
|
end
|
|
804
824
|
end
|
|
805
825
|
end
|
|
806
826
|
|
|
807
|
-
describe "TranslatePages", :
|
|
808
|
-
before {
|
|
827
|
+
describe "TranslatePages", type: :system do
|
|
828
|
+
before { Mobility.locale = :en }
|
|
809
829
|
refinery_login
|
|
810
830
|
|
|
811
831
|
describe "a page with a single locale" do
|
|
812
832
|
before do
|
|
813
833
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :lv])
|
|
814
|
-
Page.create :title => 'First Page'
|
|
815
834
|
end
|
|
835
|
+
let(:first_page) { Page.create title: 'First Page' }
|
|
816
836
|
|
|
817
837
|
it "can have a second locale added to it" do
|
|
818
|
-
visit refinery.
|
|
838
|
+
visit refinery.edit_admin_page_path(first_page.id)
|
|
819
839
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
fill_in "Title", :with => "Brīva vieta reklāmai"
|
|
840
|
+
switch_page_form_locale "lv"
|
|
841
|
+
fill_in "Title", with: "Brīva vieta reklāmai"
|
|
824
842
|
click_button "Save"
|
|
825
843
|
|
|
826
|
-
expect(page).to have_content("'Brīva vieta reklāmai' was successfully
|
|
827
|
-
expect(
|
|
844
|
+
expect(page).to have_content("'Brīva vieta reklāmai' was successfully updated.")
|
|
845
|
+
expect(first_page.translations.count).to eq(2)
|
|
828
846
|
end
|
|
829
847
|
end
|
|
830
848
|
|
|
@@ -833,11 +851,11 @@ module Refinery
|
|
|
833
851
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return [:en, :ru]
|
|
834
852
|
|
|
835
853
|
# Create a page in both locales
|
|
836
|
-
about_page =
|
|
837
|
-
Page.create :
|
|
854
|
+
about_page = Mobility.with_locale(:en) do
|
|
855
|
+
Page.create title: 'About'
|
|
838
856
|
end
|
|
839
857
|
|
|
840
|
-
|
|
858
|
+
Mobility.with_locale(:ru) do
|
|
841
859
|
about_page.title = 'About Ru'
|
|
842
860
|
about_page.save
|
|
843
861
|
end
|
|
@@ -847,7 +865,7 @@ module Refinery
|
|
|
847
865
|
page = Refinery::Page.last
|
|
848
866
|
# we need page parts so that there's a visual editor
|
|
849
867
|
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
|
850
|
-
page.parts.create(:
|
|
868
|
+
page.parts.create(title: default_page_part[:title], slug: default_page_part[:slug], body: nil, position: index)
|
|
851
869
|
end
|
|
852
870
|
page
|
|
853
871
|
end
|
|
@@ -857,14 +875,14 @@ module Refinery
|
|
|
857
875
|
before { Refinery::Pages.absolute_page_links = false }
|
|
858
876
|
|
|
859
877
|
it "shows Russian pages if we're editing the Russian locale" do
|
|
860
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
878
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true, switch_locale: :ru)
|
|
861
879
|
|
|
862
880
|
expect(page).to have_content("About Ru")
|
|
863
881
|
expect(page).to have_selector("a[href='/ru/about-ru']")
|
|
864
882
|
end
|
|
865
883
|
|
|
866
884
|
it "shows default to the default locale if no query string is added" do
|
|
867
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
885
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true)
|
|
868
886
|
|
|
869
887
|
expect(page).to have_content("About")
|
|
870
888
|
expect(page).to have_selector("a[href='/about']")
|
|
@@ -875,17 +893,16 @@ module Refinery
|
|
|
875
893
|
before { Refinery::Pages.absolute_page_links = true }
|
|
876
894
|
|
|
877
895
|
it "shows Russian pages if we're editing the Russian locale" do
|
|
878
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
879
|
-
|
|
896
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true, switch_locale: :ru)
|
|
880
897
|
expect(page).to have_content("About Ru")
|
|
881
|
-
expect(page).to have_selector("a[href
|
|
898
|
+
expect(page).to have_selector("a[href$='ru/about-ru']")
|
|
882
899
|
end
|
|
883
900
|
|
|
884
901
|
it "shows default to the default locale if no query string is added" do
|
|
885
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
902
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true)
|
|
886
903
|
|
|
887
904
|
expect(page).to have_content("About")
|
|
888
|
-
expect(page).to have_selector("a[href
|
|
905
|
+
expect(page).to have_selector("a[href$='about']")
|
|
889
906
|
end
|
|
890
907
|
end
|
|
891
908
|
end
|