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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e51a5224
Commit
e51a5224
authored
Mar 16, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs
parent
eefc967e
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
221 additions
and
25 deletions
+221
-25
app/controllers/admin/appearances_controller.rb
app/controllers/admin/appearances_controller.rb
+2
-2
app/views/admin/appearances/_form.html.haml
app/views/admin/appearances/_form.html.haml
+1
-1
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+2
-2
app/views/layouts/devise.html.haml
app/views/layouts/devise.html.haml
+2
-0
app/views/layouts/devise_empty.html.haml
app/views/layouts/devise_empty.html.haml
+2
-0
ee/app/controllers/ee/admin/appearances_controller.rb
ee/app/controllers/ee/admin/appearances_controller.rb
+2
-8
ee/app/helpers/ee/appearances_helper.rb
ee/app/helpers/ee/appearances_helper.rb
+6
-10
ee/app/models/ee/appearance.rb
ee/app/models/ee/appearance.rb
+8
-0
ee/app/views/admin/appearances/_system_header_footer_form.html.haml
...ws/admin/appearances/_system_header_footer_form.html.haml
+0
-0
ee/app/views/admin/appearances/ee/_footer_message.html.haml
ee/app/views/admin/appearances/ee/_footer_message.html.haml
+0
-1
ee/app/views/admin/appearances/ee/_header_message.html.haml
ee/app/views/admin/appearances/ee/_header_message.html.haml
+0
-1
ee/spec/features/display_system_header_and_footer_bar_spec.rb
...pec/features/display_system_header_and_footer_bar_spec.rb
+135
-0
ee/spec/helpers/ee/appearances_helper_spec.rb
ee/spec/helpers/ee/appearances_helper_spec.rb
+41
-0
ee/spec/models/ee/appearance_spec.rb
ee/spec/models/ee/appearance_spec.rb
+20
-0
No files found.
app/controllers/admin/appearances_controller.rb
View file @
e51a5224
...
@@ -52,10 +52,10 @@ class Admin::AppearancesController < Admin::ApplicationController
...
@@ -52,10 +52,10 @@ class Admin::AppearancesController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through.
# Only allow a trusted parameter "white list" through.
def
appearance_params
def
appearance_params
params
.
require
(
:appearance
).
permit
(
a
ppearance_params_attribute
s
)
params
.
require
(
:appearance
).
permit
(
a
llowed_appearance_param
s
)
end
end
def
a
ppearance_params_attribute
s
def
a
llowed_appearance_param
s
%i[
%i[
title
title
description
description
...
...
app/views/admin/appearances/_form.html.haml
View file @
e51a5224
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
.hint
.hint
Maximum file size is 1MB. Pages are optimized for a 28px tall header logo
Maximum file size is 1MB. Pages are optimized for a 28px tall header logo
=
render
partial:
'admin/appearances/
ee/
form'
,
locals:
{
form:
f
}
=
render
partial:
'admin/appearances/
system_header_footer_
form'
,
locals:
{
form:
f
}
%fieldset
.sign-in
%fieldset
.sign-in
%legend
%legend
...
...
app/views/layouts/application.html.haml
View file @
e51a5224
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
%body
{
class:
"#{user_application_theme} #{@body_class}"
,
data:
{
page:
body_data_page
,
project:
"#{@project.path if @project}"
,
group:
"#{@group.path if @group}"
,
find_file:
find_file_path
}
}
%body
{
class:
"#{user_application_theme} #{@body_class}"
,
data:
{
page:
body_data_page
,
project:
"#{@project.path if @project}"
,
group:
"#{@group.path if @group}"
,
find_file:
find_file_path
}
}
=
render
"layouts/init_auto_complete"
if
@gfm_form
=
render
"layouts/init_auto_complete"
if
@gfm_form
=
render
'peek/bar'
=
render
'peek/bar'
=
render
"admin/appearances/ee/header_message"
=
header_message
(
@appearance
)
=
render
"layouts/header/default"
=
render
"layouts/header/default"
=
render
'layouts/page'
,
sidebar:
sidebar
,
nav:
nav
=
render
'layouts/page'
,
sidebar:
sidebar
,
nav:
nav
=
render
"admin/appearances/ee/footer_message"
=
footer_message
(
@appearance
)
=
yield
:scripts_body
=
yield
:scripts_body
app/views/layouts/devise.html.haml
View file @
e51a5224
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
%html
.devise-layout-html
%html
.devise-layout-html
=
render
"layouts/head"
=
render
"layouts/head"
%body
.ui_indigo.login-page.application.navless
{
data:
{
page:
body_data_page
}
}
%body
.ui_indigo.login-page.application.navless
{
data:
{
page:
body_data_page
}
}
=
header_message
(
@appearance
)
.page-wrap
.page-wrap
=
render
"layouts/header/empty"
=
render
"layouts/header/empty"
.login-page-broadcast
.login-page-broadcast
...
@@ -40,3 +41,4 @@
...
@@ -40,3 +41,4 @@
=
link_to
"Explore"
,
explore_root_path
=
link_to
"Explore"
,
explore_root_path
=
link_to
"Help"
,
help_path
=
link_to
"Help"
,
help_path
=
link_to
"About GitLab"
,
"https://about.gitlab.com/"
=
link_to
"About GitLab"
,
"https://about.gitlab.com/"
=
footer_message
(
@appearance
)
app/views/layouts/devise_empty.html.haml
View file @
e51a5224
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
%html
{
lang:
"en"
}
%html
{
lang:
"en"
}
=
render
"layouts/head"
=
render
"layouts/head"
%body
.ui_indigo.login-page.application.navless
%body
.ui_indigo.login-page.application.navless
=
header_message
(
@appearance
)
=
render
"layouts/header/empty"
=
render
"layouts/header/empty"
=
render
"layouts/broadcast"
=
render
"layouts/broadcast"
.container.navless-container
.container.navless-container
...
@@ -15,3 +16,4 @@
...
@@ -15,3 +16,4 @@
=
link_to
"Explore"
,
explore_root_path
=
link_to
"Explore"
,
explore_root_path
=
link_to
"Help"
,
help_path
=
link_to
"Help"
,
help_path
=
link_to
"About GitLab"
,
"https://about.gitlab.com/"
=
link_to
"About GitLab"
,
"https://about.gitlab.com/"
=
footer_message
(
@appearance
)
ee/app/controllers/ee/admin/appearances_controller.rb
View file @
e51a5224
module
EE
module
EE
module
Admin
module
Admin
module
AppearancesController
module
AppearancesController
def
appearance_params_attributes
def
allowed_appearance_params
super
+
appearance_params_ee
super
+
%i[
end
private
def
appearance_params_ee
%i[
header_message
header_message
footer_message
footer_message
background_color
background_color
...
...
ee/app/helpers/ee/appearances_helper.rb
View file @
e51a5224
module
EE
module
EE
module
AppearancesHelper
module
AppearancesHelper
def
header_message
(
appearance
)
def
header_message
(
appearance
)
return
unless
appearance
&
.
header_message
.
present
?
return
unless
appearance
&
.
show_header
?
class_names
=
[]
class_names
=
[]
class_names
<<
'with-performance-bar'
if
performance_bar_enabled?
class_names
<<
'with-performance-bar'
if
performance_bar_enabled?
appearance
_message
(
appearance
,
:header_message
,
class_names
)
render
_message
(
appearance
,
:header_message
,
class_names
)
end
end
def
footer_message
(
appearance
)
def
footer_message
(
appearance
)
return
unless
appearance
&
.
footer_message
.
present
?
return
unless
appearance
&
.
show_footer
?
appearance
_message
(
appearance
,
:footer_message
)
render
_message
(
appearance
,
:footer_message
)
end
end
private
private
def
appearance
_message
(
appearance
,
field_sym
,
class_names
=
[])
def
render
_message
(
appearance
,
field_sym
,
class_names
=
[])
class_names
<<
field_sym
.
to_s
.
dasherize
class_names
<<
field_sym
.
to_s
.
dasherize
content_tag
:div
,
class:
class_names
,
style:
message_style
(
appearance
)
do
content_tag
:div
,
class:
class_names
,
style:
message_style
(
appearance
)
do
render_message
(
appearance
,
field_sym
)
::
Banzai
.
render_field
(
appearance
,
field_sym
).
html_safe
end
end
end
end
...
@@ -31,9 +31,5 @@ module EE
...
@@ -31,9 +31,5 @@ module EE
style
<<
"color:
#{
appearance
.
font_color
}
"
style
<<
"color:
#{
appearance
.
font_color
}
"
style
style
end
end
def
render_message
(
appearance
,
field
)
::
Banzai
.
render_field
(
appearance
,
field
).
html_safe
end
end
end
end
end
ee/app/models/ee/appearance.rb
View file @
e51a5224
...
@@ -12,5 +12,13 @@ module EE
...
@@ -12,5 +12,13 @@ module EE
default_value_for
:background_color
,
'#E75E40'
default_value_for
:background_color
,
'#E75E40'
default_value_for
:font_color
,
'#FFFFFF'
default_value_for
:font_color
,
'#FFFFFF'
end
end
def
show_header?
self
.
header_message
.
present?
end
def
show_footer?
self
.
footer_message
.
present?
end
end
end
end
end
ee/app/views/admin/appearances/
ee/
_form.html.haml
→
ee/app/views/admin/appearances/
_system_header_footer
_form.html.haml
View file @
e51a5224
File moved
ee/app/views/admin/appearances/ee/_footer_message.html.haml
deleted
100644 → 0
View file @
eefc967e
=
footer_message
(
Appearance
.
current
)
ee/app/views/admin/appearances/ee/_header_message.html.haml
deleted
100644 → 0
View file @
eefc967e
=
header_message
(
Appearance
.
current
)
ee/spec/features/display_system_header_and_footer_bar_spec.rb
0 → 100644
View file @
e51a5224
require
'rails_helper'
describe
'Display system header and footer bar'
do
let
(
:header_message
)
{
"Foo"
}
let
(
:footer_message
)
{
"Bar"
}
shared_examples
'system header is configured'
do
it
'shows system header'
do
expect
(
page
).
to
have_css
(
'.header-message'
)
end
it
'shows the correct content'
do
page
.
within
(
'.header-message'
)
do
expect
(
page
).
to
have_content
(
header_message
)
end
end
end
shared_examples
'system footer is configured'
do
it
'shows system footer'
do
expect
(
page
).
to
have_css
(
'.footer-message'
)
end
it
'shows the correct content'
do
page
.
within
(
'.footer-message'
)
do
expect
(
page
).
to
have_content
(
footer_message
)
end
end
end
shared_examples
'system header is not configured'
do
it
'does not show system header'
do
expect
(
page
).
not_to
have_css
(
'.header-message'
)
end
end
shared_examples
'system footer is not configured'
do
it
'does not show system footer'
do
expect
(
page
).
not_to
have_css
(
'.footer-message'
)
end
end
context
'when authenticated'
do
context
'when system header and footer are not configured'
do
before
do
sign_in
(
create
(
:user
))
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is not configured'
end
context
'when only system header is defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
)
sign_in
(
create
(
:user
))
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is not configured'
end
context
'when only system footer is defined'
do
before
do
create
(
:appearance
,
footer_message:
footer_message
)
sign_in
(
create
(
:user
))
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is configured'
end
context
'when system header and footer are defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
,
footer_message:
footer_message
)
sign_in
(
create
(
:user
))
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is configured'
end
end
context
'when not authenticated'
do
context
'when system header and footer are not configured'
do
before
do
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is not configured'
end
context
'when only system header is defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is not configured'
end
context
'when only system footer is defined'
do
before
do
create
(
:appearance
,
footer_message:
footer_message
)
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is configured'
end
context
'when system header and footer are defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
,
footer_message:
footer_message
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is configured'
end
end
end
ee/spec/helpers/ee/appearances_helper_spec.rb
0 → 100644
View file @
e51a5224
require
'spec_helper'
describe
AppearancesHelper
do
describe
'#header_message'
do
it
'returns nil when header message field is not set'
do
appearance
=
build
(
:appearance
)
expect
(
helper
.
header_message
(
appearance
)).
to
be_nil
end
context
'when header message is set'
do
let
(
:appearance
)
{
build
(
:appearance
,
header_message:
message
)
}
it
'includes current message'
do
message
=
"Foo bar"
appearance
=
build
(
:appearance
,
header_message:
message
)
expect
(
helper
.
header_message
(
appearance
)).
to
include
(
message
)
end
end
end
describe
'#footer_message'
do
it
'returns nil when footer message field is not set'
do
appearance
=
build
(
:appearance
)
expect
(
helper
.
footer_message
(
appearance
)).
to
be_nil
end
context
'when footer message is set'
do
let
(
:appearance
)
{
build
(
:appearance
,
header_message:
message
)
}
it
'includes current message'
do
message
=
"Foo bar"
appearance
=
build
(
:appearance
,
footer_message:
message
)
expect
(
helper
.
footer_message
(
appearance
)).
to
include
(
message
)
end
end
end
end
ee/spec/models/ee/appearance_spec.rb
0 → 100644
View file @
e51a5224
require
'spec_helper'
describe
Appearance
do
subject
{
build
(
:appearance
)
}
describe
'validations'
do
let
(
:triplet
)
{
'#000'
}
let
(
:hex
)
{
'#AABBCC'
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:background_color
)
}
it
{
is_expected
.
to
allow_value
(
triplet
).
for
(
:background_color
)
}
it
{
is_expected
.
to
allow_value
(
hex
).
for
(
:background_color
)
}
it
{
is_expected
.
not_to
allow_value
(
'000'
).
for
(
:background_color
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:font_color
)
}
it
{
is_expected
.
to
allow_value
(
triplet
).
for
(
:font_color
)
}
it
{
is_expected
.
to
allow_value
(
hex
).
for
(
:font_color
)
}
it
{
is_expected
.
not_to
allow_value
(
'000'
).
for
(
:font_color
)
}
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