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

Fix tests failures

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