Sha256: 84069734fdcf95bcf3cc43f4b8082a83639be2c13692e9b53d0128fc323ceb01
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
require "lanes/spec_helper" class ExportedLimitsTest < Lanes::TestCase class LimitsTestingModel include Lanes::Concerns::ExportScope include Lanes::Concerns::ExportMethods def self.scope(name, query)# act like ActiveRecord model end def secret_method( name, query ) end def test_method( name, query ) end export_methods :test_method, limit: lambda{ | user, type, name | user == 'anon' } export_scope :admin_data, lambda{ | param | param }, limit: :only_admins export_methods :secret_method, limit: :only_admins def self.only_admins( user, type, name ) return user == 'admin' end end def test_limits assert LimitsTestingModel.has_exported_method?( 'test_method', 'anon' ), "anyone can retrieve no_limit data" assert LimitsTestingModel.has_exported_scope?( 'admin_data', 'admin' ), "Admins can retrieve admin data" refute LimitsTestingModel.has_exported_scope?( 'admin_data', 'non-admin' ), "Non-Admin cannot retrieve admin data" assert LimitsTestingModel.has_exported_method?( 'secret_method', 'admin' ), "Public can retrieve public data" refute LimitsTestingModel.has_exported_method?( 'secret_method', 'unk' ), "User must be admin to retrieve public data" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.2 | spec/concerns/exported_limits_spec.rb |
lanes-0.1.0 | spec/concerns/exported_limits_spec.rb |
lanes-0.0.8 | spec/concerns/exported_limits_spec.rb |