| 1 |
Index: test/functional/admin/welcome_controller_test.rb |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- test/functional/admin/welcome_controller_test.rb (revision 602) |
|---|
| 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 602) |
|---|
| 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 602) |
|---|
| 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 602) |
|---|
| 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 |
@@ -44,7 +44,7 @@ |
|---|
| 350 |
@user = users(:admin) |
|---|
| 351 |
login_as(@user) |
|---|
| 352 |
get :remove, { :id => @user.id } |
|---|
| 353 |
- assert_redirected_to user_index_url |
|---|
| 354 |
+ assert_redirected_to users_path |
|---|
| 355 |
assert_match /cannot.*self/i, flash[:error] |
|---|
| 356 |
assert_not_nil User.find(@user.id) |
|---|
| 357 |
end |
|---|
| 358 |
@@ -63,7 +63,7 @@ |
|---|
| 359 |
{ :user => { :password => '', :password_confirmation => '', :email => 'updated@gmail.com' } } |
|---|
| 360 |
) |
|---|
| 361 |
@user = User.find(@user.id) |
|---|
| 362 |
- assert_redirected_to page_index_url |
|---|
| 363 |
+ assert_redirected_to pages_path |
|---|
| 364 |
assert_match /preferences.*?saved/i, flash[:notice] |
|---|
| 365 |
assert_equal 'updated@gmail.com', @user.email |
|---|
| 366 |
end |
|---|
| 367 |
Index: test/functional/admin/abstract_model_controller_test.rb |
|---|
| 368 |
=================================================================== |
|---|
| 369 |
--- test/functional/admin/abstract_model_controller_test.rb (revision 602) |
|---|
| 370 |
+++ test/functional/admin/abstract_model_controller_test.rb (working copy) |
|---|
| 371 |
@@ -58,22 +58,23 @@ |
|---|
| 372 |
assert_kind_of Layout, @layout |
|---|
| 373 |
assert_nil @layout.name |
|---|
| 374 |
end |
|---|
| 375 |
- def test_new__post |
|---|
| 376 |
- post :new, :layout => layout_params |
|---|
| 377 |
- assert_redirected_to layout_index_url |
|---|
| 378 |
+ |
|---|
| 379 |
+ def test_create |
|---|
| 380 |
+ post :create, :layout => layout_params |
|---|
| 381 |
+ assert_redirected_to layouts_path |
|---|
| 382 |
assert_match /saved/, flash[:notice] |
|---|
| 383 |
assert_kind_of Layout, get_test_layout |
|---|
| 384 |
end |
|---|
| 385 |
- def test_new__post_with_invalid_layout |
|---|
| 386 |
- post :new, :layout => layout_params(:name => nil) |
|---|
| 387 |
+ def test_create__with_invalid_layout |
|---|
| 388 |
+ post :create, :layout => layout_params(:name => nil) |
|---|
| 389 |
assert_response :success |
|---|
| 390 |
assert_match /error/, flash[:error] |
|---|
| 391 |
assert_nil get_test_layout |
|---|
| 392 |
end |
|---|
| 393 |
- def test_new__save_and_continue_editing |
|---|
| 394 |
- post :new, :layout => layout_params, :continue => 'Save and Continue Editing' |
|---|
| 395 |
+ def test_create__save_and_continue_editing |
|---|
| 396 |
+ post :create, :layout => layout_params, :continue => 'Save and Continue Editing' |
|---|
| 397 |
@layout = get_test_layout |
|---|
| 398 |
- assert_redirected_to layout_edit_url(:id => @layout.id) |
|---|
| 399 |
+ assert_redirected_to edit_layout_path(@layout) |
|---|
| 400 |
end |
|---|
| 401 |
|
|---|
| 402 |
def test_edit |
|---|
| 403 |
@@ -84,9 +85,10 @@ |
|---|
| 404 |
assert_kind_of Layout, @layout |
|---|
| 405 |
assert_equal 'Home Page', @layout.name |
|---|
| 406 |
end |
|---|
| 407 |
- def test_edit__post |
|---|
| 408 |
+ |
|---|
| 409 |
+ def test_update |
|---|
| 410 |
@layout = create_test_layout |
|---|
| 411 |
- post :edit, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 412 |
+ put :update, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 413 |
assert_response :redirect |
|---|
| 414 |
assert_equal 'edited', get_test_layout.content |
|---|
| 415 |
|
|---|
| 416 |
@@ -100,24 +102,25 @@ |
|---|
| 417 |
assert_equal @layout, assigns(:layout) |
|---|
| 418 |
assert_not_nil get_test_layout |
|---|
| 419 |
end |
|---|
| 420 |
- def test_remove__post |
|---|
| 421 |
+ |
|---|
| 422 |
+ def test_destroy |
|---|
| 423 |
@layout = create_test_layout |
|---|
| 424 |
- post :remove, :id => @layout.id |
|---|
| 425 |
+ delete :destroy, :id => @layout.id |
|---|
| 426 |
assert_nil get_test_layout |
|---|
| 427 |
- assert_redirected_to layout_index_url |
|---|
| 428 |
+ assert_redirected_to layouts_path |
|---|
| 429 |
assert_match /deleted/, flash[:notice] |
|---|
| 430 |
end |
|---|
| 431 |
|
|---|
| 432 |
def test_clears_cache_on_save |
|---|
| 433 |
@layout = layouts(:main) |
|---|
| 434 |
- post :edit, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 435 |
- assert_redirected_to layout_index_url |
|---|
| 436 |
+ put :update, :id => @layout.id, :layout => layout_params(:content => 'edited') |
|---|
| 437 |
+ assert_redirected_to layouts_path |
|---|
| 438 |
assert_equal true, @cache.cleared? |
|---|
| 439 |
end |
|---|
| 440 |
|
|---|
| 441 |
def test_not_cleared_when_invalid |
|---|
| 442 |
@layout = layouts(:main) |
|---|
| 443 |
- post :edit, :id => @layout.id, :layout => layout_params(:name => 'x' * 1000) |
|---|
| 444 |
+ put :update, :id => @layout.id, :layout => layout_params(:name => 'x' * 1000) |
|---|
| 445 |
assert_response :success |
|---|
| 446 |
assert_equal false, @cache.cleared? |
|---|
| 447 |
end |
|---|
| 448 |
Index: test/integration/page_administration_test.rb |
|---|
| 449 |
=================================================================== |
|---|
| 450 |
--- test/integration/page_administration_test.rb (revision 0) |
|---|
| 451 |
+++ test/integration/page_administration_test.rb (revision 0) |
|---|
| 452 |
@@ -0,0 +1,100 @@ |
|---|
| 453 |
+require "#{File.dirname(__FILE__)}/../test_helper" |
|---|
| 454 |
+ |
|---|
| 455 |
+class PageAdministrationTest < ActionController::IntegrationTest |
|---|
| 456 |
+ fixtures :users |
|---|
| 457 |
+ |
|---|
| 458 |
+ test_helper :pages, :page_parts, :caching, :login |
|---|
| 459 |
+ |
|---|
| 460 |
+ |
|---|
| 461 |
+ |
|---|
| 462 |
+ |
|---|
| 463 |
+ # An administrator can log into the CMS and view the index of pages. |
|---|
| 464 |
+ def test_should_show_page_index |
|---|
| 465 |
+ login_for_test |
|---|
| 466 |
+ get "/admin/pages" |
|---|
| 467 |
+ assert_response :success |
|---|
| 468 |
+ end |
|---|
| 469 |
+ |
|---|
| 470 |
+ # There's nothing here, the user will need to create a homepage |
|---|
| 471 |
+ def test_should_create_homepage |
|---|
| 472 |
+ |
|---|
| 473 |
+ # Starting with an empty site |
|---|
| 474 |
+ Page.destroy_all |
|---|
| 475 |
+ |
|---|
| 476 |
+ # We can log in |
|---|
| 477 |
+ login_for_test |
|---|
| 478 |
+ follow_redirect! |
|---|
| 479 |
+ assert_redirected_to pages_path |
|---|
| 480 |
+ follow_redirect! |
|---|
| 481 |
+ |
|---|
| 482 |
+ # And eventually see the page index. |
|---|
| 483 |
+ assert_template "index" |
|---|
| 484 |
+ |
|---|
| 485 |
+ # It's empty |
|---|
| 486 |
+ assert_select "td.note", "No Pages" |
|---|
| 487 |
+ |
|---|
| 488 |
+ # There's a form with homepage defaults prefilled |
|---|
| 489 |
+ get "/admin/pages/homepage" |
|---|
| 490 |
+ assert_template "edit" |
|---|
| 491 |
+ |
|---|
| 492 |
+ # We can create the homepage |
|---|
| 493 |
+ current_page_count = Page.count |
|---|
| 494 |
+ post "/admin/pages", :commit => "Create Page", |
|---|
| 495 |
+ :part => { "0" => { "name" =>"body", "filter_id" => "", "content" => ""}, |
|---|
| 496 |
+ "1" => { "name" =>"extended", "filter_id" => "", "content" => ""}}, |
|---|
| 497 |
+ :page => { :class_name => "Page", |
|---|
| 498 |
+ :slug => "/", |
|---|
| 499 |
+ :title => "New Homepage", |
|---|
| 500 |
+ :breadcrumb => "Home", |
|---|
| 501 |
+ :lock_version => "0", |
|---|
| 502 |
+ :status_id => "1", |
|---|
| 503 |
+ :layout_id => ""} |
|---|
| 504 |
+ |
|---|
| 505 |
+ assert_redirected_to pages_path |
|---|
| 506 |
+ assert_equal(current_page_count + 1, Page.count) |
|---|
| 507 |
+ |
|---|
| 508 |
+ # Default breadcrumb and path values where maintained. |
|---|
| 509 |
+ homepage = Page.find(:first) |
|---|
| 510 |
+ assert_equal("/", homepage.slug) |
|---|
| 511 |
+ assert_equal("Home", homepage.breadcrumb) |
|---|
| 512 |
+ |
|---|
| 513 |
+ # We can go back and edit the homepage |
|---|
| 514 |
+ get "/admin/pages/#{homepage.id}/edit" |
|---|
| 515 |
+ assert_template "edit" |
|---|
| 516 |
+ |
|---|
| 517 |
+ new_title = "Better Homepage" |
|---|
| 518 |
+ put "/admin/pages/#{homepage.id}", :page => { :title => new_title } |
|---|
| 519 |
+ assert_redirected_to pages_path |
|---|
| 520 |
+ assert_equal(new_title, homepage.reload.title) |
|---|
| 521 |
+ end |
|---|
| 522 |
+ |
|---|
| 523 |
+ def test_should_create_child_page |
|---|
| 524 |
+ login_for_test |
|---|
| 525 |
+ |
|---|
| 526 |
+ hp = Page.find(:first) |
|---|
| 527 |
+ get "/admin/pages/#{hp.id}/children/new" |
|---|
| 528 |
+ assert_response :success |
|---|
| 529 |
+ assert_template "edit" |
|---|
| 530 |
+ |
|---|
| 531 |
+ current_page_count = Page.count |
|---|
| 532 |
+ post "/admin/pages/#{hp.id}/children", :commit => "Create Page", |
|---|
| 533 |
+ :part => { "0" => { "name" =>"body", "filter_id" => "", "content" => ""}, |
|---|
| 534 |
+ "1" => { "name" =>"extended", "filter_id" => "", "content" => ""}}, |
|---|
| 535 |
+ :page => { :class_name => "Page", |
|---|
| 536 |
+ :slug => "/", |
|---|
| 537 |
+ :title => "New Child Page", |
|---|
| 538 |
+ :breadcrumb => "Home", |
|---|
| 539 |
+ :lock_version => "0", |
|---|
| 540 |
+ :status_id => "1", |
|---|
| 541 |
+ :layout_id => ""} |
|---|
| 542 |
+ |
|---|
| 543 |
+ assert_redirected_to pages_path |
|---|
| 544 |
+ assert_equal(current_page_count + 1, Page.count) |
|---|
| 545 |
+ |
|---|
| 546 |
+ end |
|---|
| 547 |
+ |
|---|
| 548 |
+ protected |
|---|
| 549 |
+ def login_for_test |
|---|
| 550 |
+ post "/admin/login", 'user' => { :login => 'existing', :password => 'password' } |
|---|
| 551 |
+ end |
|---|
| 552 |
+end |
|---|
| 553 |
Index: app/controllers/admin/welcome_controller.rb |
|---|
| 554 |
=================================================================== |
|---|
| 555 |
--- app/controllers/admin/welcome_controller.rb (revision 602) |
|---|
| 556 |
+++ app/controllers/admin/welcome_controller.rb (working copy) |
|---|
| 557 |
@@ -2,7 +2,7 @@ |
|---|
| 558 |
no_login_required |
|---|
| 559 |
|
|---|
| 560 |
def index |
|---|
| 561 |
- redirect_to page_index_url |
|---|
| 562 |
+ redirect_to pages_path |
|---|
| 563 |
end |
|---|
| 564 |
|
|---|
| 565 |
def login |
|---|
| 566 |
Index: app/controllers/admin/page_controller.rb |
|---|
| 567 |
=================================================================== |
|---|
| 568 |
--- app/controllers/admin/page_controller.rb (revision 602) |
|---|
| 569 |
+++ app/controllers/admin/page_controller.rb (working copy) |
|---|
| 570 |
@@ -1,6 +1,8 @@ |
|---|
| 571 |
class Admin::PageController < Admin::AbstractModelController |
|---|
| 572 |
model_class Page |
|---|
| 573 |
- before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit] |
|---|
| 574 |
+ before_filter :initialize_meta_rows_and_buttons, :only => [:new, :homepage, :edit, :create, :update] |
|---|
| 575 |
+ before_filter :find_parent, :only => [:new, :edit, :create] |
|---|
| 576 |
+ |
|---|
| 577 |
attr_accessor :cache |
|---|
| 578 |
|
|---|
| 579 |
def initialize |
|---|
| 580 |
@@ -9,40 +11,75 @@ |
|---|
| 581 |
end |
|---|
| 582 |
|
|---|
| 583 |
def index |
|---|
| 584 |
- @homepage = Page.find_by_parent_id(nil) |
|---|
| 585 |
+ if request.xhr? |
|---|
| 586 |
+ @parent = Page.find(params[:page_id]) |
|---|
| 587 |
+ @level = params[:level].to_i |
|---|
| 588 |
+ response.headers['Content-Type'] = 'text/html;charset=utf-8' |
|---|
| 589 |
+ render :template => "admin/page/children", :layout => false |
|---|
| 590 |
+ else |
|---|
| 591 |
+ @homepage = Page.find_by_parent_id(nil) |
|---|
| 592 |
+ end |
|---|
| 593 |
end |
|---|
| 594 |
|
|---|
| 595 |
def new |
|---|
| 596 |
@page = request.get? ? Page.new_with_defaults(config) : Page.new |
|---|
| 597 |
@page.slug = params[:slug] |
|---|
| 598 |
@page.breadcrumb = params[:breadcrumb] |
|---|
| 599 |
- @page.parent = Page.find_by_id(params[:parent_id]) |
|---|
| 600 |
+ @page.parent = @parent |
|---|
| 601 |
render :action => :edit if handle_new_or_edit_post |
|---|
| 602 |
end |
|---|
| 603 |
|
|---|
| 604 |
+ def homepage |
|---|
| 605 |
+ @homepage = true |
|---|
| 606 |
+ @page = Page.new_with_defaults(config) |
|---|
| 607 |
+ @page.slug = "/" |
|---|
| 608 |
+ @page.breadcrumb = "Home" |
|---|
| 609 |
+ |
|---|
| 610 |
+ render :action => :edit if handle_new_or_edit_post |
|---|
| 611 |
+ end |
|---|
| 612 |
+ |
|---|
| 613 |
+ def create |
|---|
| 614 |
+ @page = Page.new |
|---|
| 615 |
+ if @parent |
|---|
| 616 |
+ @page.parent = @parent |
|---|
| 617 |
+ else |
|---|
| 618 |
+ @homepage = true |
|---|
| 619 |
+ end |
|---|
| 620 |
+ |
|---|
| 621 |
+ render :action => "edit" if handle_new_or_edit_post |
|---|
| 622 |
+ end |
|---|
| 623 |
+ |
|---|
| 624 |
def edit |
|---|
| 625 |
@page = Page.find(params[:id]) |
|---|
| 626 |
@old_page_url = @page.url |
|---|
| 627 |
+ #TODO: temporary workaround for editing home page |
|---|
| 628 |
+ @homepage = true if @page.parent.nil? |
|---|
| 629 |
handle_new_or_edit_post |
|---|
| 630 |
end |
|---|
| 631 |
|
|---|
| 632 |
+ def update |
|---|
| 633 |
+ @page = Page.find(params[:id]) |
|---|
| 634 |
+ @old_page_url = @page.url |
|---|
| 635 |
+ #TODO: temporary workaround for editing home page |
|---|
| 636 |
+ @homepage = true if @page.parent.nil? |
|---|
| 637 |
+ render :action => "edit" if handle_new_or_edit_post |
|---|
| 638 |
+ end |
|---|
| 639 |
+ |
|---|
| 640 |
def remove |
|---|
| 641 |
@page = Page.find(params[:id]) |
|---|
| 642 |
- if request.post? |
|---|
| 643 |
- announce_pages_removed(@page.children.count + 1) |
|---|
| 644 |
- @page.destroy |
|---|
| 645 |
- redirect_to page_index_url |
|---|
| 646 |
- end |
|---|
| 647 |
end |
|---|
| 648 |
|
|---|
| 649 |
+ def destroy |
|---|
| 650 |
+ @page = Page.find(params[:id]) |
|---|
| 651 |
+ announce_pages_removed(@page.children.count + 1) |
|---|
| 652 |
+ @page.destroy |
|---|
| 653 |
+ redirect_to pages_path |
|---|
| 654 |
+ end |
|---|
| 655 |
+ |
|---|
| 656 |
def clear_cache |
|---|
| 657 |
- if request.post? |
|---|
| 658 |
- @cache.clear |
|---|
| 659 |
- announce_cache_cleared |
|---|
| 660 |
- redirect_to page_index_url |
|---|
| 661 |
- else |
|---|
| 662 |
- render :text => 'Do not access this URL directly.' |
|---|
| 663 |
- end |
|---|
| 664 |
+ @cache.clear |
|---|
| 665 |
+ announce_cache_cleared |
|---|
| 666 |
+ redirect_to pages_path |
|---|
| 667 |
end |
|---|
| 668 |
|
|---|
| 669 |
def add_part |
|---|
| 670 |
@@ -51,13 +88,6 @@ |
|---|
| 671 |
render(:partial => 'part', :object => part, :layout => false) |
|---|
| 672 |
end |
|---|
| 673 |
|
|---|
| 674 |
- def children |
|---|
| 675 |
- @parent = Page.find(params[:id]) |
|---|
| 676 |
- @level = params[:level].to_i |
|---|
| 677 |
- response.headers['Content-Type'] = 'text/html;charset=utf-8' |
|---|
| 678 |
- render(:layout => false) |
|---|
| 679 |
- end |
|---|
| 680 |
- |
|---|
| 681 |
def tag_reference |
|---|
| 682 |
@class_name = params[:class_name] |
|---|
| 683 |
@display_name = @class_name.constantize.display_name |
|---|
| 684 |
@@ -93,6 +123,10 @@ |
|---|
| 685 |
@meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]} |
|---|
| 686 |
end |
|---|
| 687 |
|
|---|
| 688 |
+ def find_parent |
|---|
| 689 |
+ @parent = Page.find_by_id(params[:page_id]) |
|---|
| 690 |
+ end |
|---|
| 691 |
+ |
|---|
| 692 |
def save |
|---|
| 693 |
parts = @page.parts |
|---|
| 694 |
parts_to_update = {} |
|---|
| 695 |
Index: app/controllers/admin/user_controller.rb |
|---|
| 696 |
=================================================================== |
|---|
| 697 |
--- app/controllers/admin/user_controller.rb (revision 602) |
|---|
| 698 |
+++ app/controllers/admin/user_controller.rb (working copy) |
|---|
| 699 |
@@ -10,7 +10,7 @@ |
|---|
| 700 |
@user = current_user |
|---|
| 701 |
if valid_params? |
|---|
| 702 |
handle_new_or_edit_post( |
|---|
| 703 |
- :redirect_to => page_index_url, |
|---|
| 704 |
+ :redirect_to => pages_path, |
|---|
| 705 |
:saved_message => 'Your preferences have been saved.' |
|---|
| 706 |
) |
|---|
| 707 |
else |
|---|
| 708 |
@@ -21,7 +21,7 @@ |
|---|
| 709 |
def remove |
|---|
| 710 |
if current_user.id.to_s == params[:id].to_s |
|---|
| 711 |
announce_cannot_delete_self |
|---|
| 712 |
- redirect_to user_index_url |
|---|
| 713 |
+ redirect_to users_path |
|---|
| 714 |
else |
|---|
| 715 |
super |
|---|
| 716 |
end |
|---|
| 717 |
Index: app/controllers/admin/abstract_model_controller.rb |
|---|
| 718 |
=================================================================== |
|---|
| 719 |
--- app/controllers/admin/abstract_model_controller.rb (revision 602) |
|---|
| 720 |
+++ app/controllers/admin/abstract_model_controller.rb (working copy) |
|---|
| 721 |
@@ -19,20 +19,29 @@ |
|---|
| 722 |
self.model = model_class.new |
|---|
| 723 |
render :template => "admin/#{ model_symbol }/edit" if handle_new_or_edit_post |
|---|
| 724 |
end |
|---|
| 725 |
- |
|---|
| 726 |
+ |
|---|
| 727 |
+ alias create new |
|---|
| 728 |
+ |
|---|
| 729 |
def edit |
|---|
| 730 |
self.model = model_class.find_by_id(params[:id]) |
|---|
| 731 |
handle_new_or_edit_post |
|---|
| 732 |
end |
|---|
| 733 |
+ |
|---|
| 734 |
+ def update |
|---|
| 735 |
+ self.model = model_class.find_by_id(params[:id]) |
|---|
| 736 |
+ render :template => "admin/#{ model_symbol }/edit" if handle_new_or_edit_post |
|---|
| 737 |
+ end |
|---|
| 738 |
|
|---|
| 739 |
def remove |
|---|
| 740 |
self.model = model_class.find(params[:id]) |
|---|
| 741 |
- if request.post? |
|---|
| 742 |
- model.destroy |
|---|
| 743 |
- announce_removed |
|---|
| 744 |
- redirect_to model_index_url |
|---|
| 745 |
- end |
|---|
| 746 |
end |
|---|
| 747 |
+ |
|---|
| 748 |
+ def destroy |
|---|
| 749 |
+ self.model = model_class.find(params[:id]) |
|---|
| 750 |
+ model.destroy |
|---|
| 751 |
+ announce_removed |
|---|
| 752 |
+ redirect_to model_index_url |
|---|
| 753 |
+ end |
|---|
| 754 |
|
|---|
| 755 |
protected |
|---|
| 756 |
|
|---|
| 757 |
@@ -73,11 +82,11 @@ |
|---|
| 758 |
end |
|---|
| 759 |
|
|---|
| 760 |
def model_index_url(params = {}) |
|---|
| 761 |
- send("#{ model_symbol }_index_url", params) |
|---|
| 762 |
+ send(model_name.downcase.pluralize + "_path", params) |
|---|
| 763 |
end |
|---|
| 764 |
|
|---|
| 765 |
def model_edit_url(params = {}) |
|---|
| 766 |
- send("#{ model_symbol }_edit_url", params) |
|---|
| 767 |
+ send("edit_" + model_name.downcase + "_path", params) |
|---|
| 768 |
end |
|---|
| 769 |
|
|---|
| 770 |
def continue_url(options) |
|---|
| 771 |
@@ -98,20 +107,21 @@ |
|---|
| 772 |
|
|---|
| 773 |
def announce_removed |
|---|
| 774 |
flash[:notice] = "#{humanized_model_name} has been deleted." |
|---|
| 775 |
- end |
|---|
| 776 |
- |
|---|
| 777 |
- def announce_update_conflict |
|---|
| 778 |
- flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data." |
|---|
| 779 |
- end |
|---|
| 780 |
- |
|---|
| 781 |
- def clear_model_cache |
|---|
| 782 |
- cache.clear |
|---|
| 783 |
end |
|---|
| 784 |
|
|---|
| 785 |
+ def announce_update_conflict |
|---|
| 786 |
+ flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data." |
|---|
| 787 |
+ end |
|---|
| 788 |
+ |
|---|
| 789 |
+ def clear_model_cache |
|---|
| 790 |
+ cache.clear |
|---|
| 791 |
+ end |
|---|
| 792 |
+ |
|---|
| 793 |
def handle_new_or_edit_post(options = {}) |
|---|
| 794 |
options.symbolize_keys |
|---|
| 795 |
- if request.post? |
|---|
| 796 |
- model.attributes = params[model_symbol] |
|---|
| 797 |
+ if request.post? || request.put? |
|---|
| 798 |
+ |
|---|
| 799 |
+ model.attributes = params[model_symbol] |
|---|
| 800 |
begin |
|---|
| 801 |
if save |
|---|
| 802 |
clear_model_cache |
|---|
| 803 |
@@ -120,9 +130,9 @@ |
|---|
| 804 |
return false |
|---|
| 805 |
else |
|---|
| 806 |
announce_validation_errors |
|---|
| 807 |
- end |
|---|
| 808 |
- rescue ActiveRecord::StaleObjectError |
|---|
| 809 |
- announce_update_conflict |
|---|
| 810 |
+ end |
|---|
| 811 |
+ rescue ActiveRecord::StaleObjectError |
|---|
| 812 |
+ announce_update_conflict |
|---|
| 813 |
end |
|---|
| 814 |
end |
|---|
| 815 |
true |
|---|
| 816 |
Index: app/views/layouts/application.rhtml |
|---|
| 817 |
=================================================================== |
|---|
| 818 |
--- app/views/layouts/application.rhtml (revision 602) |
|---|
| 819 |
+++ app/views/layouts/application.rhtml (working copy) |
|---|
| 820 |
@@ -60,11 +60,11 @@ |
|---|
| 821 |
<p id="site-links"> |
|---|
| 822 |
<% if logged_in? -%> |
|---|
| 823 |
<% if admin? -%> |
|---|
| 824 |
- <%= nav_link_to 'Users', user_index_url %> |
|---|
| 825 |
+ <%= nav_link_to 'Users', users_path %> |
|---|
| 826 |
<span class="separator"> | </span> |
|---|
| 827 |
<%= nav_link_to 'Extensions', extension_index_url %> |
|---|
| 828 |
<% else -%> |
|---|
| 829 |
- <%= nav_link_to 'Preferences', user_preferences_url %> |
|---|
| 830 |
+ <%= nav_link_to 'Preferences', preferences_user_path(current_user) %> |
|---|
| 831 |
<% end -%> |
|---|
| 832 |
<span class="separator"> | </span> |
|---|
| 833 |
<%= nav_link_to 'Log Out', logout_url %> |
|---|
| 834 |
Index: app/views/admin/snippet/remove.rhtml |
|---|
| 835 |
=================================================================== |
|---|
| 836 |
--- app/views/admin/snippet/remove.rhtml (revision 602) |
|---|
| 837 |
+++ app/views/admin/snippet/remove.rhtml (working copy) |
|---|
| 838 |
@@ -11,6 +11,6 @@ |
|---|
| 839 |
</tbody> |
|---|
| 840 |
</table> |
|---|
| 841 |
|
|---|
| 842 |
-<form method="post" action=""> |
|---|
| 843 |
- <p class="buttons"><%= submit_tag "Delete Snippet", :class => 'button' %> or <%= link_to 'Cancel', snippet_index_url %></p> |
|---|
| 844 |
+<%= form_tag(snippet_path(@snippet), :method => "delete", :multipart => true) %> |
|---|
| 845 |
+ <p class="buttons"><%= submit_tag "Delete Snippet", :class => 'button' %> or <%= link_to 'Cancel', snippets_path %></p> |
|---|
| 846 |
</form> |
|---|
| 847 |
Index: app/views/admin/snippet/edit.rhtml |
|---|
| 848 |
=================================================================== |
|---|
| 849 |
--- app/views/admin/snippet/edit.rhtml (revision 602) |
|---|
| 850 |
+++ app/views/admin/snippet/edit.rhtml (working copy) |
|---|
| 851 |
@@ -1,10 +1,11 @@ |
|---|
| 852 |
<% if @snippet.new_record? -%> |
|---|
| 853 |
<h1>New Snippet</h1> |
|---|
| 854 |
+<%= form_tag(snippets_path, :multipart => true) %> |
|---|
| 855 |
<% else -%> |
|---|
| 856 |
<h1>Edit Snippet</h1> |
|---|
| 857 |
+<%= form_tag(snippet_path(@snippet), :method => "put", :multipart => true) %> |
|---|
| 858 |
<% end -%> |
|---|
| 859 |
|
|---|
| 860 |
-<form method="post" action=""> |
|---|
| 861 |
<%= hidden_field "snippet", "lock_version" %> |
|---|
| 862 |
<div class="form-area"> |
|---|
| 863 |
<p class="title"> |
|---|
| 864 |
@@ -22,7 +23,7 @@ |
|---|
| 865 |
<%= updated_stamp @snippet %> |
|---|
| 866 |
</div> |
|---|
| 867 |
<p class="buttons"> |
|---|
| 868 |
- <%= save_model_button(@snippet) %> <%= save_model_and_continue_editing_button(@snippet) %> or <%= link_to "Cancel", snippet_index_url %> |
|---|
| 869 |
+ <%= save_model_button(@snippet) %> <%= save_model_and_continue_editing_button(@snippet) %> or <%= link_to "Cancel", snippets_path %> |
|---|
| 870 |
</p> |
|---|
| 871 |
</form> |
|---|
| 872 |
|
|---|
| 873 |
Index: app/views/admin/snippet/index.rhtml |
|---|
| 874 |
=================================================================== |
|---|
| 875 |
--- app/views/admin/snippet/index.rhtml (revision 602) |
|---|
| 876 |
+++ app/views/admin/snippet/index.rhtml (working copy) |
|---|
| 877 |
@@ -15,9 +15,9 @@ |
|---|
| 878 |
<tr class="node level-1"> |
|---|
| 879 |
<td class="snippet"> |
|---|
| 880 |
<%= image "snippet", :class => "icon", :alt => 'snippet-icon', :title => '' %> |
|---|
| 881 |
- <span><%= link_to snippet.name, snippet_edit_url(:id => snippet) %></span> |
|---|
| 882 |
+ <span><%= link_to snippet.name, edit_snippet_path(snippet) %></span> |
|---|
| 883 |
</td> |
|---|
| 884 |
- <td class="remove"><%= link_to image('remove', :alt => 'Remove Snippet'), snippet_remove_url(:id => snippet) %></td> |
|---|
| 885 |
+ <td class="remove"><%= link_to image('remove', :alt => 'Remove Snippet'), remove_snippet_path(snippet) %></td> |
|---|
| 886 |
</tr> |
|---|
| 887 |
<% end -%> |
|---|
| 888 |
<% else -%> |
|---|
| 889 |
@@ -33,4 +33,4 @@ |
|---|
| 890 |
// ]]> |
|---|
| 891 |
</script> |
|---|
| 892 |
|
|---|
| 893 |
-<p><%= link_to image('new-snippet', :alt => 'New Snippet'), snippet_new_url %></p> |
|---|
| 894 |
+<p><%= link_to image('new-snippet', :alt => 'New Snippet'), new_snippet_path %></p> |
|---|
| 895 |
Index: app/views/admin/page/remove.rhtml |
|---|
| 896 |
=================================================================== |
|---|
| 897 |
--- app/views/admin/page/remove.rhtml (revision 602) |
|---|
| 898 |
+++ app/views/admin/page/remove.rhtml (working copy) |
|---|
| 899 |
@@ -9,6 +9,6 @@ |
|---|
| 900 |
</tbody> |
|---|
| 901 |
</table> |
|---|
| 902 |
|
|---|
| 903 |
-<form method="post" action=""> |
|---|
| 904 |
- <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', page_index_url %></p> |
|---|
| 905 |
+<%= form_tag(page_path(@page), :method => "delete", :multipart => true) %> |
|---|
| 906 |
+ <p class="buttons"><%= submit_tag "Delete #{pages}", :class => 'button' %> or <%= link_to 'Cancel', pages_path %></p> |
|---|
| 907 |
</form> |
|---|
| 908 |
Index: app/views/admin/page/_node.rhtml |
|---|
| 909 |
=================================================================== |
|---|
| 910 |
--- app/views/admin/page/_node.rhtml (revision 602) |
|---|
| 911 |
+++ app/views/admin/page/_node.rhtml (working copy) |
|---|
| 912 |
@@ -5,7 +5,9 @@ |
|---|
| 913 |
<%= icon %> |
|---|
| 914 |
<%= node_title %> |
|---|
| 915 |
<% else -%> |
|---|
| 916 |
- <%= expander %><a href="<%= page_edit_url(:id => page) %>" title="<%= page.url %>"><%= icon %> <%= node_title %></a> |
|---|
| 917 |
+ |
|---|
| 918 |
+ <%= expander %><a href="<%= edit_page_path(page) %>" title="<%= page.url %>"><%= icon %> <%= node_title %></a> |
|---|
| 919 |
+ |
|---|
| 920 |
<%= page_type %> |
|---|
| 921 |
<%= spinner %> |
|---|
| 922 |
<% end -%> |
|---|
| 923 |
@@ -13,8 +15,8 @@ |
|---|
| 924 |
</td> |
|---|
| 925 |
<% unless simple -%> |
|---|
| 926 |
<td class="status <%= page.status.name.downcase %>-status"><%= page.status.name %></td> |
|---|
| 927 |
- <td class="add-child"><%= link_to image('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %></td> |
|---|
| 928 |
- <td class="remove"><%= link_to image('remove', :alt => 'remove page'), page_remove_url(:id => page) %></td> |
|---|
| 929 |
+ <td class="add-child"><%= link_to image('add-child', :alt => 'add child'), new_page_child_path(page) %></td> |
|---|
| 930 |
+ <td class="remove"><%= link_to image('remove', :alt => 'remove page'), page_path(page), :method => 'delete' %></td> |
|---|
| 931 |
<% end -%> |
|---|
| 932 |
</tr> |
|---|
| 933 |
<% |
|---|
| 934 |
Index: app/views/admin/page/edit.rhtml |
|---|
| 935 |
=================================================================== |
|---|
| 936 |
--- app/views/admin/page/edit.rhtml (revision 602) |
|---|
| 937 |
+++ app/views/admin/page/edit.rhtml (working copy) |
|---|
| 938 |
@@ -4,7 +4,7 @@ |
|---|
| 939 |
page_type = $F('page_class_name'); |
|---|
| 940 |
popup = $('tag-reference-popup'); |
|---|
| 941 |
if(last_type != page_type) { |
|---|
| 942 |
- url = "<%= tag_reference_url %>"; |
|---|
| 943 |
+ url = "<%= tag_reference_pages_path %>"; |
|---|
| 944 |
params = "class_name=" + page_type; |
|---|
| 945 |
new Effect.Highlight('tag-reference-link-'+ part); |
|---|
| 946 |
req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true }); |
|---|
| 947 |
@@ -19,7 +19,7 @@ |
|---|
| 948 |
filter_type = $F("part_" + part + "_filter_id"); |
|---|
| 949 |
popup = $('filter-reference-popup'); |
|---|
| 950 |
if(last_filter != filter_type) { |
|---|
| 951 |
- url = "<%= filter_reference_url %>"; |
|---|
| 952 |
+ url = "<%= filter_reference_pages_path %>"; |
|---|
| 953 |
params = "filter_name=" + filter_type; |
|---|
| 954 |
new Effect.Highlight('filter-reference-link-'+ part); |
|---|
| 955 |
req = new Ajax.Request(url, { method: 'get', parameters: params, evalScripts: true }); |
|---|
| 956 |
@@ -50,11 +50,14 @@ |
|---|
| 957 |
<% include_javascript "tag_reference_search" %> |
|---|
| 958 |
<% if @page.new_record? -%> |
|---|
| 959 |
<h1 id="new_page">New Page</h1> |
|---|
| 960 |
+<%= form_tag(@homepage ? pages_path : page_children_path(:page_id => @parent), :multipart => true) %> |
|---|
| 961 |
+ |
|---|
| 962 |
<% else -%> |
|---|
| 963 |
<h1 id="edit_page">Edit Page</h1> |
|---|
| 964 |
+<%= form_tag(page_path(@page), :method => "put", :multipart => true) %> |
|---|
| 965 |
+ |
|---|
| 966 |
<% end -%> |
|---|
| 967 |
|
|---|
| 968 |
-<form method="post" action="" enctype="multipart/form-data"> |
|---|
| 969 |
<%= hidden_field "page", "lock_version" %> |
|---|
| 970 |
<div class="form-area"> |
|---|
| 971 |
<p class="title"> |
|---|
| 972 |
@@ -66,7 +69,7 @@ |
|---|
| 973 |
<% for meta in @meta %> |
|---|
| 974 |
<%= render :partial => "meta_row", :object => meta %> |
|---|
| 975 |
<% end %> |
|---|
| 976 |
- </table> |
|---|
| 977 |
+ </table> |
|---|
| 978 |
</div> |
|---|
| 979 |
<p class="more-or-less"> |
|---|
| 980 |
<small> |
|---|
| 981 |
@@ -85,7 +88,7 @@ |
|---|
| 982 |
<%= render :partial => 'part', :collection => @page.parts %> |
|---|
| 983 |
</div> |
|---|
| 984 |
</div> |
|---|
| 985 |
- |
|---|
| 986 |
+ |
|---|
| 987 |
<div class="row"> |
|---|
| 988 |
<p><label for="page_layout_id">Layout</label> |
|---|
| 989 |
<%= select "page", "layout_id", [['<inherit>', '']] + Layout.find(:all).map { |s| [s.name, s.id] } %></p> |
|---|
| 990 |
@@ -101,7 +104,7 @@ |
|---|
| 991 |
<%= render :partial => partial %> |
|---|
| 992 |
<% end %> |
|---|
| 993 |
<p class="buttons"> |
|---|
| 994 |
- <%= save_model_button(@page) %> <%= save_model_and_continue_editing_button(@page) %> or <%= link_to "Cancel", page_index_url %> |
|---|
| 995 |
+ <%= save_model_button(@page) %> <%= save_model_and_continue_editing_button(@page) %> or <%= link_to "Cancel", pages_path %> |
|---|
| 996 |
</p> |
|---|
| 997 |
</form> |
|---|
| 998 |
|
|---|
| 999 |
@@ -109,8 +112,10 @@ |
|---|
| 1000 |
<div class="popup" id="add-part-popup" style="display: none"> |
|---|
| 1001 |
<div id="busy" class="busy" style="display: none"><%= image 'spinner.gif' %></div> |
|---|
| 1002 |
<h3>Add Part</h3> |
|---|
| 1003 |
+ <%# FIXME: this should be a POST request, placeholder for routing change. %> |
|---|
| 1004 |
<% form_remote_tag( |
|---|
| 1005 |
- :url => page_add_part_url, |
|---|
| 1006 |
+ :url => add_part_pages_path, |
|---|
| 1007 |
+ :method => "get", |
|---|
| 1008 |
:update => "pages", |
|---|
| 1009 |
:position => :bottom, |
|---|
| 1010 |
:loading => 'part_loading()', |
|---|
| 1011 |
@@ -137,4 +142,4 @@ |
|---|
| 1012 |
<div id="filter-reference"><%= filter_reference(default_filter_name) %></div> |
|---|
| 1013 |
<p><%= link_to_function 'Close', "Element.hide('filter-reference-popup')", :class => 'close-link' %></p> |
|---|
| 1014 |
</div> |
|---|
| 1015 |
-<% end -%> |
|---|
| 1016 |
+<% end -%> |
|---|
| 1017 |
Index: app/views/admin/page/index.rhtml |
|---|
| 1018 |
=================================================================== |
|---|
| 1019 |
--- app/views/admin/page/index.rhtml (revision 602) |
|---|
| 1020 |
+++ app/views/admin/page/index.rhtml (working copy) |
|---|
| 1021 |
@@ -21,11 +21,11 @@ |
|---|
| 1022 |
</tbody> |
|---|
| 1023 |
</table> |
|---|
| 1024 |
|
|---|
| 1025 |
-<form action="<%= clear_cache_url %>" method="post"> |
|---|
| 1026 |
+<% form_tag(clear_cache_pages_path, :method => "delete") do %> |
|---|
| 1027 |
<p> |
|---|
| 1028 |
<% unless @homepage -%> |
|---|
| 1029 |
- <%= link_to image('new-homepage', :alt => 'New Homepage'), homepage_new_url %> |
|---|
| 1030 |
+ <%= link_to image('new-homepage', :alt => 'New Homepage'), homepage_pages_path %> |
|---|
| 1031 |
<% end -%> |
|---|
| 1032 |
<%= image_submit 'clear-page-cache' %> |
|---|
| 1033 |
</p> |
|---|
| 1034 |
-</form> |
|---|
| 1035 |
+<% end -%> |
|---|
| 1036 |
Index: app/views/admin/layout/remove.rhtml |
|---|
| 1037 |
=================================================================== |
|---|
| 1038 |
--- app/views/admin/layout/remove.rhtml (revision 602) |
|---|
| 1039 |
+++ app/views/admin/layout/remove.rhtml (working copy) |
|---|
| 1040 |
@@ -12,6 +12,7 @@ |
|---|
| 1041 |
</tbody> |
|---|
| 1042 |
</table> |
|---|
| 1043 |
|
|---|
| 1044 |
-<form method="post" action=""> |
|---|
| 1045 |
- <p class="buttons"><%= submit_tag "Delete Layout", :class => 'button' %> or <%= link_to 'Cancel', layout_index_url %></p> |
|---|
| 1046 |
+<%= form_tag(layout_path(@layout), :method => "delete", :multipart => true) %> |
|---|
| 1047 |
+ |
|---|
| 1048 |
+ <p class="buttons"><%= submit_tag "Delete Layout", :class => 'button' %> or <%= link_to 'Cancel', layouts_path %></p> |
|---|
| 1049 |
</form> |
|---|
| 1050 |
Index: app/views/admin/layout/edit.rhtml |
|---|
| 1051 |
=================================================================== |
|---|
| 1052 |
--- app/views/admin/layout/edit.rhtml (revision 602) |
|---|
| 1053 |
+++ app/views/admin/layout/edit.rhtml (working copy) |
|---|
| 1054 |
@@ -1,10 +1,11 @@ |
|---|
| 1055 |
<% if @layout.new_record? -%> |
|---|
| 1056 |
<h1>New Layout</h1> |
|---|
| 1057 |
+<%= form_tag(layouts_path, :multipart => true) %> |
|---|
| 1058 |
<% else -%> |
|---|
| 1059 |
<h1>Edit Layout</h1> |
|---|
| 1060 |
+<%= form_tag(layout_path(@layout), :method => "put", :multipart => true) %> |
|---|
| 1061 |
<% end -%> |
|---|
| 1062 |
|
|---|
| 1063 |
-<form method="post" action=""> |
|---|
| 1064 |
<%= hidden_field "layout", "lock_version" %> |
|---|
| 1065 |
<div class="form-area"> |
|---|
| 1066 |
<p class="title"> |
|---|
| 1067 |
@@ -32,7 +33,7 @@ |
|---|
| 1068 |
<%= updated_stamp @layout %> |
|---|
| 1069 |
</div> |
|---|
| 1070 |
<p class="buttons"> |
|---|
| 1071 |
- <%= save_model_button(@layout) %> <%= save_model_and_continue_editing_button(@layout) %> or <%= link_to "Cancel", layout_index_url %> |
|---|
| 1072 |
+ <%= save_model_button(@layout) %> <%= save_model_and_continue_editing_button(@layout) %> or <%= link_to "Cancel", layouts_path %> |
|---|
| 1073 |
</p> |
|---|
| 1074 |
</form> |
|---|
| 1075 |
|
|---|
| 1076 |
Index: app/views/admin/layout/index.rhtml |
|---|
| 1077 |
=================================================================== |
|---|
| 1078 |
--- app/views/admin/layout/index.rhtml (revision 602) |
|---|
| 1079 |
+++ app/views/admin/layout/index.rhtml (working copy) |
|---|
| 1080 |
@@ -17,9 +17,9 @@ |
|---|
| 1081 |
<tr class="node level-1"> |
|---|
| 1082 |
<td class="layout"> |
|---|
| 1083 |
<%= i |
|---|