alchemy_cms 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -122,7 +122,8 @@ module Alchemy
|
|
122
122
|
:reverse_children => false
|
123
123
|
}.merge(options)
|
124
124
|
page = page_or_find(options[:from_page])
|
125
|
-
|
125
|
+
return nil if page.blank?
|
126
|
+
pages = page.children.with_permissions_to(:see, :context => :alchemy_pages)
|
126
127
|
pages = pages.restricted if options.delete(:restricted_only)
|
127
128
|
if depth = options[:deepness]
|
128
129
|
pages = pages.where("#{Page.table_name}.depth <= #{depth}")
|
@@ -197,7 +198,7 @@ module Alchemy
|
|
197
198
|
:reverse => false,
|
198
199
|
:link_active_page => false
|
199
200
|
}.merge(options)
|
200
|
-
pages = breadcrumb(options[:page]).
|
201
|
+
pages = breadcrumb(options[:page]).with_permissions_to(:see, :context => :alchemy_pages)
|
201
202
|
pages = pages.restricted if options.delete(:restricted_only)
|
202
203
|
pages.to_a.reverse! if options[:reverse]
|
203
204
|
if options[:without].present?
|
@@ -1,6 +1,9 @@
|
|
1
1
|
authorization do
|
2
2
|
|
3
3
|
role :guest do
|
4
|
+
has_permission_on :alchemy_pages, :to => [:see] do
|
5
|
+
if_attribute :visible => true, :restricted => false
|
6
|
+
end
|
4
7
|
has_permission_on :alchemy_pages, :to => [:show] do
|
5
8
|
if_attribute :public => true, :restricted => false
|
6
9
|
end
|
@@ -17,6 +20,9 @@ authorization do
|
|
17
20
|
|
18
21
|
role :registered do
|
19
22
|
includes :guest
|
23
|
+
has_permission_on :alchemy_pages, :to => [:see] do
|
24
|
+
if_attribute :visible => true, :restricted => true
|
25
|
+
end
|
20
26
|
has_permission_on :alchemy_pages, :to => [:show] do
|
21
27
|
if_attribute :public => true, :restricted => true
|
22
28
|
if_attribute :public => true, :restricted => false
|
data/lib/alchemy/version.rb
CHANGED
@@ -60,5 +60,31 @@ module Alchemy
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
describe '#page_or_find' do
|
64
|
+
let(:page) { FactoryGirl.create(:public_page) }
|
65
|
+
|
66
|
+
context "passing a page_layout string" do
|
67
|
+
context "of a not existing page" do
|
68
|
+
it "should return nil" do
|
69
|
+
expect(helper.page_or_find('contact')).to be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'of an existing page' do
|
74
|
+
it "should return the page object" do
|
75
|
+
session[:language_id] = page.language_id
|
76
|
+
expect(helper.page_or_find(page.page_layout)).to eq(page)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "passing a page object" do
|
82
|
+
it "should return the given page object" do
|
83
|
+
expect(helper.page_or_find(page)).to eq(page)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
63
89
|
end
|
64
90
|
end
|
@@ -25,14 +25,26 @@ module Alchemy
|
|
25
25
|
@root_page = language_root # We need this instance variable in the helpers
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
describe "#render_page_layout" do
|
29
|
+
it "should render the current page layout" do
|
30
|
+
@page = public_page
|
31
|
+
helper.render_page_layout.should have_selector('div#content')
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
35
|
describe "#render_navigation" do
|
34
36
|
before { visible_page }
|
35
37
|
|
38
|
+
it "should render only visible pages" do
|
39
|
+
not_visible_page = FactoryGirl.create(:page, visible: false)
|
40
|
+
helper.render_navigation.should_not match(/#{not_visible_page.name}/)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should render visible unpublished pages" do
|
44
|
+
unpublished_visible_page = FactoryGirl.create(:page, visible: true, public: false)
|
45
|
+
helper.render_navigation.should match(/#{unpublished_visible_page.name}/)
|
46
|
+
end
|
47
|
+
|
36
48
|
context "not in multi_language mode" do
|
37
49
|
before { helper.stub(:multi_language?).and_return(false) }
|
38
50
|
|
@@ -54,8 +66,10 @@ module Alchemy
|
|
54
66
|
Authorization.stub!(:current_user).and_return(FactoryGirl.build(:registered_user))
|
55
67
|
end
|
56
68
|
|
57
|
-
it "should render restricted pages" do
|
58
|
-
|
69
|
+
it "should render also restricted pages" do
|
70
|
+
not_restricted_page = FactoryGirl.create(:public_page, restricted: false, visible: true)
|
71
|
+
helper.render_navigation.should match(/#{restricted_page.name}/)
|
72
|
+
helper.render_navigation.should match(/#{not_restricted_page.name}/)
|
59
73
|
end
|
60
74
|
end
|
61
75
|
|
@@ -114,6 +128,34 @@ module Alchemy
|
|
114
128
|
end
|
115
129
|
end
|
116
130
|
|
131
|
+
context "with options[:from_page] set" do
|
132
|
+
before { level_2_page }
|
133
|
+
|
134
|
+
context "passing a page object" do
|
135
|
+
it "should render the pages underneath the given one" do
|
136
|
+
output = helper.render_navigation(from_page: visible_page)
|
137
|
+
output.should_not have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
|
138
|
+
output.should have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "passing a page_layout" do
|
143
|
+
it "should render the pages underneath the page with the given page_layout" do
|
144
|
+
helper.stub(:page_or_find).with('contact').and_return(visible_page)
|
145
|
+
output = helper.render_navigation(from_page: 'contact')
|
146
|
+
output.should_not have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
|
147
|
+
output.should have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "passing a page_layout of a not existing page" do
|
152
|
+
it "should render nothing" do
|
153
|
+
expect(helper.render_navigation(from_page: 'news')).to be_nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
117
159
|
end
|
118
160
|
|
119
161
|
describe '#render_subnavigation' do
|
@@ -211,14 +253,14 @@ module Alchemy
|
|
211
253
|
end
|
212
254
|
end
|
213
255
|
|
214
|
-
it "should render a breadcrumb of visible pages only
|
215
|
-
page.update_attributes!(visible: false, urlname: 'a-invisible-
|
216
|
-
helper.render_breadcrumb(page: page
|
256
|
+
it "should render a breadcrumb of visible pages only" do
|
257
|
+
page.update_attributes!(visible: false, urlname: 'a-invisible-page', name: 'A Invisible Page', title: 'A Invisible Page')
|
258
|
+
helper.render_breadcrumb(page: page).should_not match(/A Invisible Page/)
|
217
259
|
end
|
218
260
|
|
219
|
-
it "should render a breadcrumb of
|
261
|
+
it "should render a breadcrumb of visible and unpublished pages" do
|
220
262
|
page.update_attributes!(public: false, urlname: 'a-unpublic-page', name: 'A Unpublic Page', title: 'A Unpublic Page')
|
221
|
-
helper.render_breadcrumb(page: page
|
263
|
+
helper.render_breadcrumb(page: page).should match(/A Unpublic Page/)
|
222
264
|
end
|
223
265
|
|
224
266
|
context "with options[:without]" do
|
@@ -266,7 +308,7 @@ module Alchemy
|
|
266
308
|
describe "#language_links" do
|
267
309
|
|
268
310
|
context "with two public languages" do
|
269
|
-
|
311
|
+
|
270
312
|
# Always create second language
|
271
313
|
before { klingonian }
|
272
314
|
|
@@ -324,7 +366,7 @@ module Alchemy
|
|
324
366
|
end
|
325
367
|
end
|
326
368
|
end
|
327
|
-
|
369
|
+
|
328
370
|
context "with options[:show_title]" do
|
329
371
|
context "set to true" do
|
330
372
|
it "should render the language links with titles" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-
|
16
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rails
|
@@ -1151,7 +1151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1151
1151
|
version: '0'
|
1152
1152
|
segments:
|
1153
1153
|
- 0
|
1154
|
-
hash:
|
1154
|
+
hash: 2987207668504208741
|
1155
1155
|
requirements:
|
1156
1156
|
- ImageMagick (libmagick), v6.6 or greater.
|
1157
1157
|
rubyforge_project:
|