Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (46 sloc) 1.039 kB
require 'rubygems'
require 'bundler'
Bundler.require(:default, :test)
require 'active_support/all'
require 'matchers'
require 'cancan'
require 'cancan/matchers'
RSpec.configure do |config|
config.mock_with :rr
end
class Ability
include CanCan::Ability
def initialize(user)
end
end
# Generic class to mimic a model
class Project
attr_accessor :name
def initialize(attributes = {})
@name = attributes[:name]
end
def attributes=(attributes)
@name = attributes[:name] if attributes[:name]
end
class << self
protected
def sanitize_sql(hash_cond)
case hash_cond
when Hash
sanitize_hash(hash_cond).join(' AND ')
when Array
hash_cond.shift.gsub('?'){"#{hash_cond.shift.inspect}"}
when String then hash_cond
end
end
def sanitize_hash(hash)
hash.map do |name, value|
if Hash === value
sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
else
"#{name}=#{value}"
end
end.flatten
end
end
end
Jump to Line
Something went wrong with that request. Please try again.