Skip to content

Commit

Permalink
fix finishing a build that has a canceled job on a stage
Browse files Browse the repository at this point in the history
  • Loading branch information
svenfuchs committed Aug 29, 2017
1 parent 65063a8 commit a4b4e70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/travis/hub/model/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Stage < ActiveRecord::Base

event :start, if: :start?
event :finish, if: :finish?, to: Build::FINISHED_STATES
event :cancel
event :cancel, if: :finish?
event :restart
event :all, after: :propagate

Expand Down
14 changes: 14 additions & 0 deletions spec/travis/hub/model/stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,18 @@ def reload

it { expect(Travis::Event).to have_received(:dispatch).times(3) }
end

describe 'cancel and fail' do
before { jobs[0].cancel! }
before { jobs[2].cancel! }
before { jobs[1].finish!(state: :failed, finished_at: now) }
before { reload }

it { expect(build.state).to eq :canceled }
it { expect(stages[0].state).to eq :canceled }
it { expect(stages[1].state).to eq :canceled }
it { expect(jobs[0].state).to eq :canceled }
it { expect(jobs[1].state).to eq :failed }
it { expect(jobs[2].state).to eq :canceled }
end
end

0 comments on commit a4b4e70

Please sign in to comment.