refinerycms-pages 4.0.3 → 4.1.0
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 -22
- 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 +164 -155
- data/spec/{features → system}/refinery/pages_spec.rb +10 -10
- metadata +48 -106
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
|
@@ -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,13 +189,13 @@ 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.")
|
|
@@ -205,9 +215,9 @@ module Refinery
|
|
|
205
215
|
|
|
206
216
|
context 'when saving and returning to index' do
|
|
207
217
|
it "updates page", js: true do
|
|
208
|
-
|
|
218
|
+
first(edit_selector(slug: updateable_page.slug)).click
|
|
209
219
|
|
|
210
|
-
fill_in "Title", :
|
|
220
|
+
fill_in "Title", with: "Updated"
|
|
211
221
|
find("#submit_button").click
|
|
212
222
|
|
|
213
223
|
expect(page).to have_content("'Updated' was successfully updated.")
|
|
@@ -216,10 +226,10 @@ module Refinery
|
|
|
216
226
|
|
|
217
227
|
context 'when saving and continuing to edit', js: true do
|
|
218
228
|
before :each do
|
|
219
|
-
expect(page).to have_selector(
|
|
220
|
-
|
|
229
|
+
expect(page).to have_selector(edit_selector(slug: updateable_page.slug), visible: true)
|
|
230
|
+
first(edit_selector(slug: updateable_page.slug)).click
|
|
221
231
|
|
|
222
|
-
fill_in "Title", :
|
|
232
|
+
fill_in "Title", with: "Updated you"
|
|
223
233
|
find("#submit_continue_button").click
|
|
224
234
|
find('#flash').visible?
|
|
225
235
|
end
|
|
@@ -249,12 +259,12 @@ module Refinery
|
|
|
249
259
|
describe 'Previewing', js: true do
|
|
250
260
|
let(:preview_content) { "Some changes I'm unsure what they will look like".freeze }
|
|
251
261
|
context "an existing page" do
|
|
252
|
-
before { Page.create :
|
|
262
|
+
before { Page.create title: 'Preview me' }
|
|
253
263
|
|
|
254
264
|
it 'will show the preview changes in a new window' do
|
|
255
265
|
visit refinery.admin_pages_path
|
|
256
266
|
|
|
257
|
-
|
|
267
|
+
first(edit_selector).click
|
|
258
268
|
fill_in "Title", with: preview_content
|
|
259
269
|
window = window_opened_by do
|
|
260
270
|
click_button "Preview"
|
|
@@ -268,7 +278,7 @@ module Refinery
|
|
|
268
278
|
it 'will not show the site bar' do
|
|
269
279
|
visit refinery.admin_pages_path
|
|
270
280
|
|
|
271
|
-
|
|
281
|
+
first(edit_selector).click
|
|
272
282
|
fill_in "Title", with: preview_content
|
|
273
283
|
window = window_opened_by do
|
|
274
284
|
click_button "Preview"
|
|
@@ -277,11 +287,11 @@ module Refinery
|
|
|
277
287
|
expect_window_without_content(
|
|
278
288
|
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
279
289
|
window: window
|
|
280
|
-
|
|
290
|
+
)
|
|
281
291
|
expect_window_without_content(
|
|
282
292
|
::I18n.t('switch_to_website_editor', scope: 'refinery.site_bar'),
|
|
283
293
|
window: window
|
|
284
|
-
|
|
294
|
+
)
|
|
285
295
|
|
|
286
296
|
window.close
|
|
287
297
|
end
|
|
@@ -289,7 +299,7 @@ module Refinery
|
|
|
289
299
|
it 'will not save the preview changes' do
|
|
290
300
|
visit refinery.admin_pages_path
|
|
291
301
|
|
|
292
|
-
|
|
302
|
+
first(edit_selector).click
|
|
293
303
|
fill_in "Title", with: preview_content
|
|
294
304
|
window = window_opened_by do
|
|
295
305
|
click_button "Preview"
|
|
@@ -298,7 +308,7 @@ module Refinery
|
|
|
298
308
|
expect_window_with_content(
|
|
299
309
|
preview_content,
|
|
300
310
|
window: window
|
|
301
|
-
|
|
311
|
+
)
|
|
302
312
|
|
|
303
313
|
window.close
|
|
304
314
|
|
|
@@ -309,8 +319,8 @@ module Refinery
|
|
|
309
319
|
it 'will show the preview in a new window after save-and-continue' do
|
|
310
320
|
visit refinery.admin_pages_path
|
|
311
321
|
|
|
312
|
-
|
|
313
|
-
fill_in "Title", :
|
|
322
|
+
first(edit_selector).click
|
|
323
|
+
fill_in "Title", with: "Save this"
|
|
314
324
|
click_button "Save & continue editing"
|
|
315
325
|
expect(page).to have_content("'Save this' was successfully updated")
|
|
316
326
|
|
|
@@ -320,9 +330,9 @@ module Refinery
|
|
|
320
330
|
|
|
321
331
|
expect_window_with_content("Save this", window: window)
|
|
322
332
|
expect_window_without_content(
|
|
323
|
-
::I18n.t('switch_to_website', :
|
|
333
|
+
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
324
334
|
window: window
|
|
325
|
-
|
|
335
|
+
)
|
|
326
336
|
|
|
327
337
|
window.close
|
|
328
338
|
end
|
|
@@ -332,8 +342,8 @@ module Refinery
|
|
|
332
342
|
it 'will save-and-continue after show the preview in a new window' do
|
|
333
343
|
visit refinery.admin_pages_path
|
|
334
344
|
|
|
335
|
-
|
|
336
|
-
fill_in "Title", :
|
|
345
|
+
first(title_link_selector).click
|
|
346
|
+
fill_in "Title", with: "Save this"
|
|
337
347
|
|
|
338
348
|
window = window_opened_by do
|
|
339
349
|
click_button "Preview"
|
|
@@ -341,23 +351,26 @@ module Refinery
|
|
|
341
351
|
|
|
342
352
|
expect_window_with_content("Save this", window: window)
|
|
343
353
|
expect_window_without_content(
|
|
344
|
-
::I18n.t('switch_to_website', :
|
|
354
|
+
::I18n.t('switch_to_website', scope: 'refinery.site_bar'),
|
|
345
355
|
window: window
|
|
346
356
|
)
|
|
347
357
|
|
|
348
358
|
window.close
|
|
349
359
|
|
|
360
|
+
# Wait for JavaScript setTimeout to restore form action after preview
|
|
361
|
+
expect(page).to have_no_css("form[action*='/preview/']", wait: 1)
|
|
362
|
+
|
|
350
363
|
click_button "Save & continue editing"
|
|
351
364
|
expect(page).to have_content("'Save this' was successfully updated")
|
|
352
365
|
end
|
|
353
366
|
|
|
354
|
-
it 'will show pages with inherited templates', js:true do
|
|
367
|
+
it 'will show pages with inherited templates', js: true do
|
|
355
368
|
visit refinery.admin_pages_path
|
|
356
369
|
|
|
357
|
-
|
|
358
|
-
fill_in 'Title', :
|
|
359
|
-
find('#toggle_advanced_options').
|
|
360
|
-
select 'Searchable', :
|
|
370
|
+
first(edit_selector).click
|
|
371
|
+
fill_in 'Title', with: 'Searchable'
|
|
372
|
+
find('#toggle_advanced_options').click
|
|
373
|
+
select 'Searchable', from: 'View template'
|
|
361
374
|
Timeout::timeout(5) do
|
|
362
375
|
click_button 'Preview'
|
|
363
376
|
sleep 0.1 and redo unless windows.many?
|
|
@@ -367,11 +380,11 @@ module Refinery
|
|
|
367
380
|
end
|
|
368
381
|
|
|
369
382
|
context 'a brand new page' do
|
|
370
|
-
it "will not save when just previewing", js:true do
|
|
383
|
+
it "will not save when just previewing", js: true do
|
|
371
384
|
visit refinery.admin_pages_path
|
|
372
385
|
|
|
373
|
-
find('a', text: 'Add new page').
|
|
374
|
-
fill_in "Title", :
|
|
386
|
+
find('a', text: 'Add new page').click
|
|
387
|
+
fill_in "Title", with: "My first page"
|
|
375
388
|
window = window_opened_by do
|
|
376
389
|
click_button "Preview"
|
|
377
390
|
end
|
|
@@ -384,34 +397,36 @@ module Refinery
|
|
|
384
397
|
end
|
|
385
398
|
|
|
386
399
|
context 'a nested page' do
|
|
387
|
-
let!(:parent_page) { Page.create :
|
|
388
|
-
let!(:nested_page) { parent_page.children.create :
|
|
400
|
+
let!(:parent_page) { Page.create title: "Our Parent Page" }
|
|
401
|
+
let!(:nested_page) { parent_page.children.create title: 'Preview Me' }
|
|
389
402
|
|
|
390
|
-
it "works like an un-nested page" do
|
|
403
|
+
it "works like an un-nested page", js: true do
|
|
391
404
|
visit refinery.admin_pages_path
|
|
392
405
|
|
|
393
|
-
within "#page_#{nested_page.id}" do
|
|
394
|
-
|
|
406
|
+
within "#page_#{nested_page.id} .item" do
|
|
407
|
+
first(title_link_selector).click
|
|
395
408
|
end
|
|
396
409
|
|
|
397
410
|
fill_in "Title", with: preview_content
|
|
398
|
-
window = window_opened_by do
|
|
411
|
+
window = page.window_opened_by do
|
|
399
412
|
click_button "Preview"
|
|
400
413
|
end
|
|
401
414
|
|
|
402
|
-
expect_window_with_content(preview_content)
|
|
415
|
+
expect_window_with_content(preview_content, window: window)
|
|
403
416
|
end
|
|
404
417
|
end
|
|
405
418
|
end
|
|
406
419
|
|
|
407
420
|
describe "destroy" do
|
|
408
|
-
context "when page can be deleted", js:true do
|
|
409
|
-
before { Page.create :
|
|
421
|
+
context "when page can be deleted", js: true do
|
|
422
|
+
before { Page.create title: "Delete me" }
|
|
410
423
|
|
|
411
424
|
it "will show delete button" do
|
|
412
425
|
visit refinery.admin_pages_path
|
|
413
426
|
|
|
414
|
-
find('a[tooltip="Remove this page forever"]').
|
|
427
|
+
find('a[tooltip="Remove this page forever"]').click
|
|
428
|
+
|
|
429
|
+
page.accept_alert
|
|
415
430
|
|
|
416
431
|
expect(page).to have_content("'Delete me' was successfully removed.")
|
|
417
432
|
|
|
@@ -420,7 +435,7 @@ module Refinery
|
|
|
420
435
|
end
|
|
421
436
|
|
|
422
437
|
context "when page can't be deleted" do
|
|
423
|
-
before { Page.create :
|
|
438
|
+
before { Page.create title: "Indestructible", deletable: false }
|
|
424
439
|
|
|
425
440
|
it "wont show delete button" do
|
|
426
441
|
visit refinery.admin_pages_path
|
|
@@ -432,12 +447,12 @@ module Refinery
|
|
|
432
447
|
end
|
|
433
448
|
|
|
434
449
|
context "duplicate page titles" do
|
|
435
|
-
before { Page.create :
|
|
450
|
+
before { Page.create title: "I was here first" }
|
|
436
451
|
|
|
437
452
|
it "will append nr to url path" do
|
|
438
453
|
visit refinery.new_admin_page_path
|
|
439
454
|
|
|
440
|
-
fill_in "Title", :
|
|
455
|
+
fill_in "Title", with: "I was here first"
|
|
441
456
|
click_button "Save"
|
|
442
457
|
|
|
443
458
|
expect(Refinery::Page.last.url[:path].first).to match(%r{\Ai-was-here-first-.+?})
|
|
@@ -447,25 +462,27 @@ module Refinery
|
|
|
447
462
|
context "with translations" do
|
|
448
463
|
before do
|
|
449
464
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
|
|
465
|
+
end
|
|
450
466
|
|
|
467
|
+
before do
|
|
451
468
|
# Create a home page in both locales (needed to test menus)
|
|
452
|
-
home_page =
|
|
453
|
-
Page.create :
|
|
454
|
-
|
|
455
|
-
|
|
469
|
+
home_page = Mobility.with_locale(:en) do
|
|
470
|
+
Page.create title: 'Home',
|
|
471
|
+
link_url: '/',
|
|
472
|
+
menu_match: "^/$"
|
|
456
473
|
end
|
|
457
474
|
|
|
458
|
-
|
|
475
|
+
Mobility.with_locale(:ru) do
|
|
459
476
|
home_page.title = 'Домашняя страница'
|
|
460
477
|
home_page.save
|
|
461
478
|
end
|
|
462
479
|
end
|
|
463
480
|
|
|
464
|
-
describe "add a page with title for default locale", js:true do
|
|
481
|
+
describe "add a page with title for default locale", js: true do
|
|
465
482
|
before do
|
|
466
483
|
visit refinery.admin_pages_path
|
|
467
|
-
find('a', text: "Add new page").
|
|
468
|
-
fill_in "Title", :
|
|
484
|
+
find('a', text: "Add new page").click
|
|
485
|
+
fill_in "Title", with: "News"
|
|
469
486
|
click_button "Save"
|
|
470
487
|
end
|
|
471
488
|
|
|
@@ -474,24 +491,21 @@ module Refinery
|
|
|
474
491
|
expect(Refinery::Page.count).to eq(2)
|
|
475
492
|
end
|
|
476
493
|
|
|
477
|
-
it "
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
expect(page).
|
|
481
|
-
expect(page).to have_content('EN')
|
|
494
|
+
it "doesn't show locale for default frontend locale" do
|
|
495
|
+
within "#page_#{::Refinery::Page.by_slug('news').first.id}" do
|
|
496
|
+
expect(page).not_to have_selector(".locales")
|
|
497
|
+
expect(page).not_to have_selector(locale_link_selector(locale: 'en'))
|
|
482
498
|
end
|
|
483
499
|
end
|
|
484
500
|
|
|
485
501
|
it "shows title in the admin menu" do
|
|
486
|
-
|
|
487
|
-
within "#page_#{p.id}" do
|
|
502
|
+
within "#page_#{::Refinery::Page.by_slug('news').first.id}" do
|
|
488
503
|
expect(page).to have_content('News')
|
|
489
|
-
expect(page.
|
|
504
|
+
expect(page.first(title_link_selector)[:text]).to have_content('News')
|
|
490
505
|
end
|
|
491
506
|
end
|
|
492
507
|
|
|
493
508
|
it "shows in frontend menu for 'en' locale" do
|
|
494
|
-
# page.driver.debug
|
|
495
509
|
visit "/"
|
|
496
510
|
|
|
497
511
|
within "#menu" do
|
|
@@ -505,7 +519,7 @@ module Refinery
|
|
|
505
519
|
|
|
506
520
|
within "#menu" do
|
|
507
521
|
# we should only have the home page in the menu
|
|
508
|
-
expect(page).to have_css('li', :
|
|
522
|
+
expect(page).to have_css('li', count: 1)
|
|
509
523
|
end
|
|
510
524
|
end
|
|
511
525
|
end
|
|
@@ -516,17 +530,12 @@ module Refinery
|
|
|
516
530
|
let(:ru_page_title) { 'Новости' }
|
|
517
531
|
let(:ru_page_slug_encoded) { '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8' }
|
|
518
532
|
let!(:news_page) do
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
Globalize.with_locale(:ru) do
|
|
525
|
-
_page.title = ru_page_title
|
|
526
|
-
_page.save
|
|
533
|
+
Mobility.with_locale(:en) { Page.create(title: en_page_title) }.tap do |localised_page|
|
|
534
|
+
Mobility.with_locale(:ru) do
|
|
535
|
+
localised_page.title = ru_page_title
|
|
536
|
+
localised_page.save
|
|
537
|
+
end
|
|
527
538
|
end
|
|
528
|
-
|
|
529
|
-
_page
|
|
530
539
|
end
|
|
531
540
|
|
|
532
541
|
it "can have a title for each locale" do
|
|
@@ -536,7 +545,7 @@ module Refinery
|
|
|
536
545
|
click_link "Add new page"
|
|
537
546
|
switch_page_form_locale "RU"
|
|
538
547
|
|
|
539
|
-
fill_in "Title", :
|
|
548
|
+
fill_in "Title", with: ru_page_title
|
|
540
549
|
click_button "Save"
|
|
541
550
|
expect(page).to have_selector("#page_#{Page.last.id} .actions")
|
|
542
551
|
|
|
@@ -545,20 +554,23 @@ module Refinery
|
|
|
545
554
|
end
|
|
546
555
|
|
|
547
556
|
switch_page_form_locale "EN"
|
|
548
|
-
fill_in "Title", :
|
|
557
|
+
fill_in "Title", with: en_page_title
|
|
549
558
|
find("#submit_button").click
|
|
550
559
|
|
|
551
560
|
expect(page).to have_content("'#{en_page_title}' was successfully updated.")
|
|
552
561
|
expect(Refinery::Page.count).to eq(2)
|
|
553
562
|
end
|
|
554
563
|
|
|
555
|
-
it "is shown with
|
|
564
|
+
it "is shown with only the non-default locale in the index" do
|
|
556
565
|
visit refinery.admin_pages_path
|
|
557
566
|
|
|
558
|
-
within "#page_#{news_page.id}
|
|
559
|
-
expect(page).to
|
|
560
|
-
|
|
561
|
-
|
|
567
|
+
within "#page_#{news_page.id}" do
|
|
568
|
+
expect(page).to have_selector(".locales")
|
|
569
|
+
|
|
570
|
+
within ".locales" do
|
|
571
|
+
expect(page).to have_selector(locale_link_selector(locale: 'ru'))
|
|
572
|
+
expect(page).to have_no_selector(locale_link_selector(locale: 'en'))
|
|
573
|
+
end
|
|
562
574
|
end
|
|
563
575
|
end
|
|
564
576
|
|
|
@@ -574,7 +586,7 @@ module Refinery
|
|
|
574
586
|
visit refinery.admin_pages_path
|
|
575
587
|
|
|
576
588
|
within "#page_#{news_page.id}" do
|
|
577
|
-
expect(page.
|
|
589
|
+
expect(page.first(title_link_selector)[:href]).to match(en_page_slug)
|
|
578
590
|
end
|
|
579
591
|
end
|
|
580
592
|
|
|
@@ -595,10 +607,10 @@ module Refinery
|
|
|
595
607
|
end
|
|
596
608
|
end
|
|
597
609
|
|
|
598
|
-
describe "add a page with title only for secondary locale", js:true do
|
|
610
|
+
describe "add a page with title only for secondary locale", js: true do
|
|
599
611
|
let(:ru_page) {
|
|
600
|
-
|
|
601
|
-
Page.create :
|
|
612
|
+
Mobility.with_locale(:ru) {
|
|
613
|
+
Page.create title: ru_page_title
|
|
602
614
|
}
|
|
603
615
|
}
|
|
604
616
|
let(:ru_page_id) { ru_page.id }
|
|
@@ -612,10 +624,10 @@ module Refinery
|
|
|
612
624
|
|
|
613
625
|
it "lets you add a Russian title without an English title" do
|
|
614
626
|
ru_page.destroy!
|
|
615
|
-
find('a', text: 'Add new page').
|
|
627
|
+
find('a', text: 'Add new page').click
|
|
616
628
|
switch_page_form_locale "RU"
|
|
617
629
|
|
|
618
|
-
fill_in "Title", :
|
|
630
|
+
fill_in "Title", with: ru_page_title
|
|
619
631
|
click_button "Save"
|
|
620
632
|
|
|
621
633
|
expect(page).to have_content("'#{ru_page_title}' was successfully added.")
|
|
@@ -624,13 +636,13 @@ module Refinery
|
|
|
624
636
|
|
|
625
637
|
it "shows locale indicator for page" do
|
|
626
638
|
within "#page_#{ru_page_id}" do
|
|
627
|
-
expect(page).to have_selector(
|
|
639
|
+
expect(page).to have_selector(locale_link_selector(locale: 'ru'))
|
|
628
640
|
end
|
|
629
641
|
end
|
|
630
642
|
|
|
631
643
|
it "doesn't show locale indicator for primary locale" do
|
|
632
644
|
within "#page_#{ru_page_id}" do
|
|
633
|
-
expect(page).to_not have_selector('
|
|
645
|
+
expect(page).to_not have_selector(locale_picker('en'))
|
|
634
646
|
end
|
|
635
647
|
end
|
|
636
648
|
|
|
@@ -640,9 +652,9 @@ module Refinery
|
|
|
640
652
|
end
|
|
641
653
|
end
|
|
642
654
|
|
|
643
|
-
it "uses slug in admin" do
|
|
655
|
+
it "uses secondary locale slug in admin" do
|
|
644
656
|
within "#page_#{ru_page_id}" do
|
|
645
|
-
expect(page.find(
|
|
657
|
+
expect(page.find(title_link_selector)[:href]).to match(ru_page_slug_encoded)
|
|
646
658
|
end
|
|
647
659
|
end
|
|
648
660
|
|
|
@@ -660,23 +672,23 @@ module Refinery
|
|
|
660
672
|
|
|
661
673
|
within "#menu" do
|
|
662
674
|
# we should only have the home page in the menu
|
|
663
|
-
expect(page).to have_css('li', :
|
|
675
|
+
expect(page).to have_css('li', count: 1)
|
|
664
676
|
end
|
|
665
677
|
end
|
|
666
678
|
|
|
667
679
|
context "when page is a child page" do
|
|
668
680
|
it 'succeeds' do
|
|
669
681
|
ru_page.destroy!
|
|
670
|
-
parent_page = Page.create(:
|
|
671
|
-
sub_page =
|
|
672
|
-
Page.create :
|
|
682
|
+
parent_page = Page.create(title: "Parent page")
|
|
683
|
+
sub_page = Mobility.with_locale(:ru) {
|
|
684
|
+
Page.create title: ru_page_title, parent_id: parent_page.id
|
|
673
685
|
}
|
|
674
686
|
expect(sub_page.parent).to eq(parent_page)
|
|
675
687
|
visit refinery.admin_pages_path
|
|
676
688
|
within "#page_#{sub_page.id}" do
|
|
677
|
-
|
|
689
|
+
first(edit_selector).click
|
|
678
690
|
end
|
|
679
|
-
fill_in "Title", :
|
|
691
|
+
fill_in "Title", with: ru_page_title
|
|
680
692
|
click_button "Save"
|
|
681
693
|
expect(page).to have_content("'#{ru_page_title}' was successfully updated")
|
|
682
694
|
end
|
|
@@ -691,10 +703,10 @@ module Refinery
|
|
|
691
703
|
|
|
692
704
|
it "adds new page part", js: true do
|
|
693
705
|
visit refinery.new_admin_page_path
|
|
694
|
-
find("#add_page_part").
|
|
706
|
+
find("#add_page_part").click
|
|
695
707
|
|
|
696
708
|
within "#new_page_part_dialog" do
|
|
697
|
-
fill_in "new_page_part_title", :
|
|
709
|
+
fill_in "new_page_part_title", with: "testy"
|
|
698
710
|
click_button "Save"
|
|
699
711
|
end
|
|
700
712
|
|
|
@@ -705,12 +717,12 @@ module Refinery
|
|
|
705
717
|
end
|
|
706
718
|
|
|
707
719
|
describe "delete existing page part" do
|
|
708
|
-
let!(:some_page) { Page.create! :
|
|
720
|
+
let!(:some_page) { Page.create! title: "Some Page" }
|
|
709
721
|
|
|
710
722
|
before do
|
|
711
|
-
some_page.parts.create! :
|
|
712
|
-
some_page.parts.create! :
|
|
713
|
-
some_page.parts.create! :
|
|
723
|
+
some_page.parts.create! title: "First Part", slug: "first_part", position: 1
|
|
724
|
+
some_page.parts.create! title: "Second Part", slug: "second_part", position: 2
|
|
725
|
+
some_page.parts.create! title: "Third Part", slug: "third_part", position: 3
|
|
714
726
|
|
|
715
727
|
allow(Refinery::Pages).to receive(:new_page_parts).and_return(true)
|
|
716
728
|
end
|
|
@@ -725,7 +737,7 @@ module Refinery
|
|
|
725
737
|
end
|
|
726
738
|
|
|
727
739
|
2.times do
|
|
728
|
-
find("#delete_page_part").
|
|
740
|
+
find("#delete_page_part").click
|
|
729
741
|
# Poltergeist automatically accepts dialogues.
|
|
730
742
|
if Capybara.javascript_driver != :poltergeist
|
|
731
743
|
page.driver.browser.switch_to.alert.accept
|
|
@@ -757,16 +769,16 @@ module Refinery
|
|
|
757
769
|
allow(Refinery::Pages).to receive(:use_layout_templates).and_return(true)
|
|
758
770
|
allow(Refinery::Pages).to receive(:layout_template_whitelist).and_return(['abc', 'refinery'])
|
|
759
771
|
allow(Refinery::Pages).to receive(:valid_templates).and_return(['abc', 'refinery'])
|
|
760
|
-
parent_page = Page.create :
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
@page = parent_page.children.create :
|
|
772
|
+
parent_page = Page.create title: 'Parent Page',
|
|
773
|
+
view_template: 'refinery',
|
|
774
|
+
layout_template: 'refinery'
|
|
775
|
+
@page = parent_page.children.create title: 'Child Page'
|
|
764
776
|
end
|
|
765
777
|
|
|
766
778
|
specify 'sub page should inherit them', js: true do
|
|
767
779
|
visit refinery.edit_admin_page_path(@page.id)
|
|
768
780
|
|
|
769
|
-
find('#toggle_advanced_options').
|
|
781
|
+
find('#toggle_advanced_options').click
|
|
770
782
|
|
|
771
783
|
within '#page_layout_template' do
|
|
772
784
|
expect(page.find('option[value=refinery]')).to be_selected
|
|
@@ -783,7 +795,7 @@ module Refinery
|
|
|
783
795
|
# regression spec for https://github.com/refinery/refinerycms/issues/1891
|
|
784
796
|
describe "a page part with HTML" do
|
|
785
797
|
before do
|
|
786
|
-
page = Refinery::Page.create! :
|
|
798
|
+
page = Refinery::Page.create! title: "test"
|
|
787
799
|
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
|
788
800
|
page.parts.create(
|
|
789
801
|
title: default_page_part[:title],
|
|
@@ -794,37 +806,35 @@ module Refinery
|
|
|
794
806
|
end
|
|
795
807
|
end
|
|
796
808
|
|
|
797
|
-
specify "should retain the html", js:true do
|
|
809
|
+
specify "should retain the html", js: true do
|
|
798
810
|
visit refinery.admin_pages_path
|
|
799
|
-
|
|
800
|
-
Capybara.ignore_hidden_elements
|
|
801
|
-
|
|
802
|
-
|
|
811
|
+
first(edit_selector(slug: 'test')).click
|
|
812
|
+
Capybara.ignore_hidden_elements do
|
|
813
|
+
expect(page).to have_content("header class='regression'")
|
|
814
|
+
end
|
|
803
815
|
end
|
|
804
816
|
end
|
|
805
817
|
end
|
|
806
818
|
|
|
807
|
-
describe "TranslatePages", :
|
|
808
|
-
before {
|
|
819
|
+
describe "TranslatePages", type: :system do
|
|
820
|
+
before { Mobility.locale = :en }
|
|
809
821
|
refinery_login
|
|
810
822
|
|
|
811
823
|
describe "a page with a single locale" do
|
|
812
824
|
before do
|
|
813
825
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :lv])
|
|
814
|
-
Page.create :title => 'First Page'
|
|
815
826
|
end
|
|
827
|
+
let(:first_page) { Page.create title: 'First Page' }
|
|
816
828
|
|
|
817
829
|
it "can have a second locale added to it" do
|
|
818
|
-
visit refinery.
|
|
830
|
+
visit refinery.edit_admin_page_path(first_page.id)
|
|
819
831
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
fill_in "Title", :with => "Brīva vieta reklāmai"
|
|
832
|
+
switch_page_form_locale "lv"
|
|
833
|
+
fill_in "Title", with: "Brīva vieta reklāmai"
|
|
824
834
|
click_button "Save"
|
|
825
835
|
|
|
826
|
-
expect(page).to have_content("'Brīva vieta reklāmai' was successfully
|
|
827
|
-
expect(
|
|
836
|
+
expect(page).to have_content("'Brīva vieta reklāmai' was successfully updated.")
|
|
837
|
+
expect(first_page.translations.count).to eq(2)
|
|
828
838
|
end
|
|
829
839
|
end
|
|
830
840
|
|
|
@@ -833,11 +843,11 @@ module Refinery
|
|
|
833
843
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return [:en, :ru]
|
|
834
844
|
|
|
835
845
|
# Create a page in both locales
|
|
836
|
-
about_page =
|
|
837
|
-
Page.create :
|
|
846
|
+
about_page = Mobility.with_locale(:en) do
|
|
847
|
+
Page.create title: 'About'
|
|
838
848
|
end
|
|
839
849
|
|
|
840
|
-
|
|
850
|
+
Mobility.with_locale(:ru) do
|
|
841
851
|
about_page.title = 'About Ru'
|
|
842
852
|
about_page.save
|
|
843
853
|
end
|
|
@@ -847,7 +857,7 @@ module Refinery
|
|
|
847
857
|
page = Refinery::Page.last
|
|
848
858
|
# we need page parts so that there's a visual editor
|
|
849
859
|
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
|
850
|
-
page.parts.create(:
|
|
860
|
+
page.parts.create(title: default_page_part[:title], slug: default_page_part[:slug], body: nil, position: index)
|
|
851
861
|
end
|
|
852
862
|
page
|
|
853
863
|
end
|
|
@@ -857,14 +867,14 @@ module Refinery
|
|
|
857
867
|
before { Refinery::Pages.absolute_page_links = false }
|
|
858
868
|
|
|
859
869
|
it "shows Russian pages if we're editing the Russian locale" do
|
|
860
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
870
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true, switch_locale: :ru)
|
|
861
871
|
|
|
862
872
|
expect(page).to have_content("About Ru")
|
|
863
873
|
expect(page).to have_selector("a[href='/ru/about-ru']")
|
|
864
874
|
end
|
|
865
875
|
|
|
866
876
|
it "shows default to the default locale if no query string is added" do
|
|
867
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
877
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true)
|
|
868
878
|
|
|
869
879
|
expect(page).to have_content("About")
|
|
870
880
|
expect(page).to have_selector("a[href='/about']")
|
|
@@ -875,17 +885,16 @@ module Refinery
|
|
|
875
885
|
before { Refinery::Pages.absolute_page_links = true }
|
|
876
886
|
|
|
877
887
|
it "shows Russian pages if we're editing the Russian locale" do
|
|
878
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
879
|
-
|
|
888
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true, switch_locale: :ru)
|
|
880
889
|
expect(page).to have_content("About Ru")
|
|
881
|
-
expect(page).to have_selector("a[href
|
|
890
|
+
expect(page).to have_selector("a[href$='ru/about-ru']")
|
|
882
891
|
end
|
|
883
892
|
|
|
884
893
|
it "shows default to the default locale if no query string is added" do
|
|
885
|
-
visit refinery.link_to_admin_pages_dialogs_path(:
|
|
894
|
+
visit refinery.link_to_admin_pages_dialogs_path(visual_editor: true)
|
|
886
895
|
|
|
887
896
|
expect(page).to have_content("About")
|
|
888
|
-
expect(page).to have_selector("a[href
|
|
897
|
+
expect(page).to have_selector("a[href$='about']")
|
|
889
898
|
end
|
|
890
899
|
end
|
|
891
900
|
end
|