diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-10 19:43:13 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-05-10 19:48:24 +0300 |
commit | 17755364f81112dbc5d2791022018a06242ac4a5 (patch) | |
tree | b7f85d9ff6e805d0f30668157fee8a45012c2540 /spec | |
parent | bd581a35c204444344b611cea33fbf6273feeaa8 (diff) |
Merge branch 'bw-fix-sha-attribute' into 'master'
ShaAttribute crashes with ArgumentError if column doesn't exist
See merge request gitlab-org/gitlab-ce!18880
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/concerns/sha_attribute_spec.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/spec/models/concerns/sha_attribute_spec.rb b/spec/models/concerns/sha_attribute_spec.rb index 592feddf1dc..0d3beb6a6e3 100644 --- a/spec/models/concerns/sha_attribute_spec.rb +++ b/spec/models/concerns/sha_attribute_spec.rb @@ -36,24 +36,26 @@ describe ShaAttribute do end context 'when the table does not exist' do - it 'allows the attribute to be added' do + it 'allows the attribute to be added and issues a warning' do allow(model).to receive(:table_exists?).and_return(false) expect(model).not_to receive(:columns) expect(model).to receive(:attribute) + expect(model).to receive(:warn) model.sha_attribute(:name) end end context 'when the column does not exist' do - it 'raises ArgumentError' do + it 'allows the attribute to be added and issues a warning' do allow(model).to receive(:table_exists?).and_return(true) expect(model).to receive(:columns) - expect(model).not_to receive(:attribute) + expect(model).to receive(:attribute) + expect(model).to receive(:warn) - expect { model.sha_attribute(:no_name) }.to raise_error(ArgumentError) + model.sha_attribute(:no_name) end end |