Defect #44343 ยป user-destroy-oauth-grants-tokens.patch
| app/models/user.rb | ||
|---|---|---|
|
has_many :email_addresses, :dependent => :delete_all
|
||
|
has_many :reactions, dependent: :delete_all
|
||
|
has_many :webhooks, dependent: :destroy
|
||
|
has_many :oauth_access_grants, :class_name => 'Doorkeeper::AccessGrant',
|
||
|
:foreign_key => :resource_owner_id, :dependent => :delete_all
|
||
|
has_many :oauth_access_tokens, :class_name => 'Doorkeeper::AccessToken',
|
||
|
:foreign_key => :resource_owner_id, :dependent => :delete_all
|
||
|
belongs_to :auth_source
|
||
| test/unit/user_test.rb | ||
|---|---|---|
|
assert_nil Token.find_by_id(token.id)
|
||
|
end
|
||
|
def test_destroy_should_delete_oauth_access_grants
|
||
|
application = Doorkeeper::Application.create!(
|
||
|
:name => 'Test App',
|
||
|
:redirect_uri => 'http://localhost/callback',
|
||
|
:scopes => 'view_issues'
|
||
|
)
|
||
|
grant = Doorkeeper::AccessGrant.create!(
|
||
|
:application_id => application.id,
|
||
|
:resource_owner_id => 2,
|
||
|
:redirect_uri => application.redirect_uri,
|
||
|
:scopes => 'view_issues',
|
||
|
:expires_in => 600
|
||
|
)
|
||
|
User.find(2).destroy
|
||
|
assert_nil User.find_by_id(2)
|
||
|
assert_nil Doorkeeper::AccessGrant.find_by_id(grant.id)
|
||
|
end
|
||
|
def test_destroy_should_delete_oauth_access_tokens
|
||
|
application = Doorkeeper::Application.create!(
|
||
|
:name => 'Test App',
|
||
|
:redirect_uri => 'http://localhost/callback',
|
||
|
:scopes => 'view_issues'
|
||
|
)
|
||
|
token = Doorkeeper::AccessToken.create!(
|
||
|
:application_id => application.id,
|
||
|
:resource_owner_id => 2,
|
||
|
:scopes => 'view_issues',
|
||
|
:expires_in => 7200
|
||
|
)
|
||
|
User.find(2).destroy
|
||
|
assert_nil User.find_by_id(2)
|
||
|
assert_nil Doorkeeper::AccessToken.find_by_id(token.id)
|
||
|
end
|
||
|
def test_destroy_should_delete_watchers
|
||
|
issue = Issue.create!(:project_id => 1, :author_id => 1,
|
||
|
:tracker_id => 1, :subject => 'foo')
|
||