Skip to content

Commit

Permalink
Limit use of mock_model to ActiveRecord - use an alternate document c…
Browse files Browse the repository at this point in the history
…lass for Mongoid
  • Loading branch information
petergoldstein committed Jul 29, 2012
1 parent c0ea168 commit 87fdc4f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spec/models/doorkeeper/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

module Doorkeeper
describe Application do
include OrmHelper

let(:require_owner) { Doorkeeper.configuration.instance_variable_set("@confirm_application_owner", true) }
let(:unset_require_owner) { Doorkeeper.configuration.instance_variable_set("@confirm_application_owner", false) }
let(:new_application) { FactoryGirl.build(:application) }

context "application_owner is enabled" do
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
enable_application_owner
end
end
Expand All @@ -26,7 +29,7 @@ module Doorkeeper
context "application owner is required" do
before(:each) do
require_owner
@owner = mock_model 'User', :id => 1234
@owner = mock_application_owner
end

it 'is invalid without an owner' do
Expand Down
8 changes: 8 additions & 0 deletions spec/support/orm/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# load schema to in memory sqlite
ActiveRecord::Migration.verbose = false
load Rails.root + "db/schema.rb"

module Doorkeeper
module OrmHelper
def mock_application_owner
mock_model 'User', :id => 1234
end
end
end
16 changes: 16 additions & 0 deletions spec/support/orm/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,19 @@
Doorkeeper::AccessToken.create_indexes
end
end

module Doorkeeper
class PlaceholderApplicationOwner
include Mongoid::Document

self.store_in :placeholder_application_owners
has_many :applications

end

module OrmHelper
def mock_application_owner
PlaceholderApplicationOwner.new
end
end
end

0 comments on commit 87fdc4f

Please sign in to comment.