Commit 3c46f30a36e70a2ff09e7ea691daca47e0f883ec

Authored by Braulio Bhavamitra
1 parent fd398cc0

access_control: Rename file (fix tests)

test/unit/manage_products_helper_test.rb
@@ -101,7 +101,7 @@ class ManageProductsHelperTest < ActionView::TestCase @@ -101,7 +101,7 @@ class ManageProductsHelperTest < ActionView::TestCase
101 category = fast_create(ProductCategory, :name => 'Category 1', :environment_id => @environment.id) 101 category = fast_create(ProductCategory, :name => 'Category 1', :environment_id => @environment.id)
102 product = fast_create(Product, :product_category_id => category.id) 102 product = fast_create(Product, :product_category_id => category.id)
103 103
104 - expects(:ui_button_to_remote).with('link to edit', {:update => "product-info", :loading => "loading_for_button('#edit-product-remote-button-ui-info')", :url => {:controller => 'manage_products', :action => 'edit', :id => product.id, :field => 'info'}, :complete => "$('edit-product-button-ui-info').hide()", :method => :get}, :id => 'edit-product-remote-button-ui-info').returns('LINK') 104 + expects(:ui_button_to_remote).with('link to edit', {:update => "product-info", :loading => "loading_for_button('#edit-product-remote-button-ui-info')", :url => {:controller => 'manage_products', :action => 'edit', :id => product.id, :field => 'info'}, :complete => "$('#edit-product-button-ui-info').hide()", :method => :get}, :id => 'edit-product-remote-button-ui-info').returns('LINK')
105 105
106 assert_equal 'LINK', edit_product_ui_button_to_remote(product, 'info', 'link to edit') 106 assert_equal 'LINK', edit_product_ui_button_to_remote(product, 'info', 'link to edit')
107 end 107 end
vendor/plugins/access_control/lib/permission_check.rb
1 module PermissionCheck 1 module PermissionCheck
2 - 2 +
3 module ClassMethods 3 module ClassMethods
4 # Declares the +permission+ need to be able to access +action+. 4 # Declares the +permission+ need to be able to access +action+.
5 # 5 #
@@ -8,15 +8,15 @@ module PermissionCheck @@ -8,15 +8,15 @@ module PermissionCheck
8 # * +target+ is the object over witch the user would need the specified 8 # * +target+ is the object over witch the user would need the specified
9 # permission and must be specified as a symbol or the string 'global'. The controller using 9 # permission and must be specified as a symbol or the string 'global'. The controller using
10 # +target+ must respond to a method with that name returning the object 10 # +target+ must respond to a method with that name returning the object
11 - # against which the permissions needed will be checked or if 'global' is passed it will be 11 + # against which the permissions needed will be checked or if 'global' is passed it will be
12 # cheked if the assignment is global 12 # cheked if the assignment is global
13 # * +accessor+ is a mehtod that returns the accessor who must have the permission. By default 13 # * +accessor+ is a mehtod that returns the accessor who must have the permission. By default
14 # is :user 14 # is :user
15 - # * +action+ must be a hash of options for a before filter like 15 + # * +action+ must be a hash of options for a before filter like
16 # :only => :index or :except => [:edit, :update] by default protects all the actions 16 # :only => :index or :except => [:edit, :update] by default protects all the actions
17 def protect(permission, target_method, accessor_method = :user, actions = {}) 17 def protect(permission, target_method, accessor_method = :user, actions = {})
18 actions, accessor_method = accessor_method, :user if accessor_method.kind_of?(Hash) 18 actions, accessor_method = accessor_method, :user if accessor_method.kind_of?(Hash)
19 - before_filter actions do |c| 19 + before_filter actions do |c|
20 target = target_method.kind_of?(Symbol) ? c.send(target_method) : target_method 20 target = target_method.kind_of?(Symbol) ? c.send(target_method) : target_method
21 accessor = accessor_method.kind_of?(Symbol) ? c.send(accessor_method) : accessor_method 21 accessor = accessor_method.kind_of?(Symbol) ? c.send(accessor_method) : accessor_method
22 unless accessor && accessor.has_permission?(permission.to_s, target) 22 unless accessor && accessor.has_permission?(permission.to_s, target)
@@ -34,12 +34,12 @@ module PermissionCheck @@ -34,12 +34,12 @@ module PermissionCheck
34 end 34 end
35 35
36 def access_denied_template_path 36 def access_denied_template_path
37 - if File.exists?(File.join(Rails.root, 'app', 'views', 'access_control', 'access_denied.rhtml'))  
38 - File.join(Rails.root, 'app', 'views', 'access_control', 'access_denied.rhtml')  
39 - elsif File.exists?(File.join(Rails.root, 'app','views', 'shared', 'access_denied.rhtml'))  
40 - File.join('shared', 'access_denied.rhtml') 37 + if File.exists?(File.join(Rails.root, 'app', 'views', 'access_control', 'access_denied.html.erb'))
  38 + File.join(Rails.root, 'app', 'views', 'access_control', 'access_denied.html.erb')
  39 + elsif File.exists?(File.join(Rails.root, 'app','views', 'shared', 'access_denied.html.erb'))
  40 + File.join('shared', 'access_denied.html.erb')
41 else 41 else
42 - File.join(File.dirname(__FILE__), '..', 'views', 'access_denied.rhtml') 42 + File.join(File.dirname(__FILE__), '..', 'views', 'access_denied.html.erb')
43 end 43 end
44 end 44 end
45 end 45 end