diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-05 20:22:00 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-28 13:58:15 +0200 |
commit | 1e138767a652d86458d38665b98c9c2e5d4c3cb8 (patch) | |
tree | 76f9789951a66be76d0f50028aad6f7fa0d66f04 /spec/models/concerns | |
parent | 62f053e4e50dd04933d49622a74dcb89ebe8174e (diff) | |
download | gitlab-ce-1e138767a652d86458d38665b98c9c2e5d4c3cb8.tar.gz |
Fix tests failures
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/chronic_duration_attribute_spec.rb | 20 |
1 files changed, 19 insertions, 1 deletions
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 |