adding model adapter files in proper location with loading behavior
This commit is contained in:
parent
f8760b7149
commit
4c5ba09f4c
9
Gemfile
9
Gemfile
|
@ -1,10 +1,13 @@
|
|||
source "http://rubygems.org"
|
||||
gemspec
|
||||
|
||||
case ENV["MODEL_ADAPTER"]
|
||||
when nil, "active_record"
|
||||
gem "activerecord", :require => "active_record"
|
||||
when "data_mapper"
|
||||
gem "dm-core", "~> 1.0.2"
|
||||
when "mongoid"
|
||||
gem "bson_ext", "~> 1.1"
|
||||
gem "mongoid", "~> 2.0.0.beta.19"
|
||||
when "data_mapper"
|
||||
gem "dm-core", "~> 1.0.2"
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -2,8 +2,10 @@ require 'cancan/ability'
|
|||
require 'cancan/rule'
|
||||
require 'cancan/controller_resource'
|
||||
require 'cancan/controller_additions'
|
||||
require 'cancan/active_record_additions'
|
||||
require 'cancan/mongoid_additions'
|
||||
require 'cancan/exceptions'
|
||||
require 'cancan/query'
|
||||
require 'cancan/inherited_resource'
|
||||
|
||||
require 'cancan/model_adapters/active_record_adapter' if defined? ActiveRecord
|
||||
require 'cancan/model_adapters/data_mapper_adapter' if defined? DataMapper
|
||||
require 'cancan/model_adapters/mongoid_adapter' if defined? Mongoid
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'dm-core'
|
||||
|
||||
module CanCan
|
||||
module Ability
|
||||
# could use alias_method_chain, but it's not worth adding activesupport as a gem dependency
|
|
@ -1,6 +1,5 @@
|
|||
if ENV["MODEL_ADAPTER"] == "data_mapper"
|
||||
require "spec_helper"
|
||||
require 'cancan/data_mapper_additions'
|
||||
|
||||
describe CanCan::DataMapperAdditions do
|
||||
before(:each) do
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
if ENV["MODEL_ADAPTER"] == "mongoid"
|
||||
require 'mongoid' # require mongoid first so MongoidAdditions are loaded
|
||||
require "spec_helper"
|
||||
|
||||
class MongoidCategory
|
||||
|
@ -35,7 +34,7 @@ if ENV["MODEL_ADAPTER"] == "mongoid"
|
|||
end
|
||||
|
||||
Mongoid.configure do |config|
|
||||
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("cancan_mongoid_additions_spec")
|
||||
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("cancan_mongoid_spec")
|
||||
end
|
||||
|
||||
describe CanCan::MongoidAdditions do
|
||||
|
@ -50,7 +49,6 @@ if ENV["MODEL_ADAPTER"] == "mongoid"
|
|||
it "should not raise an error for ActiveRecord models" do
|
||||
@model_class = Class.new(Project)
|
||||
stub(@model_class).scoped { :scoped_stub }
|
||||
@model_class.send(:include, CanCan::ActiveRecordAdditions)
|
||||
@ability = Object.new
|
||||
@ability.extend(CanCan::Ability)
|
||||
|
||||
|
@ -60,7 +58,7 @@ if ENV["MODEL_ADAPTER"] == "mongoid"
|
|||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "Mongoid defined" do
|
||||
before(:each) do
|
||||
@model_class = MongoidProject
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
|
||||
Bundler.require(:default)
|
||||
|
||||
require 'supermodel' # shouldn't Bundler do this already?
|
||||
require 'active_support/all'
|
||||
require 'matchers'
|
||||
|
|
Loading…
Reference in New Issue
Block a user