Remove specs from vendored travis-core

This commit is contained in:
Ana Rosas 2016-07-01 07:25:51 -07:00 committed by Aakriti Gupta
parent 5dd513f79b
commit 9e2fff6e0a
3 changed files with 0 additions and 182 deletions

View File

@ -1,50 +0,0 @@
describe Travis::Services::CancelBuild do
let(:repo) { Factory(:repository) }
let!(:job) { Factory(:test, repository: repo, state: :created) }
let!(:passed_job) { Factory(:test, repository: repo, state: :passed) }
let(:build) { Factory(:build, repository: repo) }
let(:params) { { id: build.id, source: 'tests' } }
let(:user) { Factory(:user) }
let(:service) { described_class.new(user, params) }
before do
build.matrix.destroy_all
build.matrix << passed_job
build.matrix << job
end
describe 'run' do
it 'should cancel the build if it\'s cancelable' do
job.stubs(:cancelable?).returns(true)
service.stubs(:authorized?).returns(true)
publisher = mock('publisher')
service.stubs(:publisher).returns(publisher)
publisher.expects(:publish).with(type: 'cancel_job', job_id: job.id, source: 'tests')
publisher.expects(:publish).with(type: 'cancel_job', job_id: passed_job.id, source: 'tests')
expect {
expect {
service.run
}.to change { build.reload.state }
}.to change { job.reload.state }
job.state.should == 'canceled'
build.state.should == 'canceled'
end
it 'should not cancel the job if it\'s not cancelable' do
job.stubs(:cancelable?).returns(false)
expect {
service.run
}.to_not change { build.reload.state }
end
it 'should not be able to cancel job if user does not have any permissions' do
user.permissions.destroy_all
service.can_cancel?.should be false
end
end
end

View File

@ -1,40 +0,0 @@
describe Travis::Services::CancelJob do
let(:repo) { Factory(:repository) }
let!(:job) { Factory(:test, repository: repo, state: :created) }
let(:params) { { id: job.id, source: 'tests' } }
let(:user) { Factory(:user) }
let(:service) { described_class.new(user, params) }
describe 'run' do
it 'should cancel the job if it\'s cancelable' do
job.stubs(:cancelable?).returns(true)
service.stubs(:authorized?).returns(true)
publisher = mock('publisher')
service.stubs(:publisher).returns(publisher)
publisher.expects(:publish).with(type: 'cancel_job', job_id: job.id, source: 'tests')
expect {
service.run
}.to change { job.reload.state }
job.state.should == 'canceled'
end
it 'should not cancel the job if it\'s not cancelable' do
job.state.should == :created
job.stubs(:cancelable?).returns(false)
expect {
service.run
}.to_not change { job.state }
end
it 'should not be able to cancel job if user does not have pull permission' do
user.permissions.destroy_all
service.can_cancel?.should be false
end
end
end

View File

@ -1,92 +0,0 @@
describe Travis::Services::ResetModel do
let(:user) { User.first || Factory(:user) }
before :each do
Travis.config.roles = {}
end
describe 'given a job_id' do
let(:service) { described_class.new(user, job_id: job.id, token: 'token') }
let(:job) { Factory(:test, state: :passed) }
before :each do
service.stubs(:service).with(:find_job, id: job.id).returns(stub(run: job))
end
it 'resets the job' do
user.permissions.create!(repository_id: job.repository_id, pull: true)
job.expects(:reset!)
service.run
end
it 'has message: all cool' do
user.permissions.create!(repository_id: job.repository_id, pull: true)
service.run
service.messages.should == [{ notice: 'The job was successfully restarted.' }]
end
it 'has message: missing permissions and can not be enqueued' do
job.stubs(:resetable?).returns(false)
service.run
service.messages.should == [
{ error: 'You do not seem to have sufficient permissions.' },
{ error: 'This job currently can not be restarted.' }
]
end
end
describe 'given a build_id' do
let(:service) { described_class.new(user, build_id: build.id, token: 'token') }
let(:build) { Factory(:build, state: 'passed') }
before :each do
service.stubs(:service).with(:find_build, id: build.id).returns(stub(run: build))
end
it 'resets the build (given no roles configuration and the user has permissions)' do
user.permissions.create!(repository_id: build.repository_id, pull: true)
build.expects(:reset!)
service.run
end
it 'resets the build (given roles configuration and the user has permissions)' do
Travis.config.roles.reset_model = 'push'
user.permissions.create!(repository_id: build.repository_id, push: true)
build.expects(:reset!)
service.run
end
it 'does not reset the build (given no roles configuration and the user does not have permissions)' do
build.expects(:reset!).never
service.run
end
it 'does not reset the build (given roles configuration and the user does not have permissions)' do
Travis.config.roles.reset_model = 'push'
build.expects(:reset!).never
service.run
end
describe '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.reset_model.run:completed',
message: "Travis::Services::ResetModel#run:completed build_id=#{build.id} not accepted",
data: {
type: :build,
id: build.id,
accept?: false
}
)
end
end
end
end