Commit fca02e24 authored by Eric Eastwood's avatar Eric Eastwood

Update styling and use Gitlab::Utils.to_boolean

parent de0c4730
...@@ -39,8 +39,9 @@ module PageLayoutHelper ...@@ -39,8 +39,9 @@ module PageLayoutHelper
end end
def favicon def favicon
return 'favicon-yellow.ico' if ENV['CANARY'] == 'true' return 'favicon-yellow.ico' if Gitlab::Utils.to_boolean(ENV['CANARY'])
return 'favicon-blue.ico' if Rails.env.development? return 'favicon-blue.ico' if Rails.env.development?
'favicon.ico' 'favicon.ico'
end end
......
...@@ -7,12 +7,13 @@ class StatusEntity < Grape::Entity ...@@ -7,12 +7,13 @@ class StatusEntity < Grape::Entity
expose :details_path expose :details_path
expose :favicon do |status| expose :favicon do |status|
dir = 'ci_favicons' dir =
if Gitlab::Utils.to_boolean(ENV['CANARY'])
if ENV['CANARY'] File.join('ci_favicons', 'canary')
dir = File.join(dir, 'canary')
elsif Rails.env.development? elsif Rails.env.development?
dir = File.join(dir, 'dev') File.join('ci_favicons', 'dev')
else
'ci_favicons'
end end
ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico")) ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico"))
......
---
title: Add yellow favicon to differientate canary environment
merge_request: 12477
author:
type: changed
...@@ -50,6 +50,11 @@ describe PageLayoutHelper do ...@@ -50,6 +50,11 @@ describe PageLayoutHelper do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development')) allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
expect(helper.favicon).to eq 'favicon-blue.ico' expect(helper.favicon).to eq 'favicon-blue.ico'
end end
it 'has yellow favicon for canary' do
stub_env('CANARY', 'true')
expect(helper.favicon).to eq 'favicon-yellow.ico'
end
end end
describe 'page_image' do describe 'page_image' do
......
...@@ -25,5 +25,10 @@ describe StatusEntity do ...@@ -25,5 +25,10 @@ describe StatusEntity do
allow(Rails.env).to receive(:development?) { true } allow(Rails.env).to receive(:development?) { true }
expect(entity.as_json[:favicon]).to match_asset_path('/assets/ci_favicons/dev/favicon_status_success.ico') expect(entity.as_json[:favicon]).to match_asset_path('/assets/ci_favicons/dev/favicon_status_success.ico')
end end
it 'contains a canavary namespaced favicon if canary env' do
stub_env('CANARY', 'true')
expect(entity.as_json[:favicon]).to match_asset_path('/assets/ci_favicons/canary/favicon_status_success.ico')
end
end end
end end
...@@ -28,7 +28,7 @@ build: ...@@ -28,7 +28,7 @@ build:
canary: canary:
stage: canary stage: canary
script: script:
- CANARY=true command canary - command canary
environment: environment:
name: production name: production
url: http://$CI_PROJECT_PATH_SLUG.$KUBE_DOMAIN url: http://$CI_PROJECT_PATH_SLUG.$KUBE_DOMAIN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment