refinerycms-pages 2.0.10 → 2.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/pages_controller.rb +23 -17
- data/app/controllers/refinery/admin/pages_dialogs_controller.rb +8 -45
- data/app/controllers/refinery/pages/admin/preview_controller.rb +38 -0
- data/app/controllers/refinery/pages_controller.rb +26 -43
- data/app/helpers/refinery/admin/pages_helper.rb +19 -14
- data/app/models/refinery/page.rb +133 -194
- data/app/models/refinery/page_part.rb +1 -1
- data/{lib → app/presenters}/refinery/pages/content_page_presenter.rb +1 -5
- data/{lib → app/presenters}/refinery/pages/content_presenter.rb +1 -15
- data/app/presenters/refinery/pages/menu_presenter.rb +118 -0
- data/{lib → app/presenters}/refinery/pages/page_part_section_presenter.rb +0 -0
- data/{lib → app/presenters}/refinery/pages/section_presenter.rb +0 -0
- data/{lib → app/presenters}/refinery/pages/title_section_presenter.rb +0 -0
- data/app/sweepers/refinery/pages/page_sweeper.rb +29 -0
- data/app/views/refinery/admin/pages/_form.html.erb +4 -4
- data/app/views/refinery/admin/pages/_form_advanced_options.html.erb +3 -18
- data/app/views/refinery/admin/pages/_form_page_parts.html.erb +2 -2
- data/app/views/refinery/admin/pages/_page.html.erb +5 -5
- data/app/views/refinery/admin/pages/_records.html.erb +1 -3
- data/app/views/refinery/admin/pages/_sortable_list.html.erb +1 -1
- data/app/views/refinery/admin/pages/index.html.erb +1 -1
- data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +0 -2
- data/config/locales/bg.yml +0 -11
- data/config/locales/cs.yml +1 -3
- data/config/locales/da.yml +15 -5
- data/config/locales/de.yml +16 -5
- data/config/locales/el.yml +0 -3
- data/config/locales/en.yml +1 -12
- data/config/locales/es.yml +0 -3
- data/config/locales/fi.yml +0 -3
- data/config/locales/fr.yml +0 -11
- data/config/locales/hu.yml +85 -0
- data/config/locales/it.yml +0 -10
- data/config/locales/ja.yml +0 -3
- data/config/locales/ko.yml +0 -11
- data/config/locales/lt.yml +0 -3
- data/config/locales/lv.yml +0 -3
- data/config/locales/nb.yml +0 -3
- data/config/locales/nl.yml +51 -40
- data/config/locales/pl.yml +23 -4
- data/config/locales/pt-BR.yml +0 -3
- data/config/locales/pt.yml +85 -0
- data/config/locales/rs.yml +0 -3
- data/config/locales/ru.yml +0 -3
- data/config/locales/sk.yml +0 -11
- data/config/locales/sl.yml +0 -3
- data/config/locales/sv.yml +0 -3
- data/config/locales/tr.yml +85 -0
- data/config/locales/uk.yml +82 -0
- data/config/locales/vi.yml +0 -3
- data/config/locales/zh-CN.yml +8 -11
- data/config/locales/zh-TW.yml +0 -3
- data/config/routes.rb +11 -5
- data/db/seeds.rb +16 -14
- data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +8 -4
- data/lib/refinery/pages.rb +5 -9
- data/lib/refinery/pages/caching.rb +60 -0
- data/lib/refinery/pages/configuration.rb +11 -7
- data/lib/refinery/pages/engine.rb +7 -8
- data/lib/refinery/pages/instance_methods.rb +4 -11
- data/lib/refinery/pages/render_options.rb +27 -0
- data/lib/refinery/pages/tab.rb +15 -4
- data/lib/refinery/pages/url.rb +74 -0
- data/refinerycms-pages.gemspec +4 -3
- data/spec/controllers/refinery/pages_controller_spec.rb +24 -0
- data/spec/factories/pages.rb +1 -1
- data/spec/{requests → features}/refinery/admin/pages_spec.rb +125 -42
- data/spec/{requests → features}/refinery/pages_spec.rb +139 -23
- data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +25 -25
- data/spec/lib/refinery/pages/caching_spec.rb +90 -0
- data/spec/lib/refinery/pages/tab_spec.rb +89 -0
- data/spec/lib/refinery/pages/url_spec.rb +74 -0
- data/spec/models/refinery/page_spec.rb +196 -71
- data/spec/{lib → presenters/refinery}/pages/content_page_presenter_spec.rb +0 -0
- data/spec/{lib → presenters/refinery}/pages/content_presenter_spec.rb +0 -0
- data/spec/presenters/refinery/pages/menu_presenter_spec.rb +58 -0
- data/spec/{lib → presenters/refinery}/pages/page_part_section_presenter_spec.rb +0 -0
- data/spec/{lib → presenters/refinery}/pages/section_presenter_spec.rb +0 -0
- data/spec/{lib → presenters/refinery}/pages/title_section_presenter_spec.rb +0 -0
- data/spec/support/refinery/pages/caching.rb +19 -0
- data/spec/support/refinery/pages/caching_helpers.rb +22 -0
- metadata +77 -33
- data/app/controllers/refinery/page_sweeper.rb +0 -34
- data/app/helpers/refinery/pages_helper.rb +0 -20
- data/app/views/refinery/admin/pages/_locale_picker.html.erb +0 -11
- data/config/locales/pt-PT.yml +0 -75
- data/spec/controllers/refinery/admin/pages_controller_spec.rb +0 -17
- data/spec/helpers/refinery/pages/pages_helper_spec.rb +0 -30
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Pages
|
5
|
+
|
6
|
+
describe ".tabs" do
|
7
|
+
after do
|
8
|
+
Refinery::Pages.instance_eval { @tabs = [] }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns an array of registered tabs" do
|
12
|
+
rspec_tab = Refinery::Pages::Tab.register do |tab|
|
13
|
+
tab.name = "rspec"
|
14
|
+
tab.partial = "rspec"
|
15
|
+
end
|
16
|
+
|
17
|
+
Refinery::Pages.tabs.should include(rspec_tab)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".tabs_for_template" do
|
22
|
+
after do
|
23
|
+
Refinery::Pages.instance_eval { @tabs = [] }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns all tabs for which #templates hasn't been set" do
|
27
|
+
rspec_tab = Refinery::Pages::Tab.register do |tab|
|
28
|
+
tab.name = "rspec"
|
29
|
+
tab.partial = "rspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
Refinery::Pages.tabs_for_template("huh").should include(rspec_tab)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns tabs with matched template" do
|
36
|
+
rspec_tab = Refinery::Pages::Tab.register do |tab|
|
37
|
+
tab.name = "rspec"
|
38
|
+
tab.partial = "rspec"
|
39
|
+
tab.templates = "rspec"
|
40
|
+
end
|
41
|
+
|
42
|
+
Refinery::Pages.tabs_for_template("rspec").should include(rspec_tab)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe Tab do
|
47
|
+
after do
|
48
|
+
Refinery::Pages.instance_eval { @tabs = [] }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".register" do
|
52
|
+
it "requires name to be set" do
|
53
|
+
lambda {
|
54
|
+
Refinery::Pages::Tab.register do |tab|
|
55
|
+
tab.partial = "rspec"
|
56
|
+
end
|
57
|
+
}.should raise_error
|
58
|
+
end
|
59
|
+
|
60
|
+
it "requires partial to be set" do
|
61
|
+
lambda {
|
62
|
+
Refinery::Pages::Tab.register do |tab|
|
63
|
+
tab.name = "rspec"
|
64
|
+
end
|
65
|
+
}.should raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "sets #templates if it's not set" do
|
69
|
+
rspec_tab = Refinery::Pages::Tab.register do |tab|
|
70
|
+
tab.name = "rspec"
|
71
|
+
tab.partial = "rspec"
|
72
|
+
end
|
73
|
+
|
74
|
+
rspec_tab.templates.should eq(["all"])
|
75
|
+
end
|
76
|
+
|
77
|
+
it "converts #templates to array if it's not an array already" do
|
78
|
+
rspec_tab = Refinery::Pages::Tab.register do |tab|
|
79
|
+
tab.name = "rspec"
|
80
|
+
tab.partial = "rspec"
|
81
|
+
tab.templates = "rspec"
|
82
|
+
end
|
83
|
+
|
84
|
+
rspec_tab.templates.should eq(["rspec"])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'refinery/pages/url'
|
3
|
+
|
4
|
+
module Refinery
|
5
|
+
module Pages
|
6
|
+
describe Url::Localised do
|
7
|
+
describe ".handle?" do
|
8
|
+
it "returns true if link_url is present" do
|
9
|
+
page = double(:page, :link_url => "/")
|
10
|
+
Url::Localised.handle?(page).should be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#url" do
|
15
|
+
let(:page) { double(:page, :link_url => "/test") }
|
16
|
+
|
17
|
+
context "when current frontend locale != default frontend locale" do
|
18
|
+
it "returns link_url prefixed with current frontend locale" do
|
19
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(:lv)
|
20
|
+
Refinery::I18n.stub(:default_frontend_locale).and_return(:en)
|
21
|
+
Url::Localised.new(page).url.should eq("/lv/test")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when current frontend locale == default frontend locale" do
|
26
|
+
it "returns unaltered link_url" do
|
27
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(:en)
|
28
|
+
Refinery::I18n.stub(:default_frontend_locale).and_return(:en)
|
29
|
+
Url::Localised.new(page).url.should eq("/test")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Url::Marketable do
|
36
|
+
describe ".handle?" do
|
37
|
+
it "returns true if marketable_url config is set to true" do
|
38
|
+
page = double(:page)
|
39
|
+
Refinery::Pages.stub(:marketable_url).and_return(true)
|
40
|
+
Url::Marketable.handle?(page).should be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#url" do
|
45
|
+
it "returns hash" do
|
46
|
+
page = double(:page, :nested_url => "test")
|
47
|
+
Url::Marketable.new(page).url.should eq({
|
48
|
+
:controller => "/refinery/pages", :action => "show", :only_path => true,
|
49
|
+
:path => "test", :id => nil
|
50
|
+
})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe Url::Normal do
|
56
|
+
describe ".handle?" do
|
57
|
+
it "returns true if to_param is present" do
|
58
|
+
page = double(:page, :to_param => "test")
|
59
|
+
Url::Normal.handle?(page).should be_true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#url" do
|
64
|
+
it "returns hash" do
|
65
|
+
page = double(:page, :to_param => "test")
|
66
|
+
Url::Normal.new(page).url.should eq({
|
67
|
+
:controller => "/refinery/pages", :action => "show", :only_path => true,
|
68
|
+
:path => nil, :id => "test"
|
69
|
+
})
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
module Refinery
|
5
5
|
describe Page do
|
6
|
-
|
7
6
|
let(:page_title) { 'RSpec is great for testing too' }
|
8
7
|
let(:child_title) { 'The child page' }
|
9
8
|
|
@@ -16,15 +15,24 @@ module Refinery
|
|
16
15
|
let(:created_child) { created_page.children.create!(:title => child_title) }
|
17
16
|
|
18
17
|
def page_cannot_be_destroyed
|
18
|
+
page.should_receive(:puts_destroy_help)
|
19
19
|
page.destroy.should == false
|
20
20
|
end
|
21
21
|
|
22
22
|
def turn_off_marketable_urls
|
23
|
-
|
23
|
+
Pages.stub(:marketable_urls).and_return(false)
|
24
24
|
end
|
25
25
|
|
26
26
|
def turn_on_marketable_urls
|
27
|
-
|
27
|
+
Pages.stub(:marketable_urls).and_return(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def turn_off_slug_scoping
|
31
|
+
Pages.stub(:scope_slug_by_parent).and_return(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
def turn_on_slug_scoping
|
35
|
+
Pages.stub(:scope_slug_by_parent).and_return(true)
|
28
36
|
end
|
29
37
|
|
30
38
|
context 'cannot be deleted under certain rules' do
|
@@ -106,9 +114,9 @@ module Refinery
|
|
106
114
|
|
107
115
|
context 'canonicals' do
|
108
116
|
before do
|
109
|
-
|
110
|
-
|
111
|
-
|
117
|
+
Refinery::I18n.stub(:default_frontend_locale).and_return(:en)
|
118
|
+
Refinery::I18n.stub(:frontend_locales).and_return([I18n.default_frontend_locale, :ru])
|
119
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(I18n.default_frontend_locale)
|
112
120
|
|
113
121
|
page.save
|
114
122
|
end
|
@@ -118,7 +126,7 @@ module Refinery
|
|
118
126
|
|
119
127
|
describe '#canonical' do
|
120
128
|
let!(:default_canonical) {
|
121
|
-
Globalize.with_locale(
|
129
|
+
Globalize.with_locale(Refinery::I18n.default_frontend_locale) {
|
122
130
|
page.canonical
|
123
131
|
}
|
124
132
|
}
|
@@ -143,7 +151,7 @@ module Refinery
|
|
143
151
|
|
144
152
|
describe '#canonical_slug' do
|
145
153
|
let!(:default_canonical_slug) {
|
146
|
-
Globalize.with_locale(
|
154
|
+
Globalize.with_locale(Refinery::I18n.default_frontend_locale) {
|
147
155
|
page.canonical_slug
|
148
156
|
}
|
149
157
|
}
|
@@ -169,16 +177,20 @@ module Refinery
|
|
169
177
|
context 'custom slugs' do
|
170
178
|
let(:custom_page_slug) { 'custom-page-slug' }
|
171
179
|
let(:custom_child_slug) { 'custom-child-slug' }
|
180
|
+
let(:custom_route) { '/products/my-product' }
|
172
181
|
let(:page_with_custom_slug) {
|
173
182
|
subject.class.new(:title => page_title, :custom_slug => custom_page_slug)
|
174
183
|
}
|
175
184
|
let(:child_with_custom_slug) {
|
176
185
|
page.children.new(:title => child_title, :custom_slug => custom_child_slug)
|
177
186
|
}
|
187
|
+
let(:page_with_custom_route) {
|
188
|
+
subject.class.new(:title => page_title, :custom_slug => custom_route)
|
189
|
+
}
|
178
190
|
|
179
191
|
after(:each) do
|
180
|
-
|
181
|
-
|
192
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(I18n.default_frontend_locale)
|
193
|
+
Refinery::I18n.stub(:current_locale).and_return(I18n.default_locale)
|
182
194
|
end
|
183
195
|
|
184
196
|
it 'returns its path with custom slug' do
|
@@ -187,6 +199,23 @@ module Refinery
|
|
187
199
|
page_with_custom_slug.url[:path].should == [custom_page_slug]
|
188
200
|
end
|
189
201
|
|
202
|
+
it 'allows a custom route when slug scoping is off' do
|
203
|
+
turn_off_slug_scoping
|
204
|
+
page_with_custom_route.save
|
205
|
+
page_with_custom_route.url[:id].should be_nil
|
206
|
+
page_with_custom_route.url[:path].should == [custom_route]
|
207
|
+
turn_on_slug_scoping
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'allows slashes in custom routes but slugs everything in between' do
|
211
|
+
turn_off_slug_scoping
|
212
|
+
page_needing_a_slugging = subject.class.new(:title => page_title, :custom_slug => 'products/category/sub category/my product is cool!')
|
213
|
+
page_needing_a_slugging.save
|
214
|
+
page_needing_a_slugging.url[:id].should be_nil
|
215
|
+
page_needing_a_slugging.url[:path].should == ['products/category/sub-category/my-product-is-cool']
|
216
|
+
turn_on_slug_scoping
|
217
|
+
end
|
218
|
+
|
190
219
|
it 'returns its path underneath its parent with custom urls' do
|
191
220
|
child_with_custom_slug.save
|
192
221
|
page.save
|
@@ -195,9 +224,41 @@ module Refinery
|
|
195
224
|
child_with_custom_slug.url[:path].should == [page.url[:path].first, custom_child_slug]
|
196
225
|
end
|
197
226
|
|
227
|
+
it 'does not return a path underneath its parent when scoping is off' do
|
228
|
+
turn_off_slug_scoping
|
229
|
+
child_with_custom_slug.save
|
230
|
+
page.save
|
231
|
+
|
232
|
+
child_with_custom_slug.url[:id].should be_nil
|
233
|
+
child_with_custom_slug.url[:path].should == [custom_child_slug]
|
234
|
+
turn_on_slug_scoping
|
235
|
+
end
|
236
|
+
|
237
|
+
it "doesn't allow slashes in slug" do
|
238
|
+
page_with_slashes_in_slug = subject.class.new(:title => page_title, :custom_slug => '/products/category')
|
239
|
+
page_with_slashes_in_slug.save
|
240
|
+
page_with_slashes_in_slug.url[:path].should == ['productscategory']
|
241
|
+
end
|
242
|
+
|
243
|
+
it "allow slashes in slug when slug scoping is off" do
|
244
|
+
turn_off_slug_scoping
|
245
|
+
page_with_slashes_in_slug = subject.class.new(:title => page_title, :custom_slug => 'products/category/subcategory')
|
246
|
+
page_with_slashes_in_slug.save
|
247
|
+
page_with_slashes_in_slug.url[:path].should == ['products/category/subcategory']
|
248
|
+
turn_on_slug_scoping
|
249
|
+
end
|
250
|
+
|
251
|
+
it "strips leading and trailing slashes in slug when slug scoping is off" do
|
252
|
+
turn_off_slug_scoping
|
253
|
+
page_with_slashes_in_slug = subject.class.new(:title => page_title, :custom_slug => '/products/category/subcategory/')
|
254
|
+
page_with_slashes_in_slug.save
|
255
|
+
page_with_slashes_in_slug.url[:path].should == ['products/category/subcategory']
|
256
|
+
turn_on_slug_scoping
|
257
|
+
end
|
258
|
+
|
198
259
|
it 'returns its path with custom slug when using different locale' do
|
199
|
-
|
200
|
-
|
260
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(:ru)
|
261
|
+
Refinery::I18n.stub(:current_locale).and_return(:ru)
|
201
262
|
page_with_custom_slug.custom_slug = "#{custom_page_slug}-ru"
|
202
263
|
page_with_custom_slug.save
|
203
264
|
page_with_custom_slug.reload
|
@@ -207,8 +268,8 @@ module Refinery
|
|
207
268
|
end
|
208
269
|
|
209
270
|
it 'returns path underneath its parent with custom urls when using different locale' do
|
210
|
-
|
211
|
-
|
271
|
+
Refinery::I18n.stub(:current_frontend_locale).and_return(:ru)
|
272
|
+
Refinery::I18n.stub(:current_locale).and_return(:ru)
|
212
273
|
child_with_custom_slug.custom_slug = "#{custom_child_slug}-ru"
|
213
274
|
child_with_custom_slug.save
|
214
275
|
child_with_custom_slug.reload
|
@@ -217,16 +278,17 @@ module Refinery
|
|
217
278
|
child_with_custom_slug.url[:path].should == [page.url[:path].first, "#{custom_child_slug}-ru"]
|
218
279
|
end
|
219
280
|
|
220
|
-
|
281
|
+
context "given a page with a custom_slug exists" do
|
282
|
+
before do
|
283
|
+
FactoryGirl.create(:page, :custom_slug => custom_page_slug)
|
284
|
+
end
|
221
285
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
page.home?.should == true
|
226
|
-
end
|
286
|
+
it "fails validation when a new record uses that custom_slug" do
|
287
|
+
new_page = Page.new :custom_slug => custom_page_slug
|
288
|
+
new_page.valid?
|
227
289
|
|
228
|
-
|
229
|
-
|
290
|
+
new_page.errors[:custom_slug].should_not be_empty
|
291
|
+
end
|
230
292
|
end
|
231
293
|
end
|
232
294
|
|
@@ -241,8 +303,37 @@ module Refinery
|
|
241
303
|
page.content_for('BoDY').should == "<p>I'm the first page part for this page.</p>"
|
242
304
|
end
|
243
305
|
|
244
|
-
it '
|
245
|
-
page.
|
306
|
+
it 'requires a unique title' do
|
307
|
+
page.save
|
308
|
+
page.parts.create(:title => 'body')
|
309
|
+
duplicate_title_part = page.parts.create(:title => 'body')
|
310
|
+
|
311
|
+
duplicate_title_part.errors[:title].should be_present
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'only requires a unique title on the same page' do
|
315
|
+
part_one = Page.create(:title => 'first page').parts.create(:title => 'body')
|
316
|
+
part_two = Page.create(:title => 'second page').parts.create(:title => 'body')
|
317
|
+
|
318
|
+
part_two.errors[:title].should be_empty
|
319
|
+
end
|
320
|
+
|
321
|
+
context 'when using content_for?' do
|
322
|
+
|
323
|
+
it 'return true when page part has content' do
|
324
|
+
page.content_for?(:body).should be_true
|
325
|
+
end
|
326
|
+
|
327
|
+
it 'return false when page part does not exist' do
|
328
|
+
page.parts = []
|
329
|
+
page.content_for?(:body).should be_false
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'return false when page part does not have any content' do
|
333
|
+
page.parts.first.content = ''
|
334
|
+
page.content_for?(:body).should be_false
|
335
|
+
end
|
336
|
+
|
246
337
|
end
|
247
338
|
|
248
339
|
it 'reposition correctly' do
|
@@ -295,10 +386,6 @@ module Refinery
|
|
295
386
|
|
296
387
|
context 'meta data' do
|
297
388
|
context 'responds to' do
|
298
|
-
it 'meta_keywords' do
|
299
|
-
page.respond_to?(:meta_keywords)
|
300
|
-
end
|
301
|
-
|
302
389
|
it 'meta_description' do
|
303
390
|
page.respond_to?(:meta_description)
|
304
391
|
end
|
@@ -309,11 +396,6 @@ module Refinery
|
|
309
396
|
end
|
310
397
|
|
311
398
|
context 'allows us to assign to' do
|
312
|
-
it 'meta_keywords' do
|
313
|
-
page.meta_keywords = 'Some, great, keywords'
|
314
|
-
page.meta_keywords.should == 'Some, great, keywords'
|
315
|
-
end
|
316
|
-
|
317
399
|
it 'meta_description' do
|
318
400
|
page.meta_description = 'This is my description of the page for search results.'
|
319
401
|
page.meta_description.should == 'This is my description of the page for search results.'
|
@@ -326,14 +408,6 @@ module Refinery
|
|
326
408
|
end
|
327
409
|
|
328
410
|
context 'allows us to update' do
|
329
|
-
it 'meta_keywords' do
|
330
|
-
page.meta_keywords = 'Some, great, keywords'
|
331
|
-
page.save
|
332
|
-
|
333
|
-
page.reload
|
334
|
-
page.meta_keywords.should == 'Some, great, keywords'
|
335
|
-
end
|
336
|
-
|
337
411
|
it 'meta_description' do
|
338
412
|
page.meta_description = 'This is my description of the page for search results.'
|
339
413
|
page.save
|
@@ -355,12 +429,12 @@ module Refinery
|
|
355
429
|
|
356
430
|
describe "#to_refinery_menu_item" do
|
357
431
|
let(:page) do
|
358
|
-
|
432
|
+
Page.new(
|
359
433
|
:id => 5,
|
360
434
|
:parent_id => 8,
|
361
435
|
:menu_match => "^/foo$"
|
362
436
|
|
363
|
-
#
|
437
|
+
# Page does not allow setting lft and rgt, so stub them.
|
364
438
|
).tap do |p|
|
365
439
|
p[:lft] = 6
|
366
440
|
p[:rgt] = 7
|
@@ -387,30 +461,6 @@ module Refinery
|
|
387
461
|
end
|
388
462
|
end
|
389
463
|
|
390
|
-
context "with #page_menu_title" do
|
391
|
-
before do
|
392
|
-
page.page_menu_title = "Page Menu Title"
|
393
|
-
end
|
394
|
-
|
395
|
-
it_should_behave_like "Refinery menu item hash"
|
396
|
-
|
397
|
-
it "returns the page_menu_title for :title" do
|
398
|
-
subject[:title].should eq("Page Menu Title")
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
context "with #page_title" do
|
403
|
-
before do
|
404
|
-
page.page_title = "Page Title"
|
405
|
-
end
|
406
|
-
|
407
|
-
it_should_behave_like "Refinery menu item hash"
|
408
|
-
|
409
|
-
it "returns the page_title for :title" do
|
410
|
-
subject[:title].should eq("Page Title")
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
464
|
context "with #menu_title" do
|
415
465
|
before do
|
416
466
|
page[:menu_title] = "Menu Title"
|
@@ -436,7 +486,7 @@ module Refinery
|
|
436
486
|
end
|
437
487
|
end
|
438
488
|
|
439
|
-
describe "
|
489
|
+
describe "#in_menu?" do
|
440
490
|
context "when live? and show_in_menu? returns true" do
|
441
491
|
it "returns true" do
|
442
492
|
page.stub(:live?).and_return(true)
|
@@ -458,7 +508,7 @@ module Refinery
|
|
458
508
|
end
|
459
509
|
end
|
460
510
|
|
461
|
-
describe "
|
511
|
+
describe "#not_in_menu?" do
|
462
512
|
context "when in_menu? returns true" do
|
463
513
|
it "returns false" do
|
464
514
|
page.stub(:in_menu?).and_return(true)
|
@@ -486,11 +536,86 @@ module Refinery
|
|
486
536
|
end
|
487
537
|
|
488
538
|
it "should return (root) about page when looking for '/about'" do
|
489
|
-
|
539
|
+
Page.find_by_path('/about').should == created_root_about
|
490
540
|
end
|
491
541
|
|
492
542
|
it "should return child about page when looking for '/team/about'" do
|
493
|
-
|
543
|
+
Page.find_by_path('/team/about').should == created_child
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
describe ".find_by_path_or_id" do
|
548
|
+
let!(:market) { FactoryGirl.create(:page, :title => "market") }
|
549
|
+
let(:path) { "market" }
|
550
|
+
let(:id) { market.id }
|
551
|
+
|
552
|
+
context "when path param is present" do
|
553
|
+
context "when path is friendly_id" do
|
554
|
+
it "finds page using path" do
|
555
|
+
Page.find_by_path_or_id(path, "").should eq(market)
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
context "when path is not friendly_id" do
|
560
|
+
it "finds page using id" do
|
561
|
+
Page.find_by_path_or_id(id, "").should eq(market)
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
context "when id param is present" do
|
567
|
+
it "finds page using id" do
|
568
|
+
Page.find_by_path_or_id("", id).should eq(market)
|
569
|
+
end
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
describe "#deletable?" do
|
574
|
+
let(:deletable_page) do
|
575
|
+
page.deletable = true
|
576
|
+
page.link_url = ""
|
577
|
+
page.menu_match = ""
|
578
|
+
page.stub(:puts_destroy_help).and_return('')
|
579
|
+
page
|
580
|
+
end
|
581
|
+
|
582
|
+
context "when deletable is true and link_url, and menu_match is blank" do
|
583
|
+
it "returns true" do
|
584
|
+
deletable_page.deletable?.should be_true
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
context "when deletable is false and link_url, and menu_match is blank" do
|
589
|
+
it "returns false" do
|
590
|
+
deletable_page.deletable = false
|
591
|
+
deletable_page.deletable?.should be_false
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
context "when deletable is false and link_url or menu_match isn't blank" do
|
596
|
+
it "returns false" do
|
597
|
+
deletable_page.deletable = false
|
598
|
+
deletable_page.link_url = "text"
|
599
|
+
deletable_page.deletable?.should be_false
|
600
|
+
|
601
|
+
deletable_page.menu_match = "text"
|
602
|
+
deletable_page.deletable?.should be_false
|
603
|
+
end
|
604
|
+
end
|
605
|
+
end
|
606
|
+
|
607
|
+
describe "#destroy" do
|
608
|
+
before do
|
609
|
+
page.deletable = false
|
610
|
+
page.link_url = "link_url"
|
611
|
+
page.menu_match = "menu_match"
|
612
|
+
page.save!
|
613
|
+
end
|
614
|
+
|
615
|
+
it "shows message" do
|
616
|
+
page.should_receive(:puts_destroy_help)
|
617
|
+
|
618
|
+
page.destroy
|
494
619
|
end
|
495
620
|
end
|
496
621
|
end
|