refinerycms-pages 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/refinery/admin/page_parts_controller.rb +6 -1
- data/app/controllers/refinery/admin/pages_controller.rb +53 -45
- data/app/controllers/refinery/pages/admin/preview_controller.rb +12 -3
- data/app/controllers/refinery/pages_controller.rb +12 -12
- data/app/helpers/refinery/admin/pages_helper.rb +5 -4
- data/app/helpers/refinery/pages/content_pages_helper.rb +6 -1
- data/app/models/refinery/page.rb +115 -141
- data/app/models/refinery/page_part.rb +32 -7
- data/app/presenters/refinery/pages/content_presenter.rb +7 -5
- data/app/presenters/refinery/pages/menu_presenter.rb +41 -15
- data/app/presenters/refinery/pages/page_part_section_presenter.rb +1 -7
- data/app/presenters/refinery/pages/section_presenter.rb +2 -6
- data/app/views/refinery/admin/pages/_actions.html.erb +4 -13
- data/app/views/refinery/admin/pages/_form.html.erb +7 -10
- data/app/views/refinery/admin/pages/_form_advanced_options.html.erb +5 -3
- data/app/views/refinery/admin/pages/_form_extra_fields_for_more_options.html.erb +1 -0
- data/app/views/refinery/admin/pages/_form_new_page_parts.html.erb +8 -0
- data/app/views/refinery/admin/pages/_form_page_parts.html.erb +10 -21
- data/app/views/refinery/admin/pages/_page.html.erb +31 -31
- data/app/views/refinery/admin/pages/_page_part_field.html.erb +2 -1
- data/app/views/refinery/admin/pages/_records.html.erb +3 -3
- data/app/views/refinery/admin/pages/_save_and_continue_callback.html.erb +1 -0
- data/app/views/refinery/admin/pages/index.html.erb +2 -4
- data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +1 -1
- data/config/locales/bg.yml +1 -2
- data/config/locales/ca.yml +85 -0
- data/config/locales/cs.yml +13 -3
- data/config/locales/da.yml +1 -2
- data/config/locales/de.yml +0 -1
- data/config/locales/el.yml +41 -29
- data/config/locales/en.yml +2 -2
- data/config/locales/es.yml +2 -4
- data/config/locales/fi.yml +1 -4
- data/config/locales/fr.yml +2 -2
- data/config/locales/hu.yml +1 -2
- data/config/locales/it.yml +15 -16
- data/config/locales/ja.yml +1 -3
- data/config/locales/ko.yml +1 -4
- data/config/locales/lt.yml +1 -3
- data/config/locales/lv.yml +0 -2
- data/config/locales/nb.yml +1 -4
- data/config/locales/nl.yml +1 -2
- data/config/locales/pl.yml +1 -13
- data/config/locales/pt-BR.yml +1 -3
- data/config/locales/pt.yml +1 -2
- data/config/locales/rs.yml +1 -3
- data/config/locales/ru.yml +8 -5
- data/config/locales/sk.yml +1 -2
- data/config/locales/sl.yml +1 -3
- data/config/locales/sv.yml +1 -3
- data/config/locales/tr.yml +1 -2
- data/config/locales/uk.yml +1 -5
- data/config/locales/vi.yml +1 -3
- data/config/locales/zh-CN.yml +1 -4
- data/config/locales/zh-TW.yml +1 -3
- data/config/routes.rb +16 -16
- data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +28 -11
- data/db/migrate/20140105190324_add_custom_slug_to_refinery_pages.rb +20 -0
- data/db/migrate/20150130044643_add_slug_to_refinery_page_parts.rb +6 -0
- data/db/migrate/20150720155305_update_slug_and_title_in_refinery_page_parts.rb +13 -0
- data/db/seeds.rb +42 -36
- data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +12 -0
- data/lib/refinery/pages.rb +4 -3
- data/lib/refinery/pages/admin/instance_methods.rb +3 -3
- data/lib/refinery/pages/configuration.rb +7 -1
- data/lib/refinery/pages/engine.rb +19 -18
- data/lib/refinery/pages/finder.rb +179 -0
- data/lib/refinery/pages/instance_methods.rb +3 -14
- data/lib/refinery/pages/tab.rb +2 -2
- data/lib/refinery/pages/types.rb +1 -1
- data/lib/refinery/pages/url.rb +15 -3
- data/license.md +1 -1
- data/refinerycms-pages.gemspec +8 -5
- data/spec/controllers/refinery/admin/pages_controller_spec.rb +53 -0
- data/spec/controllers/refinery/pages_controller_spec.rb +1 -1
- data/spec/factories/pages.rb +1 -1
- data/spec/features/refinery/admin/pages_spec.rb +274 -290
- data/spec/features/refinery/pages_spec.rb +123 -138
- data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +15 -11
- data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +11 -11
- data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +1 -1
- data/spec/lib/pages_spec.rb +2 -2
- data/spec/lib/refinery/pages/tab_spec.rb +9 -9
- data/spec/lib/refinery/pages/url_spec.rb +12 -12
- data/spec/models/refinery/page_finder_spec.rb +72 -0
- data/spec/models/refinery/page_menu_spec.rb +107 -0
- data/spec/models/refinery/page_meta_data_spec.rb +49 -0
- data/spec/models/refinery/page_part_spec.rb +67 -0
- data/spec/models/refinery/page_spec.rb +16 -534
- data/spec/models/refinery/page_url_spec.rb +320 -0
- data/spec/presenters/refinery/pages/content_page_presenter_spec.rb +9 -9
- data/spec/presenters/refinery/pages/content_presenter_spec.rb +20 -20
- data/spec/presenters/refinery/pages/menu_presenter_spec.rb +44 -6
- data/spec/presenters/refinery/pages/page_part_section_presenter_spec.rb +12 -12
- data/spec/presenters/refinery/pages/section_presenter_spec.rb +22 -22
- data/spec/presenters/refinery/pages/title_section_presenter_spec.rb +4 -4
- data/spec/support/refinery/pages/caching_helpers.rb +2 -2
- metadata +55 -25
- data/app/helpers/refinery/admin/page_parts_helper.rb +0 -6
- data/app/helpers/refinery/admin/pages_dialogs_helper.rb +0 -6
- data/app/sweepers/refinery/pages/page_sweeper.rb +0 -29
- data/lib/refinery/pages/caching.rb +0 -60
- data/spec/lib/refinery/pages/caching_spec.rb +0 -90
- data/spec/support/refinery/pages/caching.rb +0 -19
@@ -2,36 +2,37 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
module Refinery
|
5
|
-
describe 'page frontend' do
|
5
|
+
describe 'page frontend', :type => :feature do
|
6
6
|
let(:home_page) { Page.create :title => 'Home', :link_url => '/' }
|
7
7
|
let(:about_page) { Page.create :title => 'About' }
|
8
8
|
let(:draft_page) { Page.create :title => 'Draft', :draft => true }
|
9
9
|
before do
|
10
10
|
# Stub the menu pages we're expecting
|
11
|
-
|
11
|
+
::I18n.default_locale = Globalize.locale = :en
|
12
|
+
allow(Page).to receive(:fast_menu).and_return([home_page, about_page])
|
12
13
|
end
|
13
14
|
|
14
15
|
def standard_page_menu_items_exist?
|
15
16
|
within('.menu') do
|
16
|
-
page.
|
17
|
-
page.
|
18
|
-
page.
|
17
|
+
expect(page).to have_content(home_page.title)
|
18
|
+
expect(page).to have_content(about_page.title)
|
19
|
+
expect(page).not_to have_content(draft_page.title)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
23
|
describe 'when marketable urls are' do
|
23
24
|
describe 'enabled' do
|
24
|
-
before { Pages.
|
25
|
+
before { allow(Pages).to receive(:marketable_urls).and_return(true) }
|
25
26
|
|
26
27
|
it 'shows the homepage' do
|
27
|
-
PagesController.
|
28
|
+
allow_any_instance_of(PagesController).to receive(:find_page).and_return(:home_page)
|
28
29
|
visit '/'
|
29
30
|
|
30
31
|
standard_page_menu_items_exist?
|
31
32
|
end
|
32
33
|
|
33
34
|
it 'shows a show page' do
|
34
|
-
PagesController.
|
35
|
+
allow_any_instance_of(PagesController).to receive(:find_page).and_return(:about_page)
|
35
36
|
visit refinery.page_path(about_page)
|
36
37
|
|
37
38
|
standard_page_menu_items_exist?
|
@@ -39,21 +40,21 @@ module Refinery
|
|
39
40
|
end
|
40
41
|
|
41
42
|
describe 'disabled' do
|
42
|
-
before { Pages.
|
43
|
+
before { allow(Pages).to receive(:marketable_urls).and_return(false) }
|
43
44
|
|
44
45
|
it 'shows the homepage' do
|
45
|
-
PagesController.
|
46
|
+
allow_any_instance_of(PagesController).to receive(:find_page).and_return(:home_page)
|
46
47
|
visit '/'
|
47
48
|
|
48
49
|
standard_page_menu_items_exist?
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'does not route to /about for About page' do
|
52
|
-
refinery.page_path(about_page).
|
53
|
+
expect(refinery.page_path(about_page)).to match(%r{/pages/about$})
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'shows the about page' do
|
56
|
-
PagesController.
|
57
|
+
allow_any_instance_of(PagesController).to receive(:find_page).and_return(:about_page)
|
57
58
|
visit refinery.page_path(about_page)
|
58
59
|
|
59
60
|
standard_page_menu_items_exist?
|
@@ -65,17 +66,17 @@ module Refinery
|
|
65
66
|
before { visit '/about' }
|
66
67
|
|
67
68
|
it "shows title at the top of the page" do
|
68
|
-
find("#body_content_title").text.
|
69
|
+
expect(find("#body_content_title").text).to eq(about_page.title)
|
69
70
|
end
|
70
71
|
|
71
72
|
it "should hide title when config is set" do
|
72
|
-
Pages.
|
73
|
+
allow(Pages).to receive(:show_title_in_body).and_return(false)
|
73
74
|
visit '/about'
|
74
|
-
page.
|
75
|
+
expect(page).not_to have_selector("#body_content_title")
|
75
76
|
end
|
76
77
|
|
77
78
|
it "uses title in the menu" do
|
78
|
-
find(".selected").text.strip.
|
79
|
+
expect(find(".selected").text.strip).to eq(about_page.title)
|
79
80
|
end
|
80
81
|
|
81
82
|
it "uses title in browser title" do
|
@@ -87,7 +88,7 @@ module Refinery
|
|
87
88
|
let(:page_mt) { Page.create :title => 'Company News' }
|
88
89
|
|
89
90
|
before do
|
90
|
-
Page.
|
91
|
+
allow(Page).to receive(:fast_menu).and_return([page_mt])
|
91
92
|
end
|
92
93
|
|
93
94
|
describe 'set' do
|
@@ -97,16 +98,18 @@ module Refinery
|
|
97
98
|
end
|
98
99
|
|
99
100
|
it 'shows the menu_title in the menu' do
|
100
|
-
visit
|
101
|
+
visit refinery.url_for(page_mt.url)
|
101
102
|
|
102
|
-
|
103
|
+
within ".selected" do
|
104
|
+
expect(page).to have_content(page_mt.menu_title)
|
105
|
+
end
|
103
106
|
end
|
104
107
|
|
105
|
-
it "does not
|
106
|
-
visit
|
108
|
+
it "does not affect browser title and page title" do
|
109
|
+
visit refinery.url_for(page_mt.url)
|
107
110
|
|
108
|
-
page.
|
109
|
-
find("#body_content_title").text.
|
111
|
+
expect(page).to have_title(page_mt.title)
|
112
|
+
expect(find("#body_content_title").text).to eq(page_mt.title)
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
@@ -121,8 +124,8 @@ module Refinery
|
|
121
124
|
it 'the friendly_id and menu are reverted to match the title' do
|
122
125
|
visit '/company-news'
|
123
126
|
|
124
|
-
current_path.
|
125
|
-
find(".selected").text.strip.
|
127
|
+
expect(current_path).to eq('/company-news')
|
128
|
+
expect(find(".selected").text.strip).to eq(page_mt.title)
|
126
129
|
end
|
127
130
|
end
|
128
131
|
end
|
@@ -132,7 +135,7 @@ module Refinery
|
|
132
135
|
Page.create :title => 'About Us', :browser_title => 'About Our Company'
|
133
136
|
}
|
134
137
|
before do
|
135
|
-
Page.
|
138
|
+
allow(Page).to receive(:fast_menu).and_return([page_bt])
|
136
139
|
end
|
137
140
|
it 'should have the browser_title in the title tag' do
|
138
141
|
visit '/about-us'
|
@@ -143,22 +146,30 @@ module Refinery
|
|
143
146
|
it 'should not effect page title and menu title' do
|
144
147
|
visit '/about-us'
|
145
148
|
|
146
|
-
find("#body_content_title").text.
|
147
|
-
find(".selected").text.strip.
|
149
|
+
expect(find("#body_content_title").text).to eq(page_bt.title)
|
150
|
+
expect(find(".selected").text.strip).to eq(page_bt.title)
|
148
151
|
end
|
149
152
|
end
|
150
153
|
|
151
154
|
describe 'custom_slug' do
|
152
155
|
let(:page_cs) { Page.create :title => 'About Us' }
|
153
156
|
before do
|
154
|
-
Page.
|
157
|
+
allow(Page).to receive(:fast_menu).and_return([page_cs])
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'canonical url' do
|
161
|
+
it 'should have a canonical url' do
|
162
|
+
visit '/about-us'
|
163
|
+
|
164
|
+
expect(page).to have_selector('head link[rel="canonical"][href^="http://www.example.com/about-us"]', visible: false)
|
165
|
+
end
|
155
166
|
end
|
156
167
|
|
157
168
|
describe 'not set' do
|
158
169
|
it 'makes friendly_id from title' do
|
159
170
|
visit '/about-us'
|
160
171
|
|
161
|
-
current_path.
|
172
|
+
expect(current_path).to eq('/about-us')
|
162
173
|
end
|
163
174
|
end
|
164
175
|
|
@@ -171,7 +182,7 @@ module Refinery
|
|
171
182
|
it 'should make and use a new friendly_id' do
|
172
183
|
visit '/about-custom'
|
173
184
|
|
174
|
-
current_path.
|
185
|
+
expect(current_path).to eq('/about-custom')
|
175
186
|
end
|
176
187
|
end
|
177
188
|
|
@@ -187,42 +198,42 @@ module Refinery
|
|
187
198
|
|
188
199
|
describe 'set with slashes' do
|
189
200
|
before do
|
190
|
-
Pages.
|
201
|
+
allow(Pages).to receive(:scope_slug_by_parent).and_return(false)
|
191
202
|
page_cs.custom_slug = "products/my product/cool one!"
|
192
203
|
page_cs.save
|
193
204
|
end
|
194
205
|
|
195
206
|
after do
|
196
|
-
Pages.
|
207
|
+
allow(Pages).to receive(:scope_slug_by_parent).and_return(true)
|
197
208
|
end
|
198
209
|
|
199
210
|
it 'should make and use a new friendly_id' do
|
200
211
|
visit '/products/my-product/cool-one'
|
201
|
-
current_path.
|
212
|
+
expect(current_path).to eq('/products/my-product/cool-one')
|
202
213
|
end
|
203
214
|
end
|
204
215
|
end
|
205
216
|
|
206
|
-
# Following specs are converted from one of the cucumber features.
|
207
|
-
# Maybe we should clean up this spec file a bit...
|
208
217
|
describe "home page" do
|
209
218
|
it "succeeds" do
|
210
|
-
visit
|
219
|
+
visit refinery.root_path
|
211
220
|
|
212
221
|
within ".selected" do
|
213
|
-
page.
|
222
|
+
expect(page).to have_content(home_page.title)
|
223
|
+
expect(page).not_to have_content(about_page.title)
|
214
224
|
end
|
215
|
-
page.
|
225
|
+
expect(page).to have_content(about_page.title)
|
216
226
|
end
|
217
227
|
end
|
218
228
|
|
219
229
|
describe "content page" do
|
220
230
|
it "succeeds" do
|
221
|
-
visit
|
231
|
+
visit refinery.marketable_page_url(about_page.url)
|
222
232
|
|
223
|
-
page.
|
233
|
+
expect(page).to have_content(home_page.title)
|
224
234
|
within ".selected > a" do
|
225
|
-
page.
|
235
|
+
expect(page).not_to have_content(home_page.title)
|
236
|
+
expect(page).to have_content(about_page.title)
|
226
237
|
end
|
227
238
|
end
|
228
239
|
end
|
@@ -231,17 +242,17 @@ module Refinery
|
|
231
242
|
let(:submenu_page) { about_page.children.create :title => 'Sample Submenu' }
|
232
243
|
|
233
244
|
before do
|
234
|
-
Page.
|
245
|
+
allow(Page).to receive(:fast_menu).and_return(
|
235
246
|
[home_page, submenu_page, about_page.reload].sort_by(&:lft)
|
236
247
|
)
|
237
248
|
end
|
238
249
|
|
239
250
|
it "succeeds" do
|
240
251
|
visit refinery.url_for(submenu_page.url)
|
241
|
-
page.
|
242
|
-
page.
|
243
|
-
within ".
|
244
|
-
page.
|
252
|
+
expect(page).to have_content(home_page.title)
|
253
|
+
expect(page).to have_content(about_page.title)
|
254
|
+
within ".active * > .selected a" do
|
255
|
+
expect(page).to have_content(submenu_page.title)
|
245
256
|
end
|
246
257
|
end
|
247
258
|
end
|
@@ -249,7 +260,7 @@ module Refinery
|
|
249
260
|
describe "special characters title" do
|
250
261
|
let(:special_page) { Page.create :title => 'ä ö ü spéciål chåråctÉrs' }
|
251
262
|
before do
|
252
|
-
Page.
|
263
|
+
allow(Page).to receive(:fast_menu).and_return(
|
253
264
|
[home_page, about_page, special_page]
|
254
265
|
)
|
255
266
|
end
|
@@ -257,10 +268,10 @@ module Refinery
|
|
257
268
|
it "succeeds" do
|
258
269
|
visit refinery.url_for(special_page.url)
|
259
270
|
|
260
|
-
page.
|
261
|
-
page.
|
271
|
+
expect(page).to have_content(home_page.title)
|
272
|
+
expect(page).to have_content(about_page.title)
|
262
273
|
within ".selected > a" do
|
263
|
-
page.
|
274
|
+
expect(page).to have_content(special_page.title)
|
264
275
|
end
|
265
276
|
end
|
266
277
|
end
|
@@ -271,7 +282,7 @@ module Refinery
|
|
271
282
|
}
|
272
283
|
|
273
284
|
before do
|
274
|
-
Page.
|
285
|
+
allow(Page).to receive(:fast_menu).and_return(
|
275
286
|
[home_page, special_page, about_page.reload].sort_by &:lft
|
276
287
|
)
|
277
288
|
end
|
@@ -279,10 +290,10 @@ module Refinery
|
|
279
290
|
it "succeeds" do
|
280
291
|
visit refinery.url_for(special_page.url)
|
281
292
|
|
282
|
-
page.
|
283
|
-
page.
|
284
|
-
within ".
|
285
|
-
page.
|
293
|
+
expect(page).to have_content(home_page.title)
|
294
|
+
expect(page).to have_content(about_page.title)
|
295
|
+
within ".active * > .selected a" do
|
296
|
+
expect(page).to have_content(special_page.title)
|
286
297
|
end
|
287
298
|
end
|
288
299
|
end
|
@@ -291,17 +302,17 @@ module Refinery
|
|
291
302
|
let(:hidden_page) { Page.create :title => "Hidden", :show_in_menu => false }
|
292
303
|
|
293
304
|
before do
|
294
|
-
Page.
|
305
|
+
allow(Page).to receive(:fast_menu).and_return([home_page, about_page])
|
295
306
|
end
|
296
307
|
|
297
308
|
it "succeeds" do
|
298
309
|
visit refinery.page_path(hidden_page)
|
299
310
|
|
300
|
-
page.
|
301
|
-
page.
|
302
|
-
page.
|
311
|
+
expect(page).to have_content(home_page.title)
|
312
|
+
expect(page).to have_content(about_page.title)
|
313
|
+
expect(page).to have_content(hidden_page.title)
|
303
314
|
within "nav" do
|
304
|
-
page.
|
315
|
+
expect(page).to have_no_content(hidden_page.title)
|
305
316
|
end
|
306
317
|
end
|
307
318
|
end
|
@@ -309,113 +320,87 @@ module Refinery
|
|
309
320
|
describe "skip to first child" do
|
310
321
|
let!(:child_page) { about_page.children.create :title => "Child Page" }
|
311
322
|
before do
|
312
|
-
|
313
|
-
|
314
|
-
|
323
|
+
about = about_page.reload
|
324
|
+
about.skip_to_first_child = true
|
325
|
+
about.save!
|
315
326
|
|
316
|
-
|
327
|
+
allow(Page).to receive(:fast_menu).and_return([home_page, about, child_page].sort_by(&:lft))
|
317
328
|
end
|
318
329
|
|
319
330
|
it "succeeds" do
|
320
331
|
visit "/about"
|
321
332
|
|
322
|
-
within ".
|
323
|
-
page.
|
333
|
+
within ".active * > .selected a" do
|
334
|
+
expect(page).to have_content(child_page.title)
|
324
335
|
end
|
325
336
|
end
|
326
337
|
end
|
338
|
+
end
|
327
339
|
|
328
|
-
|
329
|
-
|
330
|
-
|
340
|
+
context "with multiple locales" do
|
341
|
+
|
342
|
+
describe "redirects" do
|
343
|
+
before { allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru]) }
|
344
|
+
after { allow(Refinery::I18n).to receive(:frontend_locales).and_call_original }
|
345
|
+
let(:en_page_title) { 'News' }
|
346
|
+
let(:en_page_slug) { 'news' }
|
347
|
+
let(:ru_page_title) { 'Новости' }
|
348
|
+
let(:ru_page_slug_encoded) { '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8' }
|
349
|
+
let!(:news_page) do
|
350
|
+
_page = Globalize.with_locale(:en) { Page.create title: en_page_title }
|
351
|
+
Globalize.with_locale(:ru) do
|
352
|
+
_page.title = ru_page_title
|
353
|
+
_page.save
|
354
|
+
end
|
331
355
|
|
332
|
-
|
333
|
-
|
334
|
-
cached_page.should_not be_cached
|
356
|
+
_page
|
357
|
+
end
|
335
358
|
|
336
|
-
|
359
|
+
it "should recognise when default locale is in the path" do
|
360
|
+
visit "/en/#{en_page_slug}"
|
337
361
|
|
338
|
-
|
339
|
-
end
|
362
|
+
expect(current_path).to eq("/en/#{en_page_slug}")
|
340
363
|
end
|
341
364
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
cached_page.should_not be_cached
|
347
|
-
end
|
365
|
+
it "should redirect to default locale slug" do
|
366
|
+
visit "/#{ru_page_slug_encoded}"
|
367
|
+
|
368
|
+
expect(current_path).to eq("/#{en_page_slug}")
|
348
369
|
end
|
349
|
-
end
|
350
370
|
|
351
|
-
|
371
|
+
it "should redirect to second locale slug" do
|
372
|
+
visit "/ru/#{en_page_slug}"
|
373
|
+
|
374
|
+
expect(current_path).to eq("/ru/#{ru_page_slug_encoded}")
|
352
375
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
let(:
|
358
|
-
let(:
|
359
|
-
|
360
|
-
let!(:
|
376
|
+
visit "/en/#{en_page_slug}"
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "nested page" do
|
380
|
+
let(:nested_page_title) { 'nested_page' }
|
381
|
+
let(:nested_page_slug) { 'nested_page' }
|
382
|
+
|
383
|
+
let!(:nested_page) do
|
384
|
+
Globalize.fallbacks = [:ru]
|
361
385
|
_page = Globalize.with_locale(:en) {
|
362
|
-
|
386
|
+
news_page.children.create :title => nested_page_title
|
363
387
|
}
|
388
|
+
|
364
389
|
Globalize.with_locale(:ru) do
|
365
|
-
_page.title =
|
390
|
+
_page.title = nested_page_title
|
366
391
|
_page.save
|
367
392
|
end
|
368
|
-
|
369
393
|
_page
|
370
394
|
end
|
371
395
|
|
372
|
-
it "should
|
373
|
-
visit "/
|
374
|
-
|
375
|
-
current_path.should == "/en/#{en_page_slug}"
|
376
|
-
end
|
377
|
-
|
378
|
-
it "should redirect to default locale slug" do
|
379
|
-
visit "/#{ru_page_slug_encoded}"
|
380
|
-
|
381
|
-
current_path.should == "/#{en_page_slug}"
|
382
|
-
end
|
383
|
-
|
384
|
-
it "should redirect to second locale slug" do
|
385
|
-
visit "/ru/#{en_page_slug}"
|
386
|
-
|
387
|
-
current_path.should == "/ru/#{ru_page_slug_encoded}"
|
388
|
-
|
389
|
-
visit "/en/#{en_page_slug}"
|
390
|
-
end
|
391
|
-
|
392
|
-
describe "nested page" do
|
393
|
-
let(:nested_page_title) { '2012' }
|
394
|
-
let(:nested_page_slug) { '2012' }
|
395
|
-
|
396
|
-
let!(:nested_page) do
|
397
|
-
_page = Globalize.with_locale(:en) {
|
398
|
-
news_page.children.create :title => nested_page_title
|
399
|
-
}
|
396
|
+
it "should redirect to localized url" do
|
397
|
+
visit "/ru/#{en_page_slug}/#{nested_page_slug}"
|
400
398
|
|
401
|
-
|
402
|
-
_page.title = nested_page_title
|
403
|
-
_page.save
|
404
|
-
end
|
405
|
-
|
406
|
-
_page
|
407
|
-
end
|
399
|
+
expect(current_path).to eq("/ru/#{ru_page_slug_encoded}/#{nested_page_slug}")
|
408
400
|
|
409
|
-
|
410
|
-
visit "/ru/#{en_page_slug}/#{nested_page_slug}"
|
411
|
-
|
412
|
-
current_path.should == "/ru/#{ru_page_slug_encoded}/#{nested_page_slug}"
|
413
|
-
|
414
|
-
visit "/en/#{en_page_slug}/#{nested_page_slug}"
|
415
|
-
end
|
401
|
+
visit "/en/#{en_page_slug}/#{nested_page_slug}"
|
416
402
|
end
|
417
403
|
end
|
418
404
|
end
|
419
|
-
|
420
405
|
end
|
421
406
|
end
|