browsercms 3.0.2 → 3.0.3

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 (64) hide show
  1. data/app/controllers/cms/content_block_controller.rb +25 -2
  2. data/app/controllers/cms/content_controller.rb +31 -2
  3. data/app/controllers/cms/dashboard_controller.rb +2 -1
  4. data/app/controllers/cms/error_handling.rb +9 -2
  5. data/app/controllers/cms/links_controller.rb +2 -0
  6. data/app/controllers/cms/pages_controller.rb +22 -18
  7. data/app/controllers/cms/section_nodes_controller.rb +1 -1
  8. data/app/controllers/cms/sections_controller.rb +12 -7
  9. data/app/controllers/cms/sessions_controller.rb +17 -10
  10. data/app/controllers/cms/users_controller.rb +8 -6
  11. data/app/helpers/cms/application_helper.rb +2 -6
  12. data/app/helpers/cms/menu_helper.rb +118 -146
  13. data/app/helpers/cms/page_helper.rb +2 -2
  14. data/app/models/attachment.rb +2 -2
  15. data/app/models/group.rb +13 -2
  16. data/app/models/guest_user.rb +9 -3
  17. data/app/models/link.rb +2 -2
  18. data/app/models/page.rb +1 -1
  19. data/app/models/section.rb +7 -2
  20. data/app/models/user.rb +35 -17
  21. data/app/views/cms/blocks/_toolbar_for_member.html.erb +3 -3
  22. data/app/views/cms/blocks/index.html.erb +11 -6
  23. data/app/views/cms/content/show.html.erb +3 -3
  24. data/app/views/cms/menus/_menu.html.erb +9 -0
  25. data/app/views/cms/menus/_menu_item.html.erb +11 -0
  26. data/app/views/cms/pages/_edit_connector.html.erb +1 -1
  27. data/app/views/cms/pages/_edit_container.html.erb +1 -1
  28. data/app/views/cms/section_nodes/_node.html.erb +1 -1
  29. data/app/views/cms/sections/_form.html.erb +36 -34
  30. data/app/views/cms/shared/access_denied.html.erb +3 -0
  31. data/app/views/cms/users/change_password.html.erb +8 -6
  32. data/app/views/cms/users/index.html.erb +1 -1
  33. data/app/views/cms/users/show.html.erb +50 -0
  34. data/app/views/layouts/_cms_toolbar.html.erb +1 -1
  35. data/app/views/layouts/_page_toolbar.html.erb +7 -7
  36. data/app/views/layouts/cms/administration.html.erb +24 -7
  37. data/browsercms.gemspec +13 -7
  38. data/lib/acts_as_list.rb +8 -4
  39. data/lib/cms/acts/content_block.rb +1 -1
  40. data/lib/cms/authentication/controller.rb +26 -7
  41. data/lib/cms/behaviors/attaching.rb +3 -3
  42. data/lib/cms/behaviors/publishing.rb +12 -1
  43. data/lib/cms/behaviors/rendering.rb +17 -4
  44. data/lib/cms/behaviors/versioning.rb +2 -2
  45. data/lib/cms/routes.rb +4 -0
  46. data/lib/tasks/cms.rake +0 -18
  47. data/public/javascripts/cms/content_library.js +36 -0
  48. data/public/javascripts/cms/sitemap.js +21 -9
  49. data/public/stylesheets/cms/form_layout.css +16 -2
  50. data/public/stylesheets/cms/nav.css +4 -3
  51. data/test/functional/cms/content_block_controller_test.rb +120 -0
  52. data/test/functional/cms/content_controller_test.rb +135 -80
  53. data/test/functional/cms/links_controller_test.rb +89 -1
  54. data/test/functional/cms/pages_controller_test.rb +138 -0
  55. data/test/functional/cms/section_nodes_controller_test.rb +45 -5
  56. data/test/functional/cms/sections_controller_test.rb +148 -1
  57. data/test/functional/cms/sessions_controller_test.rb +26 -2
  58. data/test/functional/cms/users_controller_test.rb +49 -2
  59. data/test/test_helper.rb +3 -1
  60. data/test/unit/behaviors/attaching_test.rb +26 -0
  61. data/test/unit/helpers/menu_helper_test.rb +118 -278
  62. data/test/unit/models/group_test.rb +6 -0
  63. data/test/unit/models/user_test.rb +127 -29
  64. metadata +12 -4
