moved the monkey patching to a model, need to do a couple of validations

This commit is contained in:
Ilya Zhitomirskiy 2011-06-15 18:30:05 -07:00
parent b3cee70ead
commit 75a1012c1c
3 changed files with 25 additions and 13 deletions

View file

@ -81,16 +81,3 @@ class AuthorizationsController < ApplicationController
!OAuth2::Provider.client_class.exists?(:nonce => nonce) !OAuth2::Provider.client_class.exists?(:nonce => nonce)
end end
end end
OAuth2::Provider.client_class.instance_eval do
def self.create_or_reset_from_manifest! manifest
if obj = find_by_name(manifest['name'])
obj.oauth_identifier = OAuth2::Provider::Random.base62(16)
obj.oauth_secret = OAuth2::Provider::Random.base62(32)
obj.save!
obj
else
create!(manifest)
end
end
end

View file

@ -0,0 +1,12 @@
class OAuth2::Provider::Models::ActiveRecord::Client
def self.create_or_reset_from_manifest! manifest
if obj = find_by_name(manifest['name'])
obj.oauth_identifier = OAuth2::Provider::Random.base62(16)
obj.oauth_secret = OAuth2::Provider::Random.base62(32)
obj.save!
obj
else
create!(manifest)
end
end
end

View file

@ -0,0 +1,13 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
require 'spec_helper'
describe OAuth2::Provider::Models::ActiveRecord::Client do
#TODO
describe 'validations'do
it 'is pending for now'
end
end