diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-05 22:22:00 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-28 14:58:15 +0300 |
commit | 1e138767a652d86458d38665b98c9c2e5d4c3cb8 (patch) | |
tree | 76f9789951a66be76d0f50028aad6f7fa0d66f04 | |
parent | 62f053e4e50dd04933d49622a74dcb89ebe8174e (diff) |
Fix tests failures
4 files changed, 23 insertions, 4 deletions
diff --git a/app/models/concerns/chronic_duration_attribute.rb b/app/models/concerns/chronic_duration_attribute.rb index 87c60a2b7d5..15095d0b758 100644 --- a/app/models/concerns/chronic_duration_attribute.rb +++ b/app/models/concerns/chronic_duration_attribute.rb @@ -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 diff --git a/spec/javascripts/jobs/sidebar_detail_row_spec.js b/spec/javascripts/jobs/sidebar_detail_row_spec.js index e66cb4d9809..9fe5cf78b8b 100644 --- a/spec/javascripts/jobs/sidebar_detail_row_spec.js +++ b/spec/javascripts/jobs/sidebar_detail_row_spec.js @@ -46,6 +46,7 @@ describe('Sidebar detail row', () => { vm = new SidebarDetailRow({ propsData: { helpUrl: 'help url', + value: 'foo', }, }).$mount(); }); diff --git a/spec/models/concerns/chronic_duration_attribute_spec.rb b/spec/models/concerns/chronic_duration_attribute_spec.rb index b1ffeb0c74f..b25475d4fdb 100644 --- a/spec/models/concerns/chronic_duration_attribute_spec.rb +++ b/spec/models/concerns/chronic_duration_attribute_spec.rb @@ -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 diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 8de0bdf92e2..415302e84f2 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -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) } |