@@ -16,7 +16,6 @@ class UserTest < ActiveSupport::TestCase
16
16
  @user.disable!
17
17
  assert_nil User.authenticate(@user.login, @user.password)
18
18
  end
19
-
20
19
  def test_expiration
21
20
  @user = Factory.build(:user)
22
21
  assert_nil @user.expires_at
@@ -32,7 +31,6 @@ class UserTest < ActiveSupport::TestCase
32
31
  @user.expires_at = 1.day.ago
33
32
  assert @user.expired?
34
33
  end
35
-
36
34
  def test_disable_enable
37
35
  @user = Factory(:user)
38
36
 
@@ -52,12 +50,29 @@ class UserTest < ActiveSupport::TestCase
52
50
  assert !@user.expired?
53
51
  assert User.active.all.include?(@user)
54
52
  end
53
+ test "email validation" do
54
+ @user = Factory(:user)
55
+ assert @user.valid?
56
+
57
+ valid_emails = ['t@test.com', 'T@test.com', 'test@somewhere.mobi', 'test@somewhere.tv', 'joe_blow@somewhere.co.nz', 'joe_blow@somewhere.com.au', 't@t-t.co']
58
+ valid_emails.each do |email|
59
+ @user.email = email
60
+ assert @user.valid?
61
+ end
62
+
63
+ invalid_emails = ['', '@test.com', '@test', 'test@test', 'test@somewhere', 'test@somewhere.', 'test@somewhere.x', 'test@somewhere..']
64
+ invalid_emails.each do |email|
65
+ @user.email = email
66
+ assert !@user.valid?
67
+ end
68
+ end
69
+
55
70
  end
56
71
 
57
- class UserPermssionsTest < ActiveSupport::TestCase
72
+ class UserPermissionsTest < ActiveSupport::TestCase
58
73
  def setup
59
74
  @user = Factory(:user)
60
- @guest_group = Group.first(:conditions => {:code => "guest"})
75
+ @guest_group = Group.guest
61
76
  end
62
77
 
63
78
  def test_user_permissions
@@ -75,36 +90,119 @@ class UserPermssionsTest < ActiveSupport::TestCase
75
90
  assert !@user.able_to?("do something the group does not have permission to do")
76
91
  end
77
92
 
78
- def test_cms_user_permissions
93
+ test "cms user access to nodes" do
94
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
95
+ @user.groups << @group
96
+
97
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
98
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
99
+
100
+ @group.sections << @modifiable_section
101
+
102
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
103
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
104
+
105
+ @modifiable_link = Factory(:link, :section => @modifiable_section)
106
+ @non_modifiable_link = Factory(:link, :section => @non_modifiable_section)
107
+
108
+ assert @user.able_to_modify?(@modifiable_section)
109
+ assert !@user.able_to_modify?(@non_modifiable_section)
110
+
111
+ assert @user.able_to_modify?(@modifiable_page)
112
+ assert !@user.able_to_modify?(@non_modifiable_page)
113
+
114
+ assert @user.able_to_modify?(@modifiable_link)
115
+ assert !@user.able_to_modify?(@non_modifiable_link)
116
+ end
117
+
118
+ test "cms user access to connectables" do
79
119
  @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
120
  @user.groups << @group
