Skip to content

Commit

Permalink
No need of application owner mock
Browse files Browse the repository at this point in the history
FactoryGirl does it in one line.
  • Loading branch information
tute committed Mar 8, 2015
1 parent d983f5f commit 09cb679
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 46 deletions.
2 changes: 2 additions & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
sequence(:name) { |n| "Application #{n}" }
redirect_uri 'https://app.com/callback'
end

factory :user
end
4 changes: 1 addition & 3 deletions spec/models/doorkeeper/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

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) }
Expand Down Expand Up @@ -32,7 +30,7 @@ module Doorkeeper
context 'application owner is required' do
before(:each) do
require_owner
@owner = mock_application_owner
@owner = FactoryGirl.build_stubbed(:user)
end

it 'is invalid without an owner' do
Expand Down
8 changes: 0 additions & 8 deletions spec/support/orm/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# 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
15 changes: 0 additions & 15 deletions spec/support/orm/mongo_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,3 @@
Doorkeeper::AccessToken.create_indexes
end
end

module Doorkeeper
class PlaceholderApplicationOwner
include MongoMapper::Document

set_collection_name 'placeholder_application_owners'
many :applications, class: Doorkeeper::Application
end

module OrmHelper
def mock_application_owner
PlaceholderApplicationOwner.new
end
end
end
20 changes: 0 additions & 20 deletions spec/support/orm/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,3 @@
Doorkeeper::AccessToken.create_indexes
end
end

module Doorkeeper
class PlaceholderApplicationOwner
include Mongoid::Document

if ::Mongoid::VERSION >= '3'
self.store_in collection: :placeholder_application_owners
else
self.store_in :placeholder_application_owners
end

has_many :applications
end

module OrmHelper
def mock_application_owner
PlaceholderApplicationOwner.new
end
end
end

2 comments on commit 09cb679

@jormon
Copy link
Contributor

@jormon jormon commented on 09cb679 Jul 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm.. this causes issues for any application that includes doorkeeper's specs, as per: #55

@jormon
Copy link
Contributor

@jormon jormon commented on 09cb679 Aug 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potentially fixed in #871

Please sign in to comment.