Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finishing a build that has a canceled job on a stage #125

Merged
merged 1 commit into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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