Skip to content

Commit

Permalink
Updated to work with more RESTful admin controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
bclennox committed Dec 13, 2008
1 parent 22ed6cd commit c436cf8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
@@ -1,11 +1,11 @@
module Reorder::PageControllerExtensions
module Reorder::PagesControllerExtensions

%w{move_higher move_lower move_to_top move_to_bottom}.each do |action|
define_method action do
@page = Page.find(params[:id])
@page.parent.reload.children.reload
@page.send(action)
request.env["HTTP_REFERER"] ? redirect_to(:back) : redirect_to(page_index_url)
request.env["HTTP_REFERER"] ? redirect_to(:back) : redirect_to(admin_pages_url)
end
end

Expand Down
6 changes: 3 additions & 3 deletions reorder_extension.rb
Expand Up @@ -7,7 +7,7 @@ class ReorderExtension < Radiant::Extension
url "http://dev.radiantcms.org/"

define_routes do |map|
map.with_options :controller => "admin/page" do |page|
map.with_options :controller => "admin/pages" do |page|
page.page_move_lower "admin/pages/:id/move_lower", :action => "move_lower"
page.page_move_higher "admin/pages/:id/move_higher", :action => "move_higher"
page.page_move_to_bottom "admin/pages/:id/move_to_bottom", :action => "move_to_bottom"
Expand All @@ -20,8 +20,8 @@ def activate
admin.page.index.add :node, "order"
admin.page.index.add :top, 'header'
Page.send :include, Reorder::PageExtensions
Admin::PageController.send :include, Reorder::PageControllerExtensions
Admin::PageController.send :helper, Reorder::PageHelper
Admin::PagesController.send :include, Reorder::PagesControllerExtensions
Admin::PagesController.send :helper, Reorder::PageHelper
StandardTags.send :include, Reorder::TagExtensions
end

Expand Down
35 changes: 35 additions & 0 deletions test/fixtures/users.yml
@@ -0,0 +1,35 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
existing:
id: 1
name: Existing User
login: existing
salt: 42ddb5b6479872565981adc78e86ddc50fa21637
password: 4c5f9d5a0d4cd65d61f6b1505890576d1272986c # password
email: existing.user@gmail.com
another:
id: 2
name: Another User
login: another
salt: 42ddb5b6479872565981adc78e86ddc50fa21637
password: 4c5f9d5a0d4cd65d61f6b1505890576d1272986c # password
admin:
id: 3
name: Admin User
login: admin
salt: 42ddb5b6479872565981adc78e86ddc50fa21637
password: 4c5f9d5a0d4cd65d61f6b1505890576d1272986c # password
admin: true
developer:
id: 4
name: Developer User
login: developer
salt: 42ddb5b6479872565981adc78e86ddc50fa21637
password: 4c5f9d5a0d4cd65d61f6b1505890576d1272986c # password
developer: true
non_admin:
id: 5
name: Non-Admin User
login: non-admin
salt: 42ddb5b6479872565981adc78e86ddc50fa21637
password: 4c5f9d5a0d4cd65d61f6b1505890576d1272986c # password
admin: false
@@ -1,13 +1,13 @@
require File.dirname(__FILE__) + "/../test_helper"

Admin::PageController.class_eval { def rescue_action(e); raise(e); end }
Admin::PagesController.class_eval { def rescue_action(e); raise(e); end }

class PageControllerExtensions < Test::Unit::TestCase
class PagesControllerExtensions < Test::Unit::TestCase
fixtures :pages
test_helper :login, :page, :difference

def setup
@controller = Admin::PageController.new
@controller = Admin::PagesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as(:existing)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/tag_extensions_test.rb
Expand Up @@ -4,7 +4,7 @@
class TagExtensionsTest < Test::Unit::TestCase
def setup
@tag = OpenStruct.new
@tag.attr = {}
@tag.attr = { :status => 'all' }
@children_find_options = Page.new.method(:children_find_options)
end

Expand Down

0 comments on commit c436cf8

Please sign in to comment.