83
- @editable_section = Factory(:section, :parent => root_section, :name => "Editable")
84
- @group.sections << @editable_section
85
- @noneditable_section = Factory(:section, :parent => root_section, :name => "Not Editable")
86
- @editable_page = Factory(:page, :section => @editable_section)
87
- @noneditable_page = Factory(:page, :section => @noneditable_section)
88
-
89
- assert @user.able_to_edit?(@editable_section)
90
- assert !@user.able_to_edit?(@noneditable_section)
91
- assert @user.able_to_view?(@editable_page)
92
- assert @user.able_to_view?(@noneditable_page)
121
+
122
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
123
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
124
+
125
+ @group.sections << @modifiable_section
126
+
127
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
128
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
129
+
130
+ @all_modifiable_connectable = stub(
131
+ :class => stub(:content_block? => true, :connectable? => true),
132
+ :connected_pages => [@modifiable_page])
133
+ @some_modifiable_connectable = stub(
134
+ :class => stub(:content_block? => true, :connectable? => true),
135
+ :connected_pages => [@modifiable_page, @non_modifiable_page])
136
+ @none_modifiable_connectable = stub(
137
+ :class => stub(:content_block? => true, :connectable? => true),
138
+ :connected_pages => [@non_modifiable_page])
139
+
140
+ assert @user.able_to_modify?(@all_modifiable_connectable)
141
+ assert !@user.able_to_modify?(@some_modifiable_connectable)
142
+ assert !@user.able_to_modify?(@none_modifiable_connectable)
143
+ end
144
+
145
+ test "cms user access to non-connectable content blocks" do
146
+ @content_block = stub(:class => stub(:content_block? => true))
147
+ assert @user.able_to_modify?(@content_block)
93
148
  end
94
149
 
95
- def test_non_cms_user_permissions
150
+ test "non cms user access to nodes" do
96
151
  @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "Registered User"))
97
152
  @user.groups << @group
98
- @editable_section = Factory(:section, :parent => root_section, :name => "Editable")
99
- @group.sections << @editable_section
100
- @noneditable_section = Factory(:section, :parent => root_section, :name => "Not Editable")
101
- @editable_page = Factory(:page, :section => @editable_section)
102
- @noneditable_page = Factory(:page, :section => @noneditable_section)
153
+
154
+ @modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
155
+ @group.sections << @modifiable_section
156
+ @non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
157
+
158
+ @modifiable_page = Factory(:page, :section => @modifiable_section)
159
+ @non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
103
160
 
104
- assert !@user.able_to_edit?(@editable_section)
105
- assert !@user.able_to_edit?(@noneditable_section)
106
- assert @user.able_to_view?(@editable_page)
107
- assert !@user.able_to_view?(@noneditable_page)
161
+ assert !@user.able_to_modify?(@modifiable_section)
162
+ assert !@user.able_to_modify?(@non_modifiable_section)
163
+
164
+ assert @user.able_to_view?(@modifiable_page)
165
+ assert !@user.able_to_view?(@non_modifiable_page)
166
+ end
167
+
168
+ test "cms user with no permissions should still be able to view pages" do
169
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
170
+ @user.groups << @group
171
+
172
+ @page = Factory(:page)
173
+ assert @user.able_to_view?(@page)
174
+ end
175
+
176
+ test "cms user who can edit content" do
177
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
178
+ @group.permissions << create_or_find_permission_named("edit_content")
179
+ @user.groups << @group
180
+
181
+ node = stub
182
+
183
+ @user.stubs(:able_to_modify?).with(node).returns(true)
184
+ assert @user.able_to_edit?(node)
185
+ assert !@user.able_to_publish?(node)
186
+
187
+ @user.stubs(:able_to_modify?).with(node).returns(false)
188
+ assert !@user.able_to_edit?(node)
189
+ assert !@user.able_to_publish?(node)
190
+ end
191
+
192
+ test "cms user who can publish content" do
193
+ @group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
194
+ @group.permissions << create_or_find_permission_named("publish_content")
195
+ @user.groups << @group
196
+
197
+ node = stub
198
+
199
+ @user.stubs(:able_to_modify?).with(node).returns(true)
200
+ assert !@user.able_to_edit?(node)
201
+ assert @user.able_to_publish?(node)
202
+
203
+ @user.stubs(:able_to_modify?).with(node).returns(false)
204
+ assert !@user.able_to_edit?(node)
205
+ assert !@user.able_to_publish?(node)
108
206
  end
109
207
 
110
208
  end
@@ -112,7 +210,7 @@ end
112
210
  class GuestUserTest < ActiveSupport::TestCase
113
211
  def setup
114
212
  @user = User.guest
115
- @guest_group = Group.with_code("guest").first
213
+ @guest_group = Group.guest
116
214
  @public_page = Factory(:page, :section => root_section)
117
215
  @protected_section = Factory(:section, :parent => root_section)
118
216
  @protected_page = Factory(:page, :section => @protected_section)
@@ -127,4 +225,4 @@ class GuestUserTest < ActiveSupport::TestCase
127
225
  assert !@user.able_to_view?(@protected_page)
128
226
  end
129
227
 
130
- end
228
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsercms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrowserMedia
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-06 00:00:00 -04:00
12
+ date: 2009-11-06 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -162,6 +162,8 @@ files:
162
162
  - app/views/cms/links/destroy.js.rjs
163
163
  - app/views/cms/links/edit.html.erb
164
164
  - app/views/cms/links/new.html.erb
165
+ - app/views/cms/menus/_menu.html.erb
166
+ - app/views/cms/menus/_menu_item.html.erb
165
167
  - app/views/cms/page_routes/_form.html.erb
166
168
  - app/views/cms/page_routes/edit.html.erb
167
169
  - app/views/cms/page_routes/index.html.erb
@@ -198,6 +200,7 @@ files:
198
200
  - app/views/cms/shared/_pagination.html.erb
199
201
  - app/views/cms/shared/_version_conflict_diff.html.erb
200
202
  - app/views/cms/shared/_version_conflict_error.html.erb
203
+ - app/views/cms/shared/access_denied.html.erb
201
204
  - app/views/cms/shared/error.html.erb
202
205
  - app/views/cms/tags/_form.html.erb
203
206
  - app/views/cms/tags/render.html.erb
@@ -212,6 +215,7 @@ files:
212
215
  - app/views/cms/users/edit.html.erb
213
216
  - app/views/cms/users/index.html.erb
214
217
  - app/views/cms/users/new.html.erb
218
+ - app/views/cms/users/show.html.erb
215
219
  - app/views/layouts/_cms_toolbar.html.erb
216
220
  - app/views/layouts/_page_toolbar.html.erb
217
221
  - app/views/layouts/application.html.erb
@@ -1175,6 +1179,7 @@ files:
1175
1179
  - public/images/cms/usercontrols_bg.png
1176
1180
  - public/images/cms/usercontrols_bg_cap.png
1177
1181
  - public/javascripts/cms/application.js
1182
+ - public/javascripts/cms/content_library.js
1178
1183
  - public/javascripts/cms/editor.js
1179
1184
  - public/javascripts/cms/sitemap.js
1180
1185
  - public/javascripts/jquery-ui.js
@@ -1238,6 +1243,8 @@ files:
1238
1243
  - README.markdown
1239
1244
  has_rdoc: true
1240
1245
  homepage: http://www.browsercms.org
1246
+ licenses: []
1247
+
1241
1248
  post_install_message:
1242
1249
  rdoc_options:
1243
1250
  - --charset=UTF-8
@@ -1258,9 +1265,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1258
1265
  requirements: []
1259
1266
 
1260
1267
  rubyforge_project: browsercms
1261
- rubygems_version: 1.3.1
1268
+ rubygems_version: 1.3.5
1262
1269
  signing_key:
1263
- specification_version: 2
1270
+ specification_version: 3
1264
1271
  summary: BrowserCMS is a general purpose, open source Web Content Management System (CMS), written in Ruby on Rails.
1265
1272
  test_files:
1266
1273
  - test/functional/cms/file_blocks_controller_test.rb
@@ -1275,6 +1282,7 @@ test_files:
1275
1282
  - test/functional/cms/links_controller_test.rb
1276
1283
  - test/functional/cms/dynamic_views_controller_test.rb
1277
1284
  - test/functional/cms/categories_controller_test.rb
1285
+ - test/functional/cms/content_block_controller_test.rb
1278
1286
  - test/functional/cms/pages_controller_test.rb
1279
1287
  - test/functional/cms/connectors_controller_test.rb
1280
1288
  - test/functional/cms/home_controller_test.rb