Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a6f3f6b8
Commit
a6f3f6b8
authored
Sep 26, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract favicon logic to lib class
parent
606b23dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
31 deletions
+49
-31
app/helpers/appearances_helper.rb
app/helpers/appearances_helper.rb
+0
-4
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+1
-5
lib/gitlab/favicon.rb
lib/gitlab/favicon.rb
+23
-0
spec/helpers/page_layout_helper_spec.rb
spec/helpers/page_layout_helper_spec.rb
+0
-22
spec/lib/gitlab/favicon_spec.rb
spec/lib/gitlab/favicon_spec.rb
+25
-0
No files found.
app/helpers/appearances_helper.rb
View file @
a6f3f6b8
...
...
@@ -33,8 +33,4 @@ module AppearancesHelper
render
'shared/logo_type.svg'
end
end
def
brand_favicon
brand_item
&
.
favicon
end
end
app/helpers/page_layout_helper.rb
View file @
a6f3f6b8
...
...
@@ -39,11 +39,7 @@ module PageLayoutHelper
end
def
favicon
return
brand_favicon
.
default
.
url
if
brand_favicon
return
'favicon-yellow.ico'
if
Gitlab
::
Utils
.
to_boolean
(
ENV
[
'CANARY'
])
return
'favicon-blue.ico'
if
Rails
.
env
.
development?
'favicon.ico'
Gitlab
::
Favicon
.
default
end
def
page_image
...
...
lib/gitlab/favicon.rb
0 → 100644
View file @
a6f3f6b8
module
Gitlab
class
Favicon
class
<<
self
def
default
return
appearance_favicon
.
default
.
url
if
appearance_favicon
return
'favicon-yellow.ico'
if
Gitlab
::
Utils
.
to_boolean
(
ENV
[
'CANARY'
])
return
'favicon-blue.ico'
if
Rails
.
env
.
development?
'favicon.ico'
end
private
def
appearance
@appearance
||=
Appearance
.
current
end
def
appearance_favicon
appearance
&
.
favicon
end
end
end
end
spec/helpers/page_layout_helper_spec.rb
View file @
a6f3f6b8
...
...
@@ -40,28 +40,6 @@ describe PageLayoutHelper do
end
end
describe
'favicon'
do
it
'defaults to favicon.ico'
do
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'production'
))
expect
(
helper
.
favicon
).
to
eq
'favicon.ico'
end
it
'has blue favicon for development'
do
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'development'
))
expect
(
helper
.
favicon
).
to
eq
'favicon-blue.ico'
end
it
'has yellow favicon for canary'
do
stub_env
(
'CANARY'
,
'true'
)
expect
(
helper
.
favicon
).
to
eq
'favicon-yellow.ico'
end
it
'uses the custom favicon if an favicon appearance is present'
do
create
:appearance
,
favicon:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/dk.png'
))
expect
(
helper
.
favicon
).
to
match
%r{/uploads/-/system/appearance/favicon/
\d
+/default_dk.ico}
end
end
describe
'page_image'
do
it
'defaults to the GitLab logo'
do
expect
(
helper
.
page_image
).
to
match_asset_path
'assets/gitlab_logo.png'
...
...
spec/lib/gitlab/favicon_spec.rb
0 → 100644
View file @
a6f3f6b8
require
'rails_helper'
RSpec
.
describe
Gitlab
::
Favicon
do
describe
'.default'
do
it
'defaults to favicon.ico'
do
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'production'
))
expect
(
described_class
.
default
).
to
eq
'favicon.ico'
end
it
'has blue favicon for development'
do
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'development'
))
expect
(
described_class
.
default
).
to
eq
'favicon-blue.ico'
end
it
'has yellow favicon for canary'
do
stub_env
(
'CANARY'
,
'true'
)
expect
(
described_class
.
favicon
).
to
eq
'favicon-yellow.ico'
end
it
'uses the custom favicon if a favicon appearance is present'
do
create
:appearance
,
favicon:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/dk.png'
))
expect
(
described_class
.
default
).
to
match
%r{/uploads/-/system/appearance/favicon/
\d
+/default_dk.ico}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment