webficient-browsercms 3.0.1 → 3.0.2

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.
Files changed (34) hide show
  1. data/app/controllers/cms/content_block_controller.rb +25 -2
  2. data/app/controllers/cms/content_controller.rb +2 -1
  3. data/app/controllers/cms/dashboard_controller.rb +2 -1
  4. data/app/controllers/cms/error_handling.rb +3 -3
  5. data/app/controllers/cms/sections_controller.rb +5 -2
  6. data/app/models/attachment.rb +9 -1
  7. data/app/models/content_type.rb +2 -2
  8. data/app/models/link.rb +2 -2
  9. data/app/models/page.rb +10 -0
  10. data/app/models/user.rb +34 -16
  11. data/app/views/cms/blocks/_toolbar_for_member.html.erb +3 -3
  12. data/app/views/cms/blocks/index.html.erb +10 -6
  13. data/app/views/cms/content/show.html.erb +0 -1
  14. data/app/views/cms/dashboard/_recently_updated.html.erb +50 -0
  15. data/app/views/cms/dashboard/index.html.erb +9 -1
  16. data/app/views/cms/sections/_form.html.erb +36 -34
  17. data/app/views/layouts/_page_toolbar.html.erb +5 -5
  18. data/browsercms.gemspec +1289 -1283
  19. data/lib/cms/acts/content_block.rb +1 -1
  20. data/lib/cms/behaviors/publishing.rb +11 -1
  21. data/lib/cms/behaviors/versioning.rb +8 -2
  22. data/lib/cms/routes.rb +8 -1
  23. data/lib/tasks/db.rake +1 -1
  24. data/public/stylesheets/cms/dashboard.css +18 -1
  25. data/test/functional/cms/content_block_controller_test.rb +120 -0
  26. data/test/functional/cms/content_controller_test.rb +10 -1
  27. data/test/functional/cms/links_controller_test.rb +5 -0
  28. data/test/functional/cms/pages_controller_test.rb +8 -0
  29. data/test/functional/cms/sections_controller_test.rb +29 -3
  30. data/test/unit/lib/routes_test.rb +57 -0
  31. data/test/unit/models/content_type_test.rb +22 -1
  32. data/test/unit/models/page_test.rb +19 -2
  33. data/test/unit/models/user_test.rb +114 -40
  34. metadata +8 -5
@@ -54,7 +54,7 @@ class UserTest < ActiveSupport::TestCase
54
54
  end
55
55
  end
56
56
 
57
- class UserPermssionsTest < ActiveSupport::TestCase
57
+ class UserPermissionsTest < ActiveSupport::TestCase
58
58
  def setup
59
59
  @user = Factory(:user)
60
60
  @guest_group = Group.first(:conditions => {:code => "guest"})
@@ -75,51 +75,125 @@ class UserPermssionsTest < ActiveSupport::TestCase
75
75
  assert !@user.able_to?("do something the group does not have permission to do")
76
76
  end
77
77
 
78
- def test_cms_user_permissions
78
+ test "cms user access to nodes" do
79
79
  @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
80
- @group.permissions << create_or_find_permission_named("edit_content")
81
- @group.permissions << create_or_find_permission_named("publish_content")
82
80
  @user.groups << @group
