Commit 1e138767 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Fix tests failures

parent 62f053e4
...@@ -19,8 +19,8 @@ module ChronicDurationAttribute ...@@ -19,8 +19,8 @@ module ChronicDurationAttribute
def chronic_duration_attr_writer(virtual_attribute, source_attribute) def chronic_duration_attr_writer(virtual_attribute, source_attribute)
define_method("#{virtual_attribute}=") do |value| define_method("#{virtual_attribute}=") do |value|
new_value = ChronicDuration.parse(value).to_i new_value = ChronicDuration.parse(value).to_i unless value.nil?
new_value = nil if new_value <= 0 new_value = nil if !new_value.nil? && new_value <= 0
self.send("#{source_attribute}=", new_value) # rubocop:disable GitlabSecurity/PublicSend self.send("#{source_attribute}=", new_value) # rubocop:disable GitlabSecurity/PublicSend
......
...@@ -46,6 +46,7 @@ describe('Sidebar detail row', () => { ...@@ -46,6 +46,7 @@ describe('Sidebar detail row', () => {
vm = new SidebarDetailRow({ vm = new SidebarDetailRow({
propsData: { propsData: {
helpUrl: 'help url', helpUrl: 'help url',
value: 'foo',
}, },
}).$mount(); }).$mount();
}); });
......
...@@ -29,11 +29,29 @@ shared_examples 'ChronicDurationAttribute writer' do ...@@ -29,11 +29,29 @@ shared_examples 'ChronicDurationAttribute writer' do
expect(subject.send(source_field)).to eq(600) expect(subject.send(source_field)).to eq(600)
end end
it 'writes null when empty input is used' do it 'writes nil when empty input is used' do
subject.send("#{virtual_field}=", '') subject.send("#{virtual_field}=", '')
expect(subject.send(source_field)).to be_nil expect(subject.send(source_field)).to be_nil
end end
it 'writes nil when negative input is used' do
allow(ChronicDuration).to receive(:parse).and_return(-10)
subject.send("#{virtual_field}=", '-10m')
expect(subject.send(source_field)).to be_nil
end
it 'writes nil when nil input is used' do
subject.send("#{virtual_field}=", nil)
expect(subject.send(source_field)).to be_nil
end
it "doesn't raise exception when nil input is used" do
expect { subject.send("#{virtual_field}=", nil) }.not_to raise_error(NoMethodError)
end
end end
describe 'ChronicDurationAttribute' do describe 'ChronicDurationAttribute' do
......
...@@ -30,7 +30,7 @@ describe Ci::RetryBuildService do ...@@ -30,7 +30,7 @@ describe Ci::RetryBuildService do
runner_id tag_taggings taggings tags trigger_request_id runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried failure_reason user_id auto_canceled_by_id retried failure_reason
artifacts_file_store artifacts_metadata_store artifacts_file_store artifacts_metadata_store
metadata].freeze build_metadata].freeze
shared_examples 'build duplication' do shared_examples 'build duplication' do
let(:another_pipeline) { create(:ci_empty_pipeline, project: project) } let(:another_pipeline) { create(:ci_empty_pipeline, project: project) }
......
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