| 1 |
Index: test/functional/admin/welcome_controller_test.rb |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- test/functional/admin/welcome_controller_test.rb (revision 588) |
|---|
| 4 |
+++ test/functional/admin/welcome_controller_test.rb (working copy) |
|---|
| 5 |
@@ -17,7 +17,7 @@ |
|---|
| 6 |
|
|---|
| 7 |
def test_index |
|---|
| 8 |
get :index |
|---|
| 9 |
- assert_redirected_to page_index_url |
|---|
| 10 |
+ assert_redirected_to pages_path |
|---|
| 11 |
end |
|---|
| 12 |
|
|---|
| 13 |
def test_login |
|---|
| 14 |
Index: test/functional/admin/page_controller_test.rb |
|---|
| 15 |
=================================================================== |
|---|
| 16 |
--- test/functional/admin/page_controller_test.rb (revision 588) |
|---|
| 17 |
+++ test/functional/admin/page_controller_test.rb (working copy) |
|---|
| 18 |
@@ -29,34 +29,29 @@ |
|---|
| 19 |
assert_response :success |
|---|
| 20 |
assert_kind_of Page, assigns(:homepage) |
|---|
| 21 |
end |
|---|
| 22 |
- |
|---|
| 23 |
def test_index__without_pages |
|---|
| 24 |
Page.destroy_all |
|---|
| 25 |
get :index |
|---|
| 26 |
assert_response :success |
|---|
| 27 |
assert_nil assigns(:homepage) |
|---|
| 28 |
end |
|---|
| 29 |
- |
|---|
| 30 |
def test_index__without_cookies |
|---|
| 31 |
get :index |
|---|
| 32 |
assert_response :success |
|---|
| 33 |
assert_rendered_nodes_where { |page| [nil, 1].include?(page.parent_id) } |
|---|
| 34 |
end |
|---|
| 35 |
- |
|---|
| 36 |
def test_index__with_empty_cookie |
|---|
| 37 |
@request.cookies['expanded_rows'] = [""] |
|---|
| 38 |
get :index |
|---|
| 39 |
assert_response :success |
|---|
| 40 |
assert_rendered_nodes_where { |page| [nil, 1].include?(page.parent_id) } |
|---|
| 41 |
end |
|---|
| 42 |
- |
|---|
| 43 |
def test_index__with_cookie |
|---|
| 44 |
@request.cookies['expanded_rows'] = ["1,5,9,10,11,12,52"] |
|---|
| 45 |
get :index |
|---|
| 46 |
assert_response :success |
|---|
| 47 |
assert_rendered_nodes_where { |page| [nil, 1, 5, 9, 52, 10, 11, 12].include?(page.parent_id) } |
|---|
| 48 |
end |
|---|
| 49 |
- |
|---|
| 50 |
def test_index__with_mangled_cookie |
|---|
| 51 |
@request.cookies['expanded_rows'] = ["1,5,:#*)&},9a,,,"] |
|---|
| 52 |
get :index |
|---|
| 53 |
@@ -64,14 +59,23 @@ |
|---|
| 54 |
assert_rendered_nodes_where { |page| [nil, 1, 5].include?(page.parent_id) } |
|---|
| 55 |
assert !assigns(:homepage).nil? |
|---|
| 56 |
end |
|---|
| 57 |
- |
|---|
| 58 |
+ def test_index__xhr |
|---|
| 59 |
+ xhr :get, :index, :page_id => '1', :level => '1' |
|---|
| 60 |
+ assert_response :success |
|---|
| 61 |
+ assert_template "admin/page/children" |
|---|
| 62 |
+ assert_equal pages(:homepage), assigns(:parent) |
|---|
| 63 |
+ assert_equal 1, assigns(:level) |
|---|
| 64 |
+ assert ! %r{<head>}.match(@response.body) |
|---|
| 65 |
+ assert_equal 'text/html;charset=utf-8', @response.headers['Content-Type'] |
|---|
| 66 |
+ end |
|---|
| 67 |
+ |
|---|
| 68 |
def test_new |
|---|
| 69 |
@controller.config = { |
|---|
| 70 |
'defaults.page.parts' => 'body, extended, summary', |
|---|
| 71 |
'defaults.page.status' => 'published' |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
- get :new, :parent_id => '1', :page => page_params |
|---|
| 75 |
+ get :new, :page_id => '1', :page => page_params |
|---|
| 76 |
assert_response :success |
|---|
| 77 |
assert_template 'admin/page/edit' |
|---|
| 78 |
|
|---|
| 79 |
@@ -86,17 +90,29 @@ |
|---|
| 80 |
assert_equal Status[:published], @page.status |
|---|
| 81 |
end |
|---|
| 82 |
def test_new__with_slug_and_breadcrumb |
|---|
| 83 |
- get :new, :parent_id => '1', :page => page_params, :slug => 'test', :breadcrumb => 'me' |
|---|
| 84 |
+ get :new, :page_id => '1', :page => page_params, :slug => 'test', :breadcrumb => 'me' |
|---|
| 85 |
assert_response :success |
|---|
| 86 |
|
|---|
| 87 |
@page = assigns(:page) |
|---|
| 88 |
assert_equal 'test', @page.slug |
|---|
| 89 |
assert_equal 'me', @page.breadcrumb |
|---|
| 90 |
end |
|---|
| 91 |
- def test_new__post |
|---|
| 92 |
+ def test_new_edit__meta_and_buttons_partials_initialized |
|---|
| 93 |
+ get :new, :page_id => '1' |
|---|
| 94 |
+ assert_response :success |
|---|
| 95 |
+ assert_not_nil assigns(:meta) |
|---|
| 96 |
+ assert_not_nil assigns(:buttons_partials) |
|---|
| 97 |
+ |
|---|
| 98 |
+ get :edit, :page_id => 1, :id => '2' |
|---|
| 99 |
+ assert_response :success |
|---|
| 100 |
+ assert_not_nil assigns(:meta) |
|---|
| 101 |
+ assert_not_nil assigns(:buttons_partials) |
|---|
| 102 |
+ end |
|---|
| 103 |
+ |
|---|
| 104 |
+ def test_create |
|---|
| 105 |
@cache = @controller.cache = FakeResponseCache.new |
|---|
| 106 |
- post :new, :parent_id => '1', :page => page_params |
|---|
| 107 |
- assert_redirected_to page_index_url |
|---|
| 108 |
+ post :create, :page_id => '1', :page => page_params |
|---|
| 109 |
+ assert_redirected_to pages_path |
|---|
| 110 |
assert_match /saved/, flash[:notice] |
|---|
| 111 |
|
|---|
| 112 |
@page = assigns(:page) |
|---|
| 113 |
@@ -106,63 +122,76 @@ |
|---|
| 114 |
assert_kind_of Page, @page |
|---|
| 115 |
assert_equal '/page/', @cache.expired_path |
|---|
| 116 |
end |
|---|
| 117 |
- def test_new__post_with_invalid_page |
|---|
| 118 |
- post :new, :parent_id => '1', :page => page_params(:status_id => 'abc') |
|---|
| 119 |
+ def test_create__with_invalid_page |
|---|
| 120 |
+ post :create, :page_id => '1', :page => page_params(:status_id => 'abc') |
|---|
| 121 |
assert_response :success |
|---|
| 122 |
assert_match /error/, flash[:error] |
|---|
| 123 |
assert_nil get_test_page |
|---|
| 124 |
end |
|---|
| 125 |
- def test_new__post_with_parts |
|---|
| 126 |
- post(:new, :parent_id => '1', :page => page_params, |
|---|
| 127 |
+ def test_create__with_parts |
|---|
| 128 |
+ post(:create, :page_id => '1', :page => page_params, |
|---|
| 129 |
:part => { |
|---|
| 130 |
'1' => part_params(:name => 'test-part-1'), |
|---|
| 131 |
'2' => part_params(:name => 'test-part-2') |
|---|
| 132 |
} |
|---|
| 133 |
) |
|---|
| 134 |
- assert_redirected_to page_index_url |
|---|
| 135 |
+ assert_redirected_to pages_path |
|---|
| 136 |
|
|---|
| 137 |
@page = get_test_page |
|---|
| 138 |
assert_kind_of Page, @page |
|---|
| 139 |
names = @page.parts.collect { |part| part.name }.sort |
|---|
| 140 |
assert_equal ['test-part-1', 'test-part-2'], names |
|---|
| 141 |
end |
|---|
| 142 |
- def test_new__post_with_invalid_part |
|---|
| 143 |
+ def test_creat__with_invalid_part |
|---|
| 144 |
@part_name = 'extra long ' * 25 |
|---|
| 145 |
- post :new, :parent_id => '1', :page => page_params, :part => { '1' => part_params(:name => @part_name)} |
|---|
| 146 |
+ post :create, :page_id => '1', :page => page_params, :part => { '1' => part_params(:name => @part_name)} |
|---|
| 147 |
assert_response :success # not redirected |
|---|
| 148 |
assert_match /error/, flash[:error] |
|---|
| 149 |
assert_nil get_test_page |
|---|
| 150 |
assert_nil get_test_part |
|---|
| 151 |
end |
|---|
| 152 |
- def test_new__save_and_continue_editing |
|---|
| 153 |
- post :new, :parent_id => '1', :page => page_params, :continue => 'Save and Continue Editing' |
|---|
| 154 |
+ def test_create__save_and_continue_editing |
|---|
| 155 |
+ post :create, :page_id => '1', :page => page_params, :continue => 'Save and Continue Editing' |
|---|
| 156 |
@page = get_test_page |
|---|
| 157 |
- assert_redirected_to page_edit_url(:id => @page.id) |
|---|
| 158 |
+ assert_redirected_to edit_page_path(@page) |
|---|
| 159 |
end |
|---|
| 160 |
- def test_new_edit__meta_and_buttons_partials_initialized |
|---|
| 161 |
- get :new, :parent_id => '1' |
|---|
| 162 |
+ |
|---|
| 163 |
+ def test_homepage |
|---|
| 164 |
+ get :homepage |
|---|
| 165 |
assert_response :success |
|---|
| 166 |
- assert_not_nil assigns(:meta) |
|---|
| 167 |
- assert_not_nil assigns(:buttons_partials) |
|---|
| 168 |
- |
|---|
| 169 |
- get :edit, :id => '1' |
|---|
| 170 |
- assert_response :success |
|---|
| 171 |
- assert_not_nil assigns(:meta) |
|---|
| 172 |
- assert_not_nil assigns(:buttons_partials) |
|---|
| 173 |
+ assert_equal(assigns(:page).breadcrumb, "Home") |
|---|
| 174 |
end |
|---|
| 175 |
- |
|---|
| 176 |
+ |
|---|
| 177 |
+ def test_create |
|---|
| 178 |
+ @cache = @controller.cache = FakeResponseCache.new |
|---|
| 179 |
+ post :new, :page_id => '1', :page => page_params |
|---|
| 180 |
+ assert_redirected_to pages_path |
|---|
| 181 |
+ assert_match /saved/, flash[:notice] |
|---|
| 182 |
+ |
|---|
| 183 |
+ @page = assigns(:page) |
|---|
| 184 |
+ assert_equal 0, @page.parts.size |
|---|
| 185 |
+ |
|---|
| 186 |
+ @expected_parent = Page.find(1) |
|---|
| 187 |
+ assert_equal @expected_parent, @page.parent |
|---|
| 188 |
+ |
|---|
| 189 |
+ @page = get_test_page |
|---|
| 190 |
+ assert_kind_of Page, @page |
|---|
| 191 |
+ assert_equal '/page/', @cache.expired_path |
|---|
| 192 |
+ end |
|---|
| 193 |
+ |
|---|
| 194 |
def test_edit |
|---|
| 195 |
- get :edit, :id => '1', :page => page_params |
|---|
| 196 |
+ get :edit, :page_id => 1, :id => '1', :page => page_params |
|---|
| 197 |
assert_response :success |
|---|
| 198 |
|
|---|
| 199 |
@page = assigns(:page) |
|---|
| 200 |
assert_kind_of Page, @page |
|---|
| 201 |
assert_equal 'Ruby Home Page', @page.title |
|---|
| 202 |
- end |
|---|
| 203 |
- def test_edit__post |
|---|
| 204 |
+ end |
|---|
| 205 |
+ |
|---|
| 206 |
+ def test_update |
|---|
| 207 |
@cache = @controller.cache = FakeResponseCache.new |
|---|
| 208 |
@page = create_test_page |
|---|
| 209 |
- post :edit, :id => @page.id, :page => page_params(:status_id => '1') |
|---|
| 210 |
+ put :update, :id => @page.id, :page => page_params(:status_id => '1') |
|---|
| 211 |
assert_response :redirect |
|---|
| 212 |
assert_equal 1, get_test_page.status.id |
|---|
| 213 |
|
|---|
| 214 |
@@ -172,10 +201,10 @@ |
|---|
| 215 |
|
|---|
| 216 |
# To-Do: Test what happens when an invalid page is submitted |
|---|
| 217 |
end |
|---|
| 218 |
- def test_edit__post_with_slug_change |
|---|
| 219 |
+ def test_update__with_slug_change |
|---|
| 220 |
@cache = @controller.cache = FakeResponseCache.new |
|---|
| 221 |
@page = create_test_page |
|---|
| 222 |
- post :edit, :id => @page.id, :page => page_params(:slug => 'monkey', :status_id => '1') |
|---|
| 223 |
+ put :update, :id => @page.id, :page => page_params(:slug => 'monkey', :status_id => '1') |
|---|
| 224 |
assert_response :redirect |
|---|
| 225 |
assert_equal 1, get_test_page.status.id |
|---|
| 226 |
|
|---|
| 227 |
@@ -185,14 +214,14 @@ |
|---|
| 228 |
|
|---|
| 229 |
# To-Do: Test what happens when an invalid page is submitted |
|---|
| 230 |
end |
|---|
| 231 |
- def test_edit__post_with_parts |
|---|
| 232 |
+ def test_update__with_parts |
|---|
| 233 |
@page = create_test_page(:no_part => true) |
|---|
| 234 |
@page.parts.create(part_params(:name => 'test-part-1')) |
|---|
| 235 |
@page.parts.create(part_params(:name => 'test-part-2')) |
|---|
| 236 |
|
|---|
| 237 |
assert_equal 2, @page.parts.size |
|---|
| 238 |
|
|---|
| 239 |
- post :edit, :id => @page.id, :page => page_params, :part => {'1' => part_params(:name => 'test-part-1', :content => 'changed')} |
|---|
| 240 |
+ put :update, :id => @page.id, :page => page_params, :part => {'1' => part_params(:name => 'test-part-1', :content => 'changed')} |
|---|
| 241 |
assert_response :redirect |
|---|
| 242 |
|
|---|
| 243 |
@page = get_test_page |
|---|
| 244 |
@@ -200,24 +229,24 @@ |
|---|
| 245 |
assert_equal 'changed', @page.parts.first.content |
|---|
| 246 |
end |
|---|
| 247 |
|
|---|
| 248 |
- def test_edit__post_with_optimistic_locking |
|---|
| 249 |
+ def test_update__with_optimistic_locking |
|---|
| 250 |
@page = create_test_page |
|---|
| 251 |
- post :edit, :id => @page.id, :page => page_params(:status_id => '1', :lock_version => '12') |
|---|
| 252 |
+ put :update, :id => @page.id, :page => page_params(:status_id => '1', :lock_version => '12') |
|---|
| 253 |
assert_response :success # not redirected |
|---|
| 254 |
assert_match /has been modified/, flash[:error] |
|---|
| 255 |
end |
|---|
| 256 |
|
|---|
| 257 |
- def test_edit__post_with_parts_and_optimistic_locking |
|---|
| 258 |
+ def test_update__with_parts_and_optimistic_locking |
|---|
| 259 |
@page = create_test_page |
|---|
| 260 |
@page.parts.create(part_params(:name => 'test-part-1', :content => 'original-1')) |
|---|
| 261 |
- post :edit, :id => @page.id, :page => page_params(:status_id => '1', :lock_version => '12'), :part => {'1' => part_params(:name => 'test-part-1', :content => 'changed-1')} |
|---|
| 262 |
+ put :update, :id => @page.id, :page => page_params(:status_id => '1', :lock_version => '12'), :part => {'1' => part_params(:name => 'test-part-1', :content => 'changed-1')} |
|---|
| 263 |
assert_response :success # not redirected |
|---|
| 264 |
assert_match /has been modified/, flash[:error] |
|---|
| 265 |
#changed value must not be saved |
|---|
| 266 |
assert_equal 'original-1', @page.parts.find_by_name('test-part-1').content |
|---|
| 267 |
#but must be rendered to page |
|---|
| 268 |
assert_tag :tag => 'textarea', :content => 'changed-1' |
|---|
| 269 |
- end |
|---|
| 270 |
+ end |
|---|
| 271 |
|
|---|
| 272 |
def test_remove |
|---|
| 273 |
@page = create_test_page |
|---|
| 274 |
@@ -234,25 +263,19 @@ |
|---|
| 275 |
assert_tag "tr", :attributes => {:id => "page-#{page.id}"} |
|---|
| 276 |
end |
|---|
| 277 |
end |
|---|
| 278 |
- def test_remove__post |
|---|
| 279 |
+ |
|---|
| 280 |
+ def test_destroy |
|---|
| 281 |
@page = create_test_page |
|---|
| 282 |
- post :remove, :id => @page.id |
|---|
| 283 |
- assert_redirected_to page_index_url |
|---|
| 284 |
+ delete :destroy, :id => @page.id |
|---|
| 285 |
+ assert_redirected_to pages_path |
|---|
| 286 |
assert_match /removed/, flash[:notice] |
|---|
| 287 |
assert_nil get_test_page |
|---|
| 288 |
end |
|---|
| 289 |
|
|---|
| 290 |
- def test_clear_cache |
|---|
| 291 |
+ def test_clear_cache__delete |
|---|
| 292 |
@cache = @controller.cache = FakeResponseCache.new |
|---|
| 293 |
- get :clear_cache |
|---|
| 294 |
- assert_response :success |
|---|
| 295 |
- assert_match /Do.*?not.*?access/i, @response.body |
|---|
| 296 |
- assert_equal false, @cache.cleared? |
|---|
| 297 |
- end |
|---|
| 298 |
- def test_clear_cache__post |
|---|
| 299 |
- @cache = @controller.cache = FakeResponseCache.new |
|---|
| 300 |
- post :clear_cache |
|---|
| 301 |
- assert_redirected_to page_index_url |
|---|
| 302 |
+ delete :clear_cache |
|---|
| 303 |
+ assert_redirected_to pages_path |
|---|
| 304 |
assert_match /cache.*clear/i, flash[:notice] |
|---|
| 305 |
assert_equal true, @cache.cleared? |
|---|
| 306 |
end |
|---|
| 307 |
@@ -263,15 +286,6 @@ |
|---|
| 308 |
assert_template 'admin/page/_part' |
|---|
| 309 |
end |
|---|
| 310 |
|
|---|
| 311 |
- def test_children |
|---|
| 312 |
- get :children, :id => '1', :level => '1' |
|---|
| 313 |
- assert_response :success |
|---|
| 314 |
- assert_equal pages(:homepage), assigns(:parent) |
|---|
| 315 |
- assert_equal 1, assigns(:level) |
|---|
| 316 |
- assert ! %r{<head>}.match(@response.body) |
|---|
| 317 |
- assert_equal 'text/html;charset=utf-8', @response.headers['Content-Type'] |
|---|
| 318 |
- end |
|---|
| 319 |
- |
|---|
| 320 |
def test_tag_reference |
|---|
| 321 |
xml_http_request :get, :tag_reference, :class_name => "Page" |
|---|
| 322 |
assert_response :success |
|---|
| 323 |
Index: test/functional/admin/layout_controller_test.rb |
|---|
| 324 |
=================================================================== |
|---|
| 325 |
--- test/functional/admin/layout_controller_test.rb (revision 588) |
|---|
| 326 |
+++ test/functional/admin/layout_controller_test.rb (working copy) |
|---|
| 327 |
@@ -34,7 +34,7 @@ |
|---|
| 328 |
define_method "test_#{action}_action__not_allowed_if_other" do |
|---|
| 329 |
login_as(:existing) |
|---|
| 330 |
get action, { :id => 1 } |
|---|
| 331 |
- assert_redirected_to page_index_url, "action: #{action}" |
|---|
| 332 |
+ assert_redirected_to pages_path, "action: #{action}" |
|---|
| 333 |
assert_match /privileges/, flash[:error], "action: #{action}" |
|---|
| 334 |
end |
|---|
| 335 |
end |
|---|
| 336 |
Index: test/functional/admin/user_controller_test.rb |
|---|
| 337 |
=================================================================== |
|---|
| 338 |
--- test/functional/admin/user_controller_test.rb (revision 588) |
|---|
| 339 |
+++ test/functional/admin/user_controller_test.rb (working copy) |
|---|
| 340 |
@@ -35,7 +35,7 @@ |
|---|
| 341 |
define_method "test_#{action}_action_not_allowed_if_other" do |
|---|
| 342 |
login_as(:non_admin) |
|---|
| 343 |
get action, { :id => 1 } |
|---|
| 344 |
- assert_redirected_to page_index_url, "action: #{action}" |
|---|
| 345 |
+ assert_redirected_to pages_path, "action: #{action}" |
|---|
| 346 |
assert_match /privileges/, flash[:error], "action: #{action}" |
|---|
| 347 |
end |
|---|
| 348 |
end |
|---|
| 349 |
@@ -63,7 +63,7 @@ |
|---|
| 350 |
{ :user => { :password => '', :password_confirmation => '', :email => 'updated@gmail.com' } } |
|---|
| 351 |
) |
|---|
| 352 |
@user = User.find(@user.id) |
|---|
| 353 |
- assert_redirected_to page_index_url |
|---|
| 354 |
+ assert_redirected_to pages_path |
|---|
| 355 |
assert_match /preferences.*?saved/i, flash[:notice] |
|---|
| 356 |
assert_equal 'updated@gmail.com', @user.email |
|---|
| 357 |
end |
|---|
| 358 |
Index: test/functional/admin/abstract_model_controller_test.rb |
|---|
| 359 |
=================================================================== |
|---|
| 360 |
--- test/functional/admin/abstract_model_controller_test.rb (revision 588) |
|---|
| 361 |
+++ test/functional/admin/abstract_model_controller_test.rb (working copy) |
|---|
| 362 |
@@ -86,7 +86,7 @@ |
|---|
| 363 |
end |
|---|
| 364 |
def test_edit__post |
|---|
| 365 |
@layout = create_test_layout |
|---|
| 366 |
- post :edit, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 367 |
+ put :edit, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 368 |
assert_response :redirect |
|---|
| 369 |
assert_equal 'edited', get_test_layout.content |
|---|
| 370 |
|
|---|
| 371 |
Index: test/integration/page_administration_test.rb |
|---|
| 372 |
=================================================================== |
|---|
| 373 |
--- test/integration/page_administration_test.rb (revision 0) |
|---|
| 374 |
+++ test/integration/page_administration_test.rb (revision 0) |
|---|
| 375 |
@@ -0,0 +1,100 @@ |
|---|
| 376 |
+require "#{File.dirname(__FILE__)}/../test_helper" |
|---|
| 377 |
+ |
|---|
| 378 |
+class PageAdministrationTest < ActionController::IntegrationTest |
|---|
| 379 |
+ fixtures :users |
|---|
| 380 |
+ |
|---|
| 381 |
+ test_helper :pages, :page_parts, :caching, :login |
|---|
| 382 |
+ |
|---|
| 383 |
+ |
|---|
| 384 |
+ |
|---|
| 385 |
+ |
|---|
| 386 |
+ # An administrator can log into the CMS and view the index of pages. |
|---|
| 387 |
+ def test_should_show_page_index |
|---|
| 388 |
+ login_for_test |
|---|
| 389 |
+ get "/admin/pages" |
|---|
| 390 |
+ assert_response :success |
|---|
| 391 |
+ end |
|---|
| 392 |
+ |
|---|
| 393 |
+ # There's nothing here, the user will need to create a homepage |
|---|
| 394 |
+ def test_should_create_homepage |
|---|
| 395 |
+ |
|---|
| 396 |
+ # Starting with an empty site |
|---|
| 397 |
+ Page.destroy_all |
|---|
| 398 |
+ |
|---|
| 399 |
+ # We can log in |
|---|
| 400 |
+ login_for_test |
|---|
| 401 |
+ follow_redirect! |
|---|
| 402 |
+ assert_redirected_to pages_path |
|---|
| 403 |
+ follow_redirect! |
|---|
| 404 |
+ |
|---|
| 405 |
+ # And eventually see the page index. |
|---|
| 406 |
+ assert_template "index" |
|---|
| 407 |
+ |
|---|
| 408 |
+ # It's empty |
|---|
| 409 |
+ assert_select "td.note", "No Pages" |
|---|
| 410 |
+ |
|---|
| 411 |
+ # There's a form with homepage defaults prefilled |
|---|
| 412 |
+ get "/admin/pages/homepage" |
|---|
| 413 |
+ assert_template "edit" |
|---|
| 414 |
+ |
|---|
| 415 |
+ # We can create the homepage |
|---|
| 416 |
+ current_page_count = Page.count |
|---|
| 417 |
+ post "/admin/pages", :commit => "Create Page", |
|---|
| 418 |
+ :part => { "0" => { "name" =>"body", "filter_id" => "", "content" => ""}, |
|---|
| 419 |
+ "1" => { "name" =>"extended", "filter_id" => "", "content" => ""}}, |
|---|
| 420 |
+ :page => { :class_name => "Page", |
|---|
| 421 |
+ :slug => "/", |
|---|
| 422 |
+ :title => "New Homepage", |
|---|
| 423 |
+ :breadcrumb => "Home", |
|---|
| 424 |
+ :lock_version => "0", |
|---|
| 425 |
+ :status_id => "1", |
|---|
| 426 |
+ :layout_id => ""} |
|---|
| 427 |
+ |
|---|
| 428 |
+ assert_redirected_to pages_path |
|---|
| 429 |
+ assert_equal(current_page_count + 1, Page.count) |
|---|
| 430 |
+ |
|---|
| 431 |
+ # Default breadcrumb and path values where maintained. |
|---|
| 432 |
+ homepage = Page.find(:first) |
|---|
| 433 |
+ assert_equal("/", homepage.slug) |
|---|
| 434 |
+ assert_equal("Home", homepage.breadcrumb) |
|---|
| 435 |
+ |
|---|
| 436 |
+ # We can go back and edit the homepage |
|---|
| 437 |
+ get "/admin/pages/#{homepage.id}/edit" |
|---|
| 438 |
+ assert_template "edit" |
|---|
| 439 |
+ |
|---|
| 440 |
+ new_title = "Better Homepage" |
|---|
| 441 |
+ put "/admin/pages/#{homepage.id}", :page => { :title => new_title } |
|---|
| 442 |
+ assert_redirected_to pages_path |
|---|
| 443 |
+ assert_equal(new_title, homepage.reload.title) |
|---|
| 444 |
+ end |
|---|
| 445 |
+ |
|---|
| 446 |
+ def test_should_create_child_page |
|---|
| 447 |
+ login_for_test |
|---|
| 448 |
+ |
|---|
| 449 |
+ hp = Page.find(:first) |
|---|
| 450 |
+ get "/admin/pages/#{hp.id}/children/new" |
|---|
| 451 |
+ assert_response :success |
|---|
| 452 |
+ assert_template "edit" |
|---|
| 453 |
+ |
|---|
| 454 |
+ current_page_count = Page.count |
|---|
| 455 |
+ post "/admin/pages/#{hp.id}/children", :commit => "Create Page", |
|---|
| 456 |
+ :part => { "0" => { "name" =>"body", "filter_id" => "", "content" => ""}, |
|---|
| 457 |
+ "1" => { "name" =>"extended", "filter_id" => "", "content" => ""}}, |
|---|
| 458 |
+ :page => { :class_name => "Page", |
|---|
| 459 |
+ :slug => "/", |
|---|
| 460 |
+ :title => "New Child Page", |
|---|
| 461 |
+ :breadcrumb => "Home", |
|---|
| 462 |
+ :lock_version => "0", |
|---|
| 463 |
+ :status_id => "1", |
|---|
| 464 |
+ :layout_id => ""} |
|---|
| 465 |
+ |
|---|
| 466 |
+ assert_redirected_to pages_path |
|---|
| 467 |
+ assert_equal(current_page_count + 1, Page.count) |
|---|
| 468 |
+ |
|---|
| 469 |
+ end |
|---|
| 470 |
+ |
|---|
| 471 |
+ protected |
|---|
| 472 |
+ def login_for_test |
|---|
| 473 |
+ post "/admin/login", 'user' => { :login => 'existing', :password => 'password' } |
|---|
| 474 |
+ end |
|---|
| 475 |
+end |
|---|
| 476 |
Index: app/controllers/admin/welcome_controller.rb |
|---|
| 477 |
=================================================================== |
|---|
| 478 |
--- app/controllers/admin/welcome_controller.rb (revision 588) |
|---|
| 479 |
+++ app/controllers/admin/welcome_controller.rb (working copy) |
|---|
| 480 |
@@ -2,7 +2,7 @@ |
|---|
| 481 |
no_login_required |
|---|
| 482 |
|
|---|
| 483 |
def index |
|---|
| 484 |
- redirect_to page_index_url |
|---|
| 485 |
+ redirect_to pages_path |
|---|
| 486 |
end |
|---|
| 487 |
|
|---|
| 488 |
def login |
|---|
| 489 |
Index: app/controllers/admin/page_controller.rb |
|---|
| 490 |
=================================================================== |
|---|
| 491 |
--- app/controllers/admin/page_controller.rb (revision 588) |
|---|
| 492 |
+++ app/controllers/admin/page_controller.rb (working copy) |
|---|
| 493 |
@@ -1,6 +1,8 @@ |
|---|
| 494 |
class Admin::PageController < Admin::AbstractModelController |
|---|
| 495 |
model_class Page |
|---|
| 496 |
- before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit] |
|---|
| 497 |
+ before_filter :initialize_meta_rows_and_buttons, :only => [:new, :homepage, :edit, :create, :update] |
|---|
| 498 |
+ before_filter :find_parent, :only => [:new, :edit, :create] |
|---|
| 499 |
+ |
|---|
| 500 |
attr_accessor :cache |
|---|
| 501 |
|
|---|
| 502 |
def initialize |
|---|
| 503 |
@@ -9,40 +11,75 @@ |
|---|
| 504 |
end |
|---|
| 505 |
|
|---|
| 506 |
def index |
|---|
| 507 |
- @homepage = Page.find_by_parent_id(nil) |
|---|
| 508 |
+ if request.xhr? |
|---|
| 509 |
+ @parent = Page.find(params[:page_id]) |
|---|
| 510 |
+ @level = params[:level].to_i |
|---|
| 511 |
+ response.headers['Content-Type'] = 'text/html;charset=utf-8' |
|---|
| 512 |
+ render :template => "admin/page/children", :layout => false |
|---|
| 513 |
+ else |
|---|
| 514 |
+ @homepage = Page.find_by_parent_id(nil) |
|---|
| 515 |
+ end |
|---|
| 516 |
end |
|---|
| 517 |
|
|---|
| 518 |
def new |
|---|
| 519 |
@page = request.get? ? Page.new_with_defaults(config) : Page.new |
|---|
| 520 |
@page.slug = params[:slug] |
|---|
| 521 |
@page.breadcrumb = params[:breadcrumb] |
|---|
| 522 |
- @page.parent = Page.find_by_id(params[:parent_id]) |
|---|
| 523 |
+ @page.parent = @parent |
|---|
| 524 |
render :action => :edit if handle_new_or_edit_post |
|---|
| 525 |
end |
|---|
| 526 |
|
|---|
| 527 |
+ def homepage |
|---|
| 528 |
+ @homepage = true |
|---|
| 529 |
+ @page = Page.new_with_defaults(config) |
|---|
| 530 |
+ @page.slug = "/" |
|---|
| 531 |
+ @page.breadcrumb = "Home" |
|---|
| 532 |
+ |
|---|
| 533 |
+ render :action => :edit if handle_new_or_edit_post |
|---|
| 534 |
+ end |
|---|
| 535 |
+ |
|---|
| 536 |
+ def create |
|---|
| 537 |
+ @page = Page.new |
|---|
| 538 |
+ if @parent |
|---|
| 539 |
+ @page.parent = @parent |
|---|
| 540 |
+ else |
|---|
| 541 |
+ @homepage = true |
|---|
| 542 |
+ end |
|---|
| 543 |
+ |
|---|
| 544 |
+ render :action => "edit" if handle_new_or_edit_post |
|---|
| 545 |
+ end |
|---|
| 546 |
+ |
|---|
| 547 |
def edit |
|---|
| 548 |
@page = Page.find(params[:id]) |
|---|
| 549 |
@old_page_url = @page.url |
|---|
| 550 |
+ #TODO: temporary workaround for editing home page |
|---|
| 551 |
+ @homepage = true if @page.parent.nil? |
|---|
| 552 |
handle_new_or_edit_post |
|---|
| 553 |
end |
|---|
| 554 |
|
|---|
| 555 |
+ def update |
|---|
| 556 |
+ @page = Page.find(params[:id]) |
|---|
| 557 |
+ @old_page_url = @page.url |
|---|
| 558 |
+ #TODO: temporary workaround for editing home page |
|---|
| 559 |
+ @homepage = true if @page.parent.nil? |
|---|
| 560 |
+ render :action => "edit" if handle_new_or_edit_post |
|---|
| 561 |
+ end |
|---|
| 562 |
+ |
|---|
| 563 |
def remove |
|---|
| 564 |
@page = Page.find(params[:id]) |
|---|
| 565 |
- if request.post? |
|---|
| 566 |
- announce_pages_removed(@page.children.count + 1) |
|---|
| 567 |
- @page.destroy |
|---|
| 568 |
- redirect_to page_index_url |
|---|
| 569 |
- end |
|---|
| 570 |
end |
|---|
| 571 |
|
|---|
| 572 |
+ def destroy |
|---|
| 573 |
+ @page = Page.find(params[:id]) |
|---|
| 574 |
+ announce_pages_removed(@page.children.count + 1) |
|---|
| 575 |
+ @page.destroy |
|---|
| 576 |
+ redirect_to pages_path |
|---|
| 577 |
+ end |
|---|
| 578 |
+ |
|---|
| 579 |
def clear_cache |
|---|
| 580 |
- if request.post? |
|---|
| 581 |
- @cache.clear |
|---|
| 582 |
- announce_cache_cleared |
|---|
| 583 |
- redirect_to page_index_url |
|---|
| 584 |
- else |
|---|
| 585 |
- render :text => 'Do not access this URL directly.' |
|---|
| 586 |
- end |
|---|
| 587 |
+ @cache.clear |
|---|
| 588 |
+ announce_cache_cleared |
|---|
| 589 |
+ redirect_to pages_path |
|---|
| 590 |
end |
|---|
| 591 |
|
|---|
| 592 |
def add_part |
|---|
| 593 |
@@ -51,13 +88,6 @@ |
|---|
| 594 |
render(:partial => 'part', :object => part, :layout => false) |
|---|
| 595 |
end |
|---|
| 596 |
|
|---|
| 597 |
- def children |
|---|
| 598 |
- @parent = Page.find(params[:id]) |
|---|
| 599 |
- @level = params[:level].to_i |
|---|
| 600 |
- response.headers['Content-Type'] = 'text/html;charset=utf-8' |
|---|
| 601 |
- render(:layout => false) |
|---|
| 602 |
- end |
|---|
| 603 |
- |
|---|
| 604 |
def tag_reference |
|---|
| 605 |
@class_name = params[:class_name] |
|---|
| 606 |
@display_name = @class_name.constantize.display_name |
|---|
| 607 |
@@ -93,6 +123,10 @@ |
|---|
| 608 |
@meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]} |
|---|
| 609 |
end |
|---|
| 610 |
|
|---|
| 611 |
+ def find_parent |
|---|
| 612 |
+ @parent = Page.find_by_id(params[:page_id]) |
|---|
| 613 |
+ end |
|---|
| 614 |
+ |
|---|
| 615 |
def save |
|---|
| 616 |
parts = @page.parts |
|---|
| 617 |
parts_to_update = {} |
|---|
| 618 |
Index: app/controllers/admin/user_controller.rb |
|---|
| 619 |
=================================================================== |
|---|
| 620 |
--- app/controllers/admin/user_controller.rb (revision 588) |
|---|
| 621 |
+++ app/controllers/admin/user_controller.rb (working copy) |
|---|
| 622 |
@@ -10,7 +10,7 @@ |
|---|
| 623 |
@user = current_user |
|---|
| 624 |
if valid_params? |
|---|
| 625 |
handle_new_or_edit_post( |
|---|
| 626 |
- :redirect_to => page_index_url, |
|---|
| 627 |
+ :redirect_to => pages_path, |
|---|
| 628 |
:saved_message => 'Your preferences have been saved.' |
|---|
| 629 |
) |
|---|
| 630 |
else |
|---|
| 631 |
Index: app/controllers/admin/abstract_model_controller.rb |
|---|
| 632 |
=================================================================== |
|---|
| 633 |
--- app/controllers/admin/abstract_model_controller.rb (revision 588) |
|---|
| 634 |
+++ app/controllers/admin/abstract_model_controller.rb (working copy) |
|---|
| 635 |
@@ -73,11 +73,21 @@ |
|---|
| 636 |
end |
|---|
| 637 |
|
|---|
| 638 |
def model_index_url(params = {}) |
|---|
| 639 |
- send("#{ model_symbol }_index_url", params) |
|---|
| 640 |
+ # FIXME: temporary solution until AbstractModelController is fully RESTive |
|---|
| 641 |
+ if ["Page"].include?(model_name) |
|---|
| 642 |
+ send(model_name.downcase.pluralize + "_path", params) |
|---|
| 643 |
+ else |
|---|
| 644 |
+ send("#{ model_symbol }_index_url", params) |
|---|
| 645 |
+ end |
|---|
| 646 |
end |
|---|
| 647 |
|
|---|
| 648 |
def model_edit_url(params = {}) |
|---|
| 649 |
- send("#{ model_symbol }_edit_url", params) |
|---|
| 650 |
+ # FIXME: temporary solution until AbstractModelController is fully RESTive |
|---|
| 651 |
+ if ["Page"].include?(model_name) |
|---|
| 652 |
+ send("edit_" + model_name.downcase + "_path", params) |
|---|
| 653 |
+ else |
|---|
| 654 |
+ send("#{ model_symbol }_edit_url", params) |
|---|
| 655 |
+ end |
|---|
| 656 |
end |
|---|
| 657 |
|
|---|
| 658 |
def continue_url(options) |
|---|
| 659 |
@@ -98,20 +108,21 @@ |
|---|
| 660 |
|
|---|
| 661 |
def announce_removed |
|---|
| 662 |
flash[:notice] = "#{humanized_model_name} has been deleted." |
|---|
| 663 |
- end |
|---|
| 664 |
- |
|---|
| 665 |
- def announce_update_conflict |
|---|
| 666 |
- flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data." |
|---|
| 667 |
- end |
|---|
| 668 |
- |
|---|
| 669 |
- def clear_model_cache |
|---|
| 670 |
- cache.clear |
|---|
| 671 |
end |
|---|
| 672 |
|
|---|
| 673 |
+ def announce_update_conflict |
|---|
| 674 |
+ flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data." |
|---|
| 675 |
+ end |
|---|
| 676 |
+ |
|---|
| 677 |
+ def clear_model_cache |
|---|
| 678 |
+ cache.clear |
|---|
| 679 |
+ end |
|---|
| 680 |
+ |
|---|
| 681 |
def handle_new_or_edit_post(options = {}) |
|---|
| 682 |
options.symbolize_keys |
|---|
| 683 |
- if request.post? |
|---|
| 684 |
- model.attributes = params[model_symbol] |
|---|
| 685 |
+ if request.post? || request.put? |
|---|
| 686 |
+ |
|---|
| 687 |
+ model.attributes = params[model_symbol] |
|---|
| 688 |
begin |
|---|
| 689 |
if save |
|---|
| 690 |
clear_model_cache |
|---|
| 691 |
@@ -120,9 +131,9 @@ |
|---|
| 692 |
return false |
|---|
| 693 |
else |
|---|
| 694 |
announce_validation_errors |
|---|
| 695 |
- end |
|---|
| 696 |
- rescue ActiveRecord::StaleObjectError |
|---|
| 697 |
- announce_update_conflict |
|---|
| 698 |
+ end |
|---|
| 699 |
+ rescue ActiveRecord::StaleObjectError |
|---|
| 700 |
+ announce_update_conflict |
|---|
| 701 |
end |
|---|
| 702 |
end |
|---|
| 703 |
true |
|---|
| 704 |
Index: app/views/admin/page/remove.rhtml |
|---|
| 705 |
=================================================================== |
|---|
| 706 |
--- app/views/admin/page/remove.rhtml (revision 588) |
|---|
| 707 |
+++ app/views/admin/page/remove.rhtml (working copy) |
|---|
| 708 |
@@ -10,5 +10,5 @@ |
|---|
| 709 |
</table> |
|---|
| 710 |
|
|---|
| 711 |
<form method="post" action=""> |
|---|
| 712 |
- <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', page_index_url %></p> |
|---|
| 713 |
+ <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', pages_path %></p> |
|---|
| 714 |
</form> |
|---|
| 715 |
Index: app/views/admin/page/_node.rhtml |
|---|
| 716 |
=================================================================== |
|---|
| 717 |
--- app/views/admin/page/_node.rhtml (revision 588) |
|---|
| 718 |
+++ app/views/admin/page/_node.rhtml (working copy) |
|---|
| 719 |
@@ -26,7 +26,7 @@ |
|---|
| 720 |
<%= icon %> |
|---|
| 721 |
<%= title %> |
|---|
| 722 |
<% else -%> |
|---|
| 723 |
- <%= expander %><a href="<%= page_edit_url(:id => page) %>" title="<%= page.url %>"><%= icon %> <%= title %></a> |
|---|
| 724 |
+ <%= expander %><a href="<%= edit_page_path(page) %>" title="<%= page.url %>"><%= icon %> <%= title %></a> |
|---|
| 725 |
<%= page_type %> |
|---|
| 726 |
<%= spinner %> |
|---|
| 727 |
<% end -%> |
|---|
| 728 |
@@ -34,8 +34,8 @@ |
|---|
| 729 |
</td> |
|---|
| 730 |
<% unless simple -%> |
|---|
| 731 |
<td class="status <%= page.status.name.downcase %>-status"><%= page.status.name %></td> |
|---|
| 732 |
- <td class="add-child"><%= link_to image('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %></td> |
|---|
| 733 |
- <td class="remove"><%= link_to image('remove', :alt => 'remove page'), page_remove_url(:id => page) %></td> |
|---|
| 734 |
+ <td class="add-child"><%= link_to image('add-child', :alt => 'add child'), new_page_child_path(page) %></td> |
|---|
| 735 |
+ <td class="remove"><%= link_to image('remove', :alt => 'remove page'), page_path(page), :method => 'delete' %></td> |
|---|
| 736 |
<% end -%> |
|---|
| 737 |
</tr> |
|---|
| 738 |
<% level = level + 1 -%> |
|---|
| 739 |
Index: app/views/admin/page/edit.rhtml |
|---|
| 740 |
=================================================================== |
|---|
| 741 |
--- app/views/admin/page/edit.rhtml (revision 588) |
|---|
| 742 |
+++ app/views/admin/page/edit.rhtml (working copy) |
|---|
| 743 |
@@ -4,7 +4,7 @@ |
|---|
| 744 |
page_type = $F('page_class_name'); |
|---|
| 745 |
popup = $('tag-reference-popup'); |
|---|
| 746 |
if(last_type != page_type) { |
|---|
| 747 |
- url = "<%= tag_reference_url %>"; |
|---|
| 748 |
+ url = "<%= tag_reference_pages_path %>"; |
|---|
| 749 |
params = "class_name=" + page_type; |
|---|
| 750 |
new Effect.Highlight('tag-reference-link-'+ part); |
|---|
| 751 |
req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true }); |
|---|
| 752 |
@@ -19,7 +19,7 @@ |
|---|
| 753 |
filter_type = $F("part_" + part + "_filter_id"); |
|---|
| 754 |
popup = $('filter-reference-popup'); |
|---|
| 755 |
if(last_filter != filter_type) { |
|---|
| 756 |
- url = "<%= filter_reference_url %>"; |
|---|
| 757 |
+ url = "<%= filter_reference_pages_path %>"; |
|---|
| 758 |
params = "filter_name=" + filter_type; |
|---|
| 759 |
new Effect.Highlight('filter-reference-link-'+ part); |
|---|
| 760 |
req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true }); |
|---|
| 761 |
@@ -50,11 +50,14 @@ |
|---|
| 762 |
<% include_javascript "tag_reference_search" %> |
|---|
| 763 |
<% if @page.new_record? -%> |
|---|
| 764 |
<h1 id="new_page">New Page</h1> |
|---|
| 765 |
+<%= form_tag(@homepage ? pages_path : page_children_path(:page_id => @parent), :multipart => true) %> |
|---|
| 766 |
+ |
|---|
| 767 |
<% else -%> |
|---|
| 768 |
<h1 id="edit_page">Edit Page</h1> |
|---|
| 769 |
+<%= form_tag(page_path(@page), :method => "put", :multipart => true) %> |
|---|
| 770 |
+ |
|---|
| 771 |
<% end -%> |
|---|
| 772 |
|
|---|
| 773 |
-<form method="post" action="" enctype="multipart/form-data"> |
|---|
| 774 |
<%= hidden_field "page", "lock_version" %> |
|---|
| 775 |
<div class="form-area"> |
|---|
| 776 |
<p class="title"> |
|---|
| 777 |
@@ -66,7 +69,7 @@ |
|---|
| 778 |
<% for meta in @meta %> |
|---|
| 779 |
<%= render :partial => "meta_row", :object => meta %> |
|---|
| 780 |
<% end %> |
|---|
| 781 |
- </table> |
|---|
| 782 |
+ </table> |
|---|
| 783 |
</div> |
|---|
| 784 |
<p class="more-or-less"> |
|---|
| 785 |
<small> |
|---|
| 786 |
@@ -85,7 +88,7 @@ |
|---|
| 787 |
<%= render :partial => 'part', :collection => @page.parts %> |
|---|
| 788 |
</div> |
|---|
| 789 |
</div> |
|---|
| 790 |
- |
|---|
| 791 |
+ |
|---|
| 792 |
<div class="row"> |
|---|
| 793 |
<p><label for="page_layout_id">Layout</label> |
|---|
| 794 |
<%= select "page", "layout_id", [['<inherit>', '']] + Layout.find(:all).map { |s| [s.name, s.id] } %></p> |
|---|
| 795 |
@@ -101,7 +104,7 @@ |
|---|
| 796 |
<%= render :partial => partial %> |
|---|
| 797 |
<% end %> |
|---|
| 798 |
<p class="buttons"> |
|---|
| 799 |
- <%= save_model_button(@page) %> <%= save_model_and_continue_editing_button(@page) %> or <%= link_to "Cancel", page_index_url %> |
|---|
| 800 |
+ <%= save_model_button(@page) %> <%= save_model_and_continue_editing_button(@page) %> or <%= link_to "Cancel", pages_path %> |
|---|
| 801 |
</p> |
|---|
| 802 |
</form> |
|---|
| 803 |
|
|---|
| 804 |
@@ -109,8 +112,10 @@ |
|---|
| 805 |
<div class="popup" id="add-part-popup" style="display: none"> |
|---|
| 806 |
<div id="busy" class="busy" style="display: none"><%= image 'spinner.gif' %></div> |
|---|
| 807 |
<h3>Add Part</h3> |
|---|
| 808 |
+ <%# FIXME: this should be a POST request, placeholder for routing change. %> |
|---|
| 809 |
<% form_remote_tag( |
|---|
| 810 |
- :url => page_add_part_url, |
|---|
| 811 |
+ :url => add_part_pages_path, |
|---|
| 812 |
+ :method => "get", |
|---|
| 813 |
:update => "pages", |
|---|
| 814 |
:position => :bottom, |
|---|
| 815 |
:loading => 'part_loading()', |
|---|
| 816 |
@@ -137,4 +142,4 @@ |
|---|
| 817 |
<div id="filter-reference"><%= filter_reference(default_filter_name) %></div> |
|---|
| 818 |
<p><%= link_to_function 'Close', "Element.hide('filter-reference-popup')", :class => 'close-link' %></p> |
|---|
| 819 |
</div> |
|---|
| 820 |
-<% end -%> |
|---|
| 821 |
+<% end -%> |
|---|
| 822 |
Index: app/views/admin/page/index.rhtml |
|---|
| 823 |
=================================================================== |
|---|
| 824 |
--- app/views/admin/page/index.rhtml (revision 588) |
|---|
| 825 |
+++ app/views/admin/page/index.rhtml (working copy) |
|---|
| 826 |
@@ -21,11 +21,11 @@ |
|---|
| 827 |
</tbody> |
|---|
| 828 |
</table> |
|---|
| 829 |
|
|---|
| 830 |
-<form action="<%= clear_cache_url %>" method="post"> |
|---|
| 831 |
+<% form_tag(clear_cache_pages_path, :method => "delete") do %> |
|---|
| 832 |
<p> |
|---|
| 833 |
<% unless @homepage -%> |
|---|
| 834 |
- <%= link_to image('new-homepage', :alt => 'New Homepage'), homepage_new_url %> |
|---|
| 835 |
+ <%= link_to image('new-homepage', :alt => 'New Homepage'), homepage_pages_path %> |
|---|
| 836 |
<% end -%> |
|---|
| 837 |
<%= image_submit 'clear-page-cache' %> |
|---|
| 838 |
</p> |
|---|
| 839 |
-</form> |
|---|
| 840 |
+<% end -%> |
|---|
| 841 |
Index: config/routes.rb |
|---|
| 842 |
=================================================================== |
|---|
| 843 |
--- config/routes.rb (revision 588) |
|---|
| 844 |
+++ config/routes.rb (working copy) |
|---|
| 845 |
@@ -15,17 +15,15 @@ |
|---|
| 846 |
end |
|---|
| 847 |
|
|---|
| 848 |
# Page Routes |
|---|
| 849 |
- map.with_options(:controller => 'admin/page') do |page| |
|---|
| 850 |
- page.page_index 'admin/pages', :action => 'index' |
|---|
| 851 |
- page.page_edit 'admin/pages/edit/:id', :action => 'edit' |
|---|
| 852 |
- page.page_new 'admin/pages/:parent_id/child/new', :action => 'new' |
|---|
| 853 |
- page.homepage_new 'admin/pages/new/homepage', :action => 'new', :slug => '/', :breadcrumb => 'Home' |
|---|
| 854 |
- page.page_remove 'admin/pages/remove/:id', :action => 'remove' |
|---|
| 855 |
- page.page_add_part 'admin/ui/pages/part/add', :action => 'add_part' |
|---|
| 856 |
- page.page_children 'admin/ui/pages/children/:id/:level', :action => 'children', :level => '1' |
|---|
| 857 |
- page.tag_reference 'admin/ui/pages/tag_reference', :action => 'tag_reference' |
|---|
| 858 |
- page.filter_reference 'admin/ui/pages/filter_reference', :action => 'filter_reference' |
|---|
| 859 |
- page.clear_cache 'admin/pages/cache/clear', :action => 'clear_cache' |
|---|
| 860 |
+ map.resources :pages, :path_prefix => "/admin", |
|---|
| 861 |
+ :controller => "admin/page", |
|---|
| 862 |
+ :collection => {:homepage => :get, |
|---|
| 863 |
+ :tag_reference => :get, |
|---|
| 864 |
+ :filter_reference => :get, |
|---|
| 865 |
+ :remove => :get, |
|---|
| 866 |
+ :add_part => :get, |
|---|
| 867 |
+ :clear_cache => :delete} do |page| |
|---|
| 868 |
+ page.resources :children, :controller => "admin/page" |
|---|
| 869 |
end |
|---|
| 870 |
|
|---|
| 871 |
# Layouts Routes |
|---|
| 872 |
@@ -69,4 +67,4 @@ |
|---|
| 873 |
site.connect '*url', :action => 'show_page' |
|---|
| 874 |
end |
|---|
| 875 |
|
|---|
| 876 |
-end |
|---|
| 877 |
\ No newline at end of file |
|---|
| 878 |
+end |
|---|
| 879 |
Index: public/javascripts/sitemap.js |
|---|
| 880 |
=================================================================== |
|---|
| 881 |
--- public/javascripts/sitemap.js (revision 588) |
|---|
| 882 |
+++ public/javascripts/sitemap.js (working copy) |
|---|
| 883 |
@@ -113,8 +113,9 @@ |
|---|
| 884 |
|
|---|
| 885 |
new Ajax.Updater( |
|---|
| 886 |
row, |
|---|
| 887 |
- '../admin/ui/pages/children/' + id + '/' + level, |
|---|
| 888 |
+ '/admin/pages/' + id + '/children?level=' + level, |
|---|
| 889 |
{ |
|---|
| 890 |
+ method: "get", |
|---|
| 891 |
insertion: "after", |
|---|
| 892 |
onLoading: function() { spinner.show(); this.updating = true }.bind(this), |
|---|
| 893 |
onComplete: function() { spinner.fade(); this.updating = false }.bind(this) |
|---|