83
- @editable_section = Factory(:section, :parent => root_section, :name => "Editable")
84
- @editable_subsection = Factory(:section, :parent => @editable_section, :name => "Editable Subsection")
85
- @group.sections << @editable_section
86
- @noneditable_section = Factory(:section, :parent => root_section, :name => "Not Editable")
87
- @editable_page = Factory(:page, :section => @editable_section)
88
- @editable_page2 = Factory(:page, :section => @editable_subsection)
89
- @noneditable_page = Factory(:page, :section => @noneditable_section)
90
- @editable_link = Factory(:link, :section => @editable_section)
91
- @editable_link2 = Factory(:link, :section => @editable_subsection)
92
- @noneditable_link = Factory(:link, :section => @noneditable_section)
93
-
94
- assert @user.able_to_edit?(@editable_section)
95
- assert @user.able_to_edit?(@editable_subsection)
96
- assert !@user.able_to_edit?(@noneditable_section)
97
-
98
- assert @user.able_to_edit?(@editable_page)
99
- assert @user.able_to_edit?(@editable_page2)
100
- assert !@user.able_to_edit?(@noneditable_page)
101
-
102
- assert @user.able_to_edit?(@editable_link)
103
- assert @user.able_to_edit?(@editable_link2)
104
- assert !@user.able_to_edit?(@noneditable_link)
105
-
106
- assert @user.able_to_view?(@editable_page)
107
- assert @user.able_to_view?(@noneditable_page)
81
+
82
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
83
+ @modifiable_subsection = Factory(:section, :parent => @modifiable_section, :name => "Modifiable Subsection")
84
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
85
+
86
+ @group.sections << @modifiable_section
87
+
88
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
89
+ @modifiable_page2 = Factory(:page, :section => @modifiable_subsection)
90
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
91
+
92
+ @modifiable_link = Factory(:link, :section => @modifiable_section)
93
+ @modifiable_link2 = Factory(:link, :section => @modifiable_subsection)
94
+ @non_modifiable_link = Factory(:link, :section => @non_modifiable_section)
95
+
96
+ assert @user.able_to_modify?(@modifiable_section)
97
+ assert @user.able_to_modify?(@modifiable_subsection)
98
+ assert !@user.able_to_modify?(@non_modifiable_section)
99
+
100
+ assert @user.able_to_modify?(@modifiable_page)
101
+ assert @user.able_to_modify?(@modifiable_page2)
102
+ assert !@user.able_to_modify?(@non_modifiable_page)
103
+
104
+ assert @user.able_to_modify?(@modifiable_link)
105
+ assert @user.able_to_modify?(@modifiable_link2)
106
+ assert !@user.able_to_modify?(@non_modifiable_link)
108
107
  end
109
108
 
110
- def test_non_cms_user_permissions
109
+ test "cms user access to connectables" do
110
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
111
+ @user.groups << @group
112
+
113
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
114
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
115
+
116
+ @group.sections << @modifiable_section
117
+
118
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
119
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
120
+
121
+ @all_modifiable_connectable = stub(
122
+ :class => stub(:content_block? => true, :connectable? => true),
123
+ :connected_pages => [@modifiable_page])
124
+ @some_modifiable_connectable = stub(
125
+ :class => stub(:content_block? => true, :connectable? => true),
126
+ :connected_pages => [@modifiable_page, @non_modifiable_page])
127
+ @none_modifiable_connectable = stub(
128
+ :class => stub(:content_block? => true, :connectable? => true),
129
+ :connected_pages => [@non_modifiable_page])
130
+
131
+ assert @user.able_to_modify?(@all_modifiable_connectable)
132
+ assert !@user.able_to_modify?(@some_modifiable_connectable)
133
+ assert !@user.able_to_modify?(@none_modifiable_connectable)
134
+ end
135
+
136
+ test "cms user access to non-connectable content blocks" do
137
+ @content_block = stub(:class => stub(:content_block? => true))
138
+ assert @user.able_to_modify?(@content_block)
139
+ end
140
+
141
+ test "non cms user access to nodes" do
111
142
  @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "Registered User"))
112
143
  @user.groups << @group
113
- @editable_section = Factory(:section, :parent => root_section, :name => "Editable")
114
- @group.sections << @editable_section
115
- @noneditable_section = Factory(:section, :parent => root_section, :name => "Not Editable")
116
- @editable_page = Factory(:page, :section => @editable_section)
117
- @noneditable_page = Factory(:page, :section => @noneditable_section)
144
+
145
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
146
+ @group.sections << @modifiable_section
147
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
148
+
149
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
150
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
118
151
 
