diff options
author | Lukas Eipert <leipert@gitlab.com> | 2018-07-18 16:56:19 +0000 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-07-18 16:56:19 +0000 |
commit | 4ff134dfd49d03b66b529256794f054ef1cbc21d (patch) | |
tree | a311a8946890c0fdb17d10cafe80b6faacc073ff /spec/helpers/icons_helper_spec.rb | |
parent | e6b6c7acbc81e646e32ee10f8a4ada3d95597d25 (diff) | |
download | gitlab-ce-4ff134dfd49d03b66b529256794f054ef1cbc21d.tar.gz |
Proper icon validator
Diffstat (limited to 'spec/helpers/icons_helper_spec.rb')
-rw-r--r-- | spec/helpers/icons_helper_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/helpers/icons_helper_spec.rb b/spec/helpers/icons_helper_spec.rb index 93d8e672f8c..82f588d1a08 100644 --- a/spec/helpers/icons_helper_spec.rb +++ b/spec/helpers/icons_helper_spec.rb @@ -55,6 +55,29 @@ describe IconsHelper do expect(sprite_icon(icon_name, size: 72, css_class: 'icon-danger').to_s) .to eq "<svg class=\"s72 icon-danger\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>" end + + describe 'non existing icon' do + non_existing = 'non_existing_icon_sprite' + + it 'should raise in development mode' do + allow(Rails.env).to receive(:development?).and_return(true) + + expect { sprite_icon(non_existing) }.to raise_error(ArgumentError, /is not a known icon/) + end + + it 'should raise in test mode' do + allow(Rails.env).to receive(:test?).and_return(true) + + expect { sprite_icon(non_existing) }.to raise_error(ArgumentError, /is not a known icon/) + end + + it 'should not raise in production mode' do + allow(Rails.env).to receive(:test?).and_return(false) + allow(Rails.env).to receive(:development?).and_return(false) + + expect { sprite_icon(non_existing) }.not_to raise_error + end + end end describe 'file_type_icon_class' do |