BigW Consortium Gitlab

Commit 6f07b84d by Filipa Lacerda Committed by Lin Jen-Shin

Merge branch 'use-favicon-full-path-for-pipeline-status-favicon' into 'master'

Use favicon full path See merge request !10676
parent 435e4090
...@@ -364,9 +364,9 @@ ...@@ -364,9 +364,9 @@
}); });
}; };
w.gl.utils.setFavicon = (iconName) => { w.gl.utils.setFavicon = (faviconPath) => {
if (faviconEl && iconName) { if (faviconEl && faviconPath) {
faviconEl.setAttribute('href', `/assets/${iconName}.ico`); faviconEl.setAttribute('href', faviconPath);
} }
}; };
...@@ -381,8 +381,8 @@ ...@@ -381,8 +381,8 @@
url: pageUrl, url: pageUrl,
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if (data && data.icon) { if (data && data.favicon) {
gl.utils.setFavicon(`ci_favicons/${data.icon}`); gl.utils.setFavicon(data.favicon);
} else { } else {
gl.utils.resetFavicon(); gl.utils.resetFavicon();
} }
......
class StatusEntity < Grape::Entity class StatusEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
expose :icon, :favicon, :text, :label, :group expose :icon, :text, :label, :group
expose :has_details?, as: :has_details expose :has_details?, as: :has_details
expose :details_path expose :details_path
expose :favicon do |status|
ActionController::Base.helpers.image_path(File.join('ci_favicons', "#{status.favicon}.ico"))
end
end end
...@@ -60,7 +60,7 @@ describe Projects::BuildsController do ...@@ -60,7 +60,7 @@ describe Projects::BuildsController do
expect(json_response['text']).to eq status.text expect(json_response['text']).to eq status.text
expect(json_response['label']).to eq status.label expect(json_response['label']).to eq status.label
expect(json_response['icon']).to eq status.icon expect(json_response['icon']).to eq status.icon
expect(json_response['favicon']).to eq status.favicon expect(json_response['favicon']).to eq "/assets/ci_favicons/#{status.favicon}.ico"
end end
end end
end end
...@@ -1208,7 +1208,7 @@ describe Projects::MergeRequestsController do ...@@ -1208,7 +1208,7 @@ describe Projects::MergeRequestsController do
expect(json_response['text']).to eq status.text expect(json_response['text']).to eq status.text
expect(json_response['label']).to eq status.label expect(json_response['label']).to eq status.label
expect(json_response['icon']).to eq status.icon expect(json_response['icon']).to eq status.icon
expect(json_response['favicon']).to eq status.favicon expect(json_response['favicon']).to eq "/assets/ci_favicons/#{status.favicon}.ico"
end end
end end
......
...@@ -86,7 +86,7 @@ describe Projects::PipelinesController do ...@@ -86,7 +86,7 @@ describe Projects::PipelinesController do
expect(json_response['text']).to eq status.text expect(json_response['text']).to eq status.text
expect(json_response['label']).to eq status.label expect(json_response['label']).to eq status.label
expect(json_response['icon']).to eq status.icon expect(json_response['icon']).to eq status.icon
expect(json_response['favicon']).to eq status.favicon expect(json_response['favicon']).to eq "/assets/ci_favicons/#{status.favicon}.ico"
end end
end end
end end
...@@ -313,7 +313,7 @@ require('~/lib/utils/common_utils'); ...@@ -313,7 +313,7 @@ require('~/lib/utils/common_utils');
describe('gl.utils.setFavicon', () => { describe('gl.utils.setFavicon', () => {
it('should set page favicon to provided favicon', () => { it('should set page favicon to provided favicon', () => {
const faviconName = 'custom_favicon'; const faviconPath = '//custom_favicon';
const fakeLink = { const fakeLink = {
setAttribute() {}, setAttribute() {},
}; };
...@@ -321,9 +321,9 @@ require('~/lib/utils/common_utils'); ...@@ -321,9 +321,9 @@ require('~/lib/utils/common_utils');
spyOn(window.document, 'getElementById').and.callFake(() => fakeLink); spyOn(window.document, 'getElementById').and.callFake(() => fakeLink);
spyOn(fakeLink, 'setAttribute').and.callFake((attr, val) => { spyOn(fakeLink, 'setAttribute').and.callFake((attr, val) => {
expect(attr).toEqual('href'); expect(attr).toEqual('href');
expect(val.indexOf('/assets/custom_favicon.ico') > -1).toBe(true); expect(val.indexOf(faviconPath) > -1).toBe(true);
}); });
gl.utils.setFavicon(faviconName); gl.utils.setFavicon(faviconPath);
}); });
}); });
...@@ -345,13 +345,12 @@ require('~/lib/utils/common_utils'); ...@@ -345,13 +345,12 @@ require('~/lib/utils/common_utils');
describe('gl.utils.setCiStatusFavicon', () => { describe('gl.utils.setCiStatusFavicon', () => {
it('should set page favicon to CI status favicon based on provided status', () => { it('should set page favicon to CI status favicon based on provided status', () => {
const BUILD_URL = `${gl.TEST_HOST}/frontend-fixtures/builds-project/builds/1/status.json`; const BUILD_URL = `${gl.TEST_HOST}/frontend-fixtures/builds-project/builds/1/status.json`;
const FAVICON_PATH = 'ci_favicons/'; const FAVICON_PATH = '//icon_status_success';
const FAVICON = 'icon_status_success';
const spySetFavicon = spyOn(gl.utils, 'setFavicon').and.stub(); const spySetFavicon = spyOn(gl.utils, 'setFavicon').and.stub();
const spyResetFavicon = spyOn(gl.utils, 'resetFavicon').and.stub(); const spyResetFavicon = spyOn(gl.utils, 'resetFavicon').and.stub();
spyOn($, 'ajax').and.callFake(function (options) { spyOn($, 'ajax').and.callFake(function (options) {
options.success({ icon: FAVICON }); options.success({ favicon: FAVICON_PATH });
expect(spySetFavicon).toHaveBeenCalledWith(FAVICON_PATH + FAVICON); expect(spySetFavicon).toHaveBeenCalledWith(FAVICON_PATH);
options.success(); options.success();
expect(spyResetFavicon).toHaveBeenCalled(); expect(spyResetFavicon).toHaveBeenCalled();
options.error(); options.error();
......
...@@ -38,7 +38,7 @@ describe BuildSerializer do ...@@ -38,7 +38,7 @@ describe BuildSerializer do
expect(subject[:text]).to eq(status.text) expect(subject[:text]).to eq(status.text)
expect(subject[:label]).to eq(status.label) expect(subject[:label]).to eq(status.label)
expect(subject[:icon]).to eq(status.icon) expect(subject[:icon]).to eq(status.icon)
expect(subject[:favicon]).to eq(status.favicon) expect(subject[:favicon]).to eq("/assets/ci_favicons/#{status.favicon}.ico")
end end
end end
end end
......
...@@ -106,7 +106,7 @@ describe PipelineSerializer do ...@@ -106,7 +106,7 @@ describe PipelineSerializer do
expect(subject[:text]).to eq(status.text) expect(subject[:text]).to eq(status.text)
expect(subject[:label]).to eq(status.label) expect(subject[:label]).to eq(status.label)
expect(subject[:icon]).to eq(status.icon) expect(subject[:icon]).to eq(status.icon)
expect(subject[:favicon]).to eq(status.favicon) expect(subject[:favicon]).to eq("/assets/ci_favicons/#{status.favicon}.ico")
end end
end end
end end
......
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