travis-api/spec/lib/services/update_log_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

36 lines
1.0 KiB
Ruby

describe Travis::Services::UpdateLog do
include Travis::Testing::Stubs
let(:service) { described_class.new(user, params) }
let(:params) { { id: log.id, archived_at: Time.now, archive_verified: true } }
before :each do
log.stubs(:update_attributes).returns(true)
service.stubs(:run_service).with(:find_log, id: log.id).returns(log)
end
it 'updates the log' do
log.expects(:update_attributes).with(archived_at: params[:archived_at], archive_verified: true)
service.run
end
describe 'the instrument' do
let(:publisher) { Travis::Notification::Publisher::Memory.new }
let(:event) { publisher.events.last }
before :each do
Travis::Notification.publishers.replace([publisher])
end
it 'publishes a event' do
service.run
event.should publish_instrumentation_event(
event: 'travis.services.update_log.run:completed',
message: "Travis::Services::UpdateLog#run:completed for #<Log id=#{log.id}> params=#{params}",
result: true
)
end
end
end