Spec employees

This commit is contained in:
2015-02-24 13:43:44 +01:00
parent 755690131c
commit 16418dde30
18 changed files with 104 additions and 97 deletions
@@ -5,6 +5,7 @@ module Suppliers
attr_reader :current_supplier
helper_method :current_supplier
layout 'supplier/app'
class_attribute :after_authentication_hooks
rescue_from 'RestClient::Conflict' do |e|
#binding.pry
@@ -16,6 +17,11 @@ module Suppliers
end
end
def self.after_authentication(options, &blk)
self.after_authentication_hooks ||= []
after_authentication_hooks << {options: options, block: blk}
end
def setup_employee_and_supplier!
authenticate_employee!
find_current_supplier!
@@ -23,6 +29,10 @@ module Suppliers
current_employee.enrich_with_settings current_supplier.settings_for(current_employee)
raise CanCan::AccessDenied unless current_employee.active?
@current_ability = ::Ability.new( current_employee )
Array.wrap(after_authentication_hooks).each do |hook|
next if hook[:options][:only].present? && !Array.wrap(hook[:options][:only].include?(action_name.to_sym))
instance_eval &hook[:block]
end
end