119
- assert !@user.able_to_edit?(@editable_section)
120
- assert !@user.able_to_edit?(@noneditable_section)
121
- assert @user.able_to_view?(@editable_page)
122
- assert !@user.able_to_view?(@noneditable_page)
152
+ assert !@user.able_to_modify?(@modifiable_section)
153
+ assert !@user.able_to_modify?(@non_modifiable_section)
154
+
155
+ assert @user.able_to_view?(@modifiable_page)
156
+ assert !@user.able_to_view?(@non_modifiable_page)
157
+ end
158
+
159
+ test "cms user with no permissions should still be able to view pages" do
160
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
161
+ @user.groups << @group
162
+
163
+ @page = Factory(:page)
164
+ assert @user.able_to_view?(@page)
165
+ end
166
+
167
+ test "cms user who can edit content" do
168
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
169
+ @group.permissions << create_or_find_permission_named("edit_content")
170
+ @user.groups << @group
171
+
172
+ node = stub
173
+
174
+ @user.stubs(:able_to_modify?).with(node).returns(true)
175
+ assert @user.able_to_edit?(node)
176
+ assert !@user.able_to_publish?(node)
177
+
178
+ @user.stubs(:able_to_modify?).with(node).returns(false)
179
+ assert !@user.able_to_edit?(node)
180
+ assert !@user.able_to_publish?(node)
181
+ end
182
+
183
+ test "cms user who can publish content" do
184
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
185
+ @group.permissions << create_or_find_permission_named("publish_content")
186
+ @user.groups << @group
187
+
188
+ node = stub
189
+
190
+ @user.stubs(:able_to_modify?).with(node).returns(true)
191
+ assert !@user.able_to_edit?(node)
192
+ assert @user.able_to_publish?(node)
193
+
194
+ @user.stubs(:able_to_modify?).with(node).returns(false)
195
+ assert !@user.able_to_edit?(node)
196
+ assert !@user.able_to_publish?(node)
123
197
  end
124
198
 
125
199
  end
@@ -142,4 +216,4 @@ class GuestUserTest < ActiveSupport::TestCase
142
216
  assert !@user.able_to_view?(@protected_page)
143
217
  end
144
218
 
145
- end
219
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webficient-browsercms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrowserMedia
@@ -10,11 +10,11 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-08-14 00:00:00 -07:00
13
+ date: 2009-08-24 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
- description:
17
+ description: browsercms
18
18
  email: github@browsermedia.com
19
19
  executables: []
20
20
 
@@ -132,6 +132,7 @@ files:
132
132
  - app/views/cms/content/show.html.erb
133
133
  - app/views/cms/content_types/index.html.erb
134
134
  - app/views/cms/dashboard/_page_drafts.html.erb
135
+ - app/views/cms/dashboard/_recently_updated.html.erb
135
136
  - app/views/cms/dashboard/_tasks.html.erb
136
137
  - app/views/cms/dashboard/index.html.erb
137
138
  - app/views/cms/dynamic_views/_form.html.erb
@@ -1242,7 +1243,7 @@ files:
1242
1243
  - templates/module.rb
1243
1244
  - LICENSE.txt
1244
1245
  - README.markdown
1245
- has_rdoc: true
1246
+ has_rdoc: false
1246
1247
  homepage: http://www.browsercms.org
1247
1248
  licenses:
1248
1249
  post_install_message:
@@ -1267,7 +1268,7 @@ requirements: []
1267
1268
  rubyforge_project: browsercms
1268
1269
  rubygems_version: 1.3.5
1269
1270
  signing_key:
1270
- specification_version: 2
1271
+ specification_version: 3
1271
1272
  summary: BrowserCMS is a general purpose, open source Web Content Management System (CMS), written in Ruby on Rails.
1272
1273
  test_files:
1273
1274
  - test/custom_assertions.rb
@@ -1275,6 +1276,7 @@ test_files:
1275
1276
  - test/functional/cms/cache_controller_test.rb
1276
1277
  - test/functional/cms/categories_controller_test.rb
1277
1278
  - test/functional/cms/connectors_controller_test.rb
1279
+ - test/functional/cms/content_block_controller_test.rb
1278
1280
  - test/functional/cms/content_controller_test.rb
1279
1281
  - test/functional/cms/content_types_controller_test.rb
1280
1282
  - test/functional/cms/dashboard_controller_test.rb
@@ -1312,6 +1314,7 @@ test_files:
1312
1314
  - test/unit/helpers/section_nodes_helper_test.rb
1313
1315
  - test/unit/lib/content_block_test.rb
1314
1316
  - test/unit/lib/generators_test.rb
1317
+ - test/unit/lib/routes_test.rb
1315
1318
  - test/unit/models/attachment_test.rb
1316
1319
  - test/unit/models/category_test.rb
1317
1320
  - test/unit/models/category_type_test.rb