trigger sync in the auth endpoint, not the user model
This commit is contained in:
parent
da4c7f26e6
commit
6603990fe4
|
@ -289,6 +289,7 @@ class Travis::Api::App
|
||||||
user.update_attributes info
|
user.update_attributes info
|
||||||
else
|
else
|
||||||
self.user = ::User.create! info
|
self.user = ::User.create! info
|
||||||
|
Travis.run_service(:sync_user, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
Travis::Github::Oauth.track_scopes(user) # unless Travis.env == 'test'
|
Travis::Github::Oauth.track_scopes(user) # unless Travis.env == 'test'
|
||||||
|
|
|
@ -62,9 +62,9 @@ describe Travis::Api::App::Endpoint::Authorization::UserManager do
|
||||||
|
|
||||||
context 'without existing user' do
|
context 'without existing user' do
|
||||||
it 'creates new user' do
|
it 'creates new user' do
|
||||||
user = stub('user', login: 'drogus', github_id: 456)
|
|
||||||
User.expects(:find_by_github_id).with(456).returns(nil)
|
User.expects(:find_by_github_id).with(456).returns(nil)
|
||||||
attributes = { login: 'drogus', github_id: 456, github_oauth_token: 'abc123', education: false }.stringify_keys
|
attributes = { login: 'drogus', github_id: 456, github_oauth_token: 'abc123', education: false }.stringify_keys
|
||||||
|
user = User.create(id: 1, login: 'drogus', github_id: 456)
|
||||||
User.expects(:create!).with(attributes).returns(user)
|
User.expects(:create!).with(attributes).returns(user)
|
||||||
manager.stubs(:education).returns(false)
|
manager.stubs(:education).returns(false)
|
||||||
|
|
||||||
|
|
8
vendor/travis-core/lib/travis/model/user.rb
vendored
8
vendor/travis-core/lib/travis/model/user.rb
vendored
|
@ -17,7 +17,7 @@ class User < Travis::Model
|
||||||
|
|
||||||
before_create :set_as_recent
|
before_create :set_as_recent
|
||||||
after_create :create_a_token
|
after_create :create_a_token
|
||||||
after_commit :sync, on: :create
|
# after_commit :sync, on: :create
|
||||||
before_save :track_previous_changes
|
before_save :track_previous_changes
|
||||||
|
|
||||||
serialize :github_scopes
|
serialize :github_scopes
|
||||||
|
@ -66,9 +66,9 @@ class User < Travis::Model
|
||||||
synced_at.nil?
|
synced_at.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync
|
# def sync
|
||||||
Travis.run_service(:sync_user, self) # TODO move to the authentication endpoint, or create a separate service
|
# Travis.run_service(:sync_user, self) # TODO move to the authentication endpoint, or create a separate service
|
||||||
end
|
# end
|
||||||
|
|
||||||
def syncing?
|
def syncing?
|
||||||
is_syncing?
|
is_syncing?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user