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
b1d05d74
Commit
b1d05d74
authored
Jul 11, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds License check for system header and footer messages
parent
8529f1f5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
259 additions
and
21 deletions
+259
-21
doc/customization/system_header_and_footer_messages.md
doc/customization/system_header_and_footer_messages.md
+5
-0
ee/app/controllers/ee/admin/appearances_controller.rb
ee/app/controllers/ee/admin/appearances_controller.rb
+11
-1
ee/app/models/ee/appearance.rb
ee/app/models/ee/appearance.rb
+4
-0
ee/app/models/license.rb
ee/app/models/license.rb
+2
-0
ee/app/views/admin/appearances/_system_header_footer_form.html.haml
...ws/admin/appearances/_system_header_footer_form.html.haml
+2
-0
ee/changelogs/unreleased/6160-add-premium-license-check-for-system-messages.yml
...ed/6160-add-premium-license-check-for-system-messages.yml
+5
-0
ee/spec/controllers/admin/appearances_controller_spec.rb
ee/spec/controllers/admin/appearances_controller_spec.rb
+89
-0
ee/spec/features/display_system_header_and_footer_bar_spec.rb
...pec/features/display_system_header_and_footer_bar_spec.rb
+119
-18
ee/spec/helpers/ee/appearances_helper_spec.rb
ee/spec/helpers/ee/appearances_helper_spec.rb
+22
-2
No files found.
doc/customization/system_header_and_footer_messages.md
View file @
b1d05d74
# Adding a system message to every page
> [Introduced][ee-1283] in [GitLab Premium][eep] 10.7.
Navigate to the
**Admin**
area and go to the
**Appearance**
page.
Under
**System header and footer**
insert your header message and/or footer message.
...
...
@@ -14,3 +16,6 @@ After saving, all GitLab pages will contain the custom system header and/or foot
The GitLab sign in page will also show the header and the footer messages:
![
sign_up_custom_header_and_footer
](
system_header_and_footer_messages/sign_up_custom_header_and_footer.png
)
[
eep
]:
https://about.gitlab.com/pricing/
[
ee-4972
]:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4972
ee/app/controllers/ee/admin/appearances_controller.rb
View file @
b1d05d74
...
...
@@ -2,7 +2,17 @@ module EE
module
Admin
module
AppearancesController
def
allowed_appearance_params
super
+
%i[
if
License
.
feature_available?
(
:system_header_footer
)
super
+
header_footer_params
else
super
end
end
private
def
header_footer_params
%i[
header_message
footer_message
message_background_color
...
...
ee/app/models/ee/appearance.rb
View file @
b1d05d74
...
...
@@ -14,10 +14,14 @@ module EE
end
def
show_header?
return
unless
::
License
.
feature_available?
(
:system_header_footer
)
header_message
.
present?
end
def
show_footer?
return
unless
::
License
.
feature_available?
(
:system_header_footer
)
footer_message
.
present?
end
end
...
...
ee/app/models/license.rb
View file @
b1d05d74
...
...
@@ -60,6 +60,7 @@ class License < ActiveRecord::Base
external_authorization_service
ci_cd_projects
group_burndown_charts
system_header_footer
]
.
freeze
EEU_FEATURES
=
EEP_FEATURES
+
%i[
...
...
@@ -154,6 +155,7 @@ class License < ActiveRecord::Base
object_storage
repository_size_limit
external_authorization_service
system_header_footer
]
.
freeze
validate
:valid_license
...
...
ee/app/views/admin/appearances/_system_header_footer_form.html.haml
View file @
b1d05d74
-
return
unless
License
.
feature_available?
(
:system_header_footer_form
)
-
form
=
local_assigns
.
fetch
(
:form
)
%fieldset
.system_header_footer
...
...
ee/changelogs/unreleased/6160-add-premium-license-check-for-system-messages.yml
0 → 100644
View file @
b1d05d74
---
title
:
Add Premium license checks for system messages
merge_request
:
6460
author
:
type
:
fixed
ee/spec/controllers/admin/appearances_controller_spec.rb
0 → 100644
View file @
b1d05d74
require
'spec_helper'
describe
Admin
::
AppearancesController
do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:header_message
)
{
"Header message"
}
let
(
:footer_message
)
{
"Footer"
}
describe
'POST #create'
do
let
(
:create_params
)
do
{
title:
"Foo"
,
description:
"Bar"
,
header_message:
header_message
,
footer_message:
footer_message
}
end
before
do
sign_in
(
admin
)
end
context
'when system messages feature is available'
do
it
'creates appearance with footer and header message'
do
stub_licensed_features
(
system_header_footer:
true
)
post
:create
,
appearance:
create_params
expect
(
Appearance
.
current
).
to
have_attributes
(
header_message:
header_message
,
footer_message:
footer_message
)
end
end
context
'when system messages feature is not available'
do
it
'does not create appearance with footer and header message'
do
stub_licensed_features
(
system_header_footer:
false
)
post
:create
,
appearance:
create_params
expect
(
Appearance
.
current
).
to
have_attributes
(
header_message:
nil
,
footer_message:
nil
)
end
end
end
describe
'PUT #update'
do
let
(
:update_params
)
do
{
header_message:
header_message
,
footer_message:
footer_message
}
end
before
do
create
(
:appearance
)
sign_in
(
admin
)
end
context
'when system messages feature is available'
do
it
'updates appearance with footer and header message'
do
stub_licensed_features
(
system_header_footer:
true
)
put
:update
,
appearance:
update_params
expect
(
Appearance
.
current
).
to
have_attributes
(
header_message:
header_message
,
footer_message:
footer_message
)
end
end
context
'when system messages feature is not available'
do
it
'does not update appearance with footer and header message'
do
stub_licensed_features
(
system_header_footer:
false
)
post
:create
,
appearance:
update_params
expect
(
Appearance
.
current
).
to
have_attributes
(
header_message:
nil
,
footer_message:
nil
)
end
end
end
end
ee/spec/features/display_system_header_and_footer_bar_spec.rb
View file @
b1d05d74
...
...
@@ -57,11 +57,28 @@ describe 'Display system header and footer bar' 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'
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is not configured'
end
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system header is not configured'
end
end
context
'when only system footer is defined'
do
...
...
@@ -69,11 +86,28 @@ describe 'Display system header and footer bar' 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'
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is configured'
end
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system footer is not configured'
end
end
context
'when system header and footer are defined'
do
...
...
@@ -81,11 +115,29 @@ describe 'Display system header and footer bar' 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'
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is configured'
end
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is not configured'
end
end
end
...
...
@@ -102,34 +154,83 @@ describe 'Display system header and footer bar' do
context
'when only system header is defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
)
end
visit
root_path
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is not configured'
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is not configured'
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system header is not configured'
end
end
context
'when only system footer is defined'
do
before
do
create
(
:appearance
,
footer_message:
footer_message
)
end
visit
root_path
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is configured'
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is configured'
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system footer is not configured'
end
end
context
'when system header and footer are defined'
do
before
do
create
(
:appearance
,
header_message:
header_message
,
footer_message:
footer_message
)
end
visit
root_path
context
'when licensed'
do
before
do
stub_licensed_features
(
system_header_footer:
true
)
visit
root_path
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is configured'
end
it_behaves_like
'system header is configured'
it_behaves_like
'system footer is configured'
context
'when unlicensed'
do
before
do
stub_licensed_features
(
system_header_footer:
false
)
visit
root_path
end
it_behaves_like
'system header is not configured'
it_behaves_like
'system footer is not configured'
end
end
end
end
ee/spec/helpers/ee/appearances_helper_spec.rb
View file @
b1d05d74
...
...
@@ -14,10 +14,20 @@ describe AppearancesHelper do
end
context
'when header message is set'
do
it
'includes current message'
do
it
'returns nil when unlicensed'
do
create
(
:appearance
,
header_message:
"Foo bar"
)
stub_licensed_features
(
system_header_footer:
false
)
expect
(
helper
.
header_message
).
to
be_nil
end
it
'includes current message when licensed'
do
message
=
"Foo bar"
create
(
:appearance
,
header_message:
message
)
stub_licensed_features
(
system_header_footer:
true
)
expect
(
helper
.
header_message
).
to
include
(
message
)
end
end
...
...
@@ -31,10 +41,20 @@ describe AppearancesHelper do
end
context
'when footer message is set'
do
it
'includes current message'
do
it
'returns nil when unlicensed'
do
create
(
:appearance
,
footer_message:
"Foo bar"
)
stub_licensed_features
(
system_header_footer:
false
)
expect
(
helper
.
footer_message
).
to
be_nil
end
it
'includes current message when licensed'
do
message
=
"Foo bar"
create
(
:appearance
,
footer_message:
message
)
stub_licensed_features
(
system_header_footer:
true
)
expect
(
helper
.
footer_message
).
to
include
(
message
)
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