Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

RAILS_ROOT -> Rails.root

Closes #134
  • Loading branch information...
commit c93fc540ba3c7542217cb9f3fddf2e6d434167dc 1 parent 2a07f2a
Kevin Moore kevmoo authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/tasks/authorization_tasks.rake
14 lib/tasks/authorization_tasks.rake
View
@@ -2,10 +2,10 @@ namespace :auth do
desc "Lists all privileges used in controllers, views, models"
task :used_privileges do
# TODO note where privileges are used
- require File.join(RAILS_ROOT, 'config', 'boot.rb')
- require File.join(RAILS_ROOT, 'config', 'environment.rb')
+ require File.join(Rails.root, 'config', 'boot.rb')
+ require File.join(Rails.root, 'config', 'environment.rb')
controllers = [ApplicationController]
- Dir.new("#{RAILS_ROOT}/app/controllers").entries.each do |controller_file|
+ Dir.new("#{Rails.root}/app/controllers").entries.each do |controller_file|
if controller_file =~ /_controller/
controllers << controller_file.gsub(".rb","").camelize.constantize
end
@@ -24,19 +24,19 @@ namespace :auth do
all += contr_perms.reject {|cp| cp[0].nil?}.collect {|cp| cp[0..1]}
end
- model_all = `grep -l "Base\.using_access_control" #{RAILS_ROOT}/config/*.rb #{RAILS_ROOT}/config/initializers/*.rb`.split("\n")
+ model_all = `grep -l "Base\.using_access_control" #{Rails.root}/config/*.rb #{Rails.root}/config/initializers/*.rb`.split("\n")
if model_all.count > 0
- model_files = Dir.glob( "#{RAILS_ROOT}/app/models/*.rb").reject do |item|
+ model_files = Dir.glob( "#{Rails.root}/app/models/*.rb").reject do |item|
item.match(/_observer\.rb/)
end
else
- model_files = `grep -l "^[[:space:]]*using_access_control" #{RAILS_ROOT}/app/models/*.rb`.split("\n")
+ model_files = `grep -l "^[[:space:]]*using_access_control" #{Rails.root}/app/models/*.rb`.split("\n")
end
models_with_ac = model_files.collect {|mf| mf.sub(/^.*\//, "").sub(".rb", "").tableize.to_sym}
model_security_privs = [:create, :read, :update, :delete]
models_with_ac.each {|m| perms += model_security_privs.collect{|msp| [msp, m]}}
- grep_file_pattern = "#{RAILS_ROOT}/app/models/*.rb #{RAILS_ROOT}/app/views/**/* #{RAILS_ROOT}/app/controllers/*.rb"
+ grep_file_pattern = "#{Rails.root}/app/models/*.rb #{Rails.root}/app/views/**/* #{Rails.root}/app/controllers/*.rb"
`grep "permitted_to?" #{grep_file_pattern}`.split("\n").each do |ptu|
file, grep_match = ptu.split(':', 2)
context = privilege = nil
Please sign in to comment.
Something went wrong with that request. Please try again.