travis-api/spec/lib/services/sync_user_spec.rb
Aakriti Gupta 65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00

35 lines
855 B
Ruby

describe Travis::Services::SyncUser do
include Travis::Testing::Stubs
let(:publisher) { stub('publisher', :publish => true) }
let(:service) { described_class.new(user, {}) }
describe 'given the user is not currently syncing' do
before :each do
user.stubs(:update_column)
user.stubs(:syncing?).returns(false)
end
it 'enqueues a sync job' do
Travis::Sidekiq::SynchronizeUser.expects(:perform_async).with(user.id)
service.run
end
it 'sets the user to syncing' do
user.expects(:update_column).with(:is_syncing, true)
service.run
end
end
describe 'given the user is currently syncing' do
before :each do
user.stubs(:syncing?).returns(true)
end
it 'does not set the user to syncing' do
user.expects(:update_column).never
service.run
end
end
end