added admin controller and index view

This commit is contained in:
Skud
2013-05-29 14:37:42 +10:00
parent b60790c8ad
commit 7a1eaeffee
9 changed files with 44 additions and 20 deletions

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -0,0 +1,8 @@
class AdminController < ApplicationController
def index
authorize! :manage, :all
respond_to do |format|
format.html # index.html.haml
end
end
end

View File

@@ -0,0 +1,2 @@
module AdminHelper
end

View File

@@ -78,32 +78,16 @@ class Ability
cannot :destroy, OrderItem, :order => { :member_id => member.id, :completed_at => nil }
if member.has_role? :admin
# admin user roles (for authorization)
can :read, Role
can :manage, Role
# for now, only admins can create/edit forums
can :manage, Forum
can :read, :all
can :manage, :all
# admins can manage products
can :manage, Product
# admins can read other people's orders...
can :read, Order
can :read, OrderItem
# but they can't do anything to them, because orders are *history*
# can't change order history, because it's *history*
cannot :create, Order
cannot :complete, Order
cannot :destroy, Order
cannot :manage, OrderItem
# admins can read and manage members' account details (paid acct
# status, etc)
can :read, Account
can :manage, Account
can :read, AccountType
can :manage, AccountType
end
end

View File

@@ -0,0 +1 @@
-content_for :title, 'Admin'

View File

@@ -89,11 +89,17 @@ Growstuff::Application.routes.draw do
# match ':controller(/:action(/:id))(.:format)'
match '/policy/:action' => 'policy#:action'
match '/support' => 'support#index'
match '/support/:action' => 'support#:action'
match '/about' => 'about#index'
match '/about/:action' => 'about#:action'
match '/shop' => 'shop#index'
match '/shop/:action' => 'shop#:action'
match '/admin' => 'admin#index'
match '/admin/:action' => 'admin#:action'
end

View File

@@ -0,0 +1,5 @@
require 'spec_helper'
describe AdminController do
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the AdminHelper. For example:
#
# describe AdminHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe AdminHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -238,7 +238,7 @@ describe Ability do
end
it "cannot delete orders" do
@admin_ability.should_not be_able_to(:delete, @order)
@admin_ability.should_not be_able_to(:destroy, @order)
end
end