mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-04 15:14:09 -04:00
added admin controller and index view
This commit is contained in:
3
app/assets/javascripts/admin.js.coffee
Normal file
3
app/assets/javascripts/admin.js.coffee
Normal 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/
|
||||
8
app/controllers/admin_controller.rb
Normal file
8
app/controllers/admin_controller.rb
Normal 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
|
||||
2
app/helpers/admin_helper.rb
Normal file
2
app/helpers/admin_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module AdminHelper
|
||||
end
|
||||
@@ -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
|
||||
|
||||
1
app/views/admin/index.html.haml
Normal file
1
app/views/admin/index.html.haml
Normal file
@@ -0,0 +1 @@
|
||||
-content_for :title, 'Admin'
|
||||
@@ -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
|
||||
|
||||
5
spec/controllers/admin_controller_spec.rb
Normal file
5
spec/controllers/admin_controller_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe AdminController do
|
||||
|
||||
end
|
||||
15
spec/helpers/admin_helper_spec.rb
Normal file
15
spec/helpers/admin_helper_spec.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user