Commit 12401758 authored by Tomasz Maczukin's avatar Tomasz Maczukin

BuildMetadata styling improvements

parent d58d3098
...@@ -19,13 +19,13 @@ module Ci ...@@ -19,13 +19,13 @@ module Ci
} }
def save_timeout_state! def save_timeout_state!
project_timeout = build.project&.build_timeout return unless build.runner.present?
timeout = [project_timeout, build.runner&.maximum_timeout].compact.min
self.timeout = timeout project_timeout = build.project&.build_timeout
self.timeout_source = timeout < project_timeout ? :runner_timeout_source : :project_timeout_source timeout = [project_timeout, build.runner.maximum_timeout].compact.min
timeout_source = timeout < project_timeout ? :runner_timeout_source : :project_timeout_source
save! update_attributes(timeout: timeout, timeout_source: timeout_source)
end end
end end
end end
...@@ -1283,8 +1283,10 @@ describe Ci::Build do ...@@ -1283,8 +1283,10 @@ describe Ci::Build do
build.run! build.run!
end end
it 'returns project timeout configuration' do context 'when runner is not assigned' do
is_expected.to eq(project2.build_timeout) it 'returns project timeout configuration' do
is_expected.to be_nil
end
end end
context 'when runner sets timeout to bigger value' do context 'when runner sets timeout to bigger value' do
...@@ -2045,8 +2047,7 @@ describe Ci::Build do ...@@ -2045,8 +2047,7 @@ describe Ci::Build do
let(:job) { create(:ci_build, :pending, runner: runner) } let(:job) { create(:ci_build, :pending, runner: runner) }
before do before do
job.project.build_timeout = 1800 job.project.update_attribute(:build_timeout, 1800)
job.project.save!
end end
shared_examples 'saves data on transition' do shared_examples 'saves data on transition' do
...@@ -2064,8 +2065,7 @@ describe Ci::Build do ...@@ -2064,8 +2065,7 @@ describe Ci::Build do
let(:expected_timeout_source) { 'runner_timeout_source' } let(:expected_timeout_source) { 'runner_timeout_source' }
before do before do
runner.maximum_timeout = 900 runner.update_attribute(:maximum_timeout, 900)
runner.save!
end end
it_behaves_like 'saves data on transition' it_behaves_like 'saves data on transition'
...@@ -2076,8 +2076,7 @@ describe Ci::Build do ...@@ -2076,8 +2076,7 @@ describe Ci::Build do
let(:expected_timeout_source) { 'project_timeout_source' } let(:expected_timeout_source) { 'project_timeout_source' }
before do before do
runner.maximum_timeout = 3600 runner.update_attribute(:maximum_timeout, 3600)
runner.save!
end end
it_behaves_like 'saves data on transition' it_behaves_like 'saves data on transition'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment