Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Eipert <leipert@gitlab.com>2018-07-18 19:56:19 +0300
committerMike Greiling <mike@pixelcog.com>2018-07-18 19:56:19 +0300
commit4ff134dfd49d03b66b529256794f054ef1cbc21d (patch)
treea311a8946890c0fdb17d10cafe80b6faacc073ff /spec/helpers
parente6b6c7acbc81e646e32ee10f8a4ada3d95597d25 (diff)
Proper icon validator
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/icons_helper_spec.rb23
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