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
35cc26e5
Commit
35cc26e5
authored
Nov 24, 2019
by
Fabio Huser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs(changelog): add changelog entry for appearance API endpoint
parent
3ea073f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
20 deletions
+25
-20
changelogs/unreleased/feat-appearance-api.yml
changelogs/unreleased/feat-appearance-api.yml
+5
-0
doc/api/appearance.md
doc/api/appearance.md
+1
-1
spec/requests/api/appearance_spec.rb
spec/requests/api/appearance_spec.rb
+19
-19
No files found.
changelogs/unreleased/feat-appearance-api.yml
0 → 100644
View file @
35cc26e5
---
title
:
Implement application appearance API endpoint
merge_request
:
20674
author
:
Fabio Huser
type
:
added
doc/api/appearance.md
View file @
35cc26e5
# Appearance API
# Appearance API
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/
???
) in GitLab 12.6.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/
20674
) in GitLab 12.6.
These API calls allow you to read and modify the GitLab appearance as visible in
These API calls allow you to read and modify the GitLab appearance as visible in
`/admin/appearance`
. You have to be an administrator in order to perform this action.
`/admin/appearance`
. You have to be an administrator in order to perform this action.
...
...
spec/requests/api/appearance_spec.rb
View file @
35cc26e5
...
@@ -10,7 +10,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -10,7 +10,7 @@ describe API::Appearance, 'Appearance' do
context
'as a non-admin user'
do
context
'as a non-admin user'
do
it
"returns 403"
do
it
"returns 403"
do
get
api
(
"/application/appearance"
,
user
)
get
api
(
"/application/appearance"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
end
...
@@ -40,11 +40,11 @@ describe API::Appearance, 'Appearance' do
...
@@ -40,11 +40,11 @@ describe API::Appearance, 'Appearance' do
context
'as a non-admin user'
do
context
'as a non-admin user'
do
it
"returns 403"
do
it
"returns 403"
do
put
api
(
"/application/appearance"
,
user
),
params:
{
title:
"Test"
}
put
api
(
"/application/appearance"
,
user
),
params:
{
title:
"Test"
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
end
context
'as an admin user'
do
context
'as an admin user'
do
context
"instance basics"
do
context
"instance basics"
do
it
"allows updating the settings"
do
it
"allows updating the settings"
do
...
@@ -53,7 +53,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -53,7 +53,7 @@ describe API::Appearance, 'Appearance' do
description:
"gitlab-test.example.com"
,
description:
"gitlab-test.example.com"
,
new_project_guidelines:
"Please read the FAQs for help."
new_project_guidelines:
"Please read the FAQs for help."
}
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'description'
]).
to
eq
(
'gitlab-test.example.com'
)
expect
(
json_response
[
'description'
]).
to
eq
(
'gitlab-test.example.com'
)
...
@@ -69,7 +69,7 @@ describe API::Appearance, 'Appearance' do
...
@@ -69,7 +69,7 @@ describe API::Appearance, 'Appearance' do
expect
(
json_response
[
'title'
]).
to
eq
(
'GitLab Test Instance'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'GitLab Test Instance'
)
end
end
end
end
context
"system header and footer"
do
context
"system header and footer"
do
it
"allows updating the settings"
do
it
"allows updating the settings"
do
settings
=
{
settings
=
{
...
@@ -79,64 +79,64 @@ describe API::Appearance, 'Appearance' do
...
@@ -79,64 +79,64 @@ describe API::Appearance, 'Appearance' do
message_background_color:
"#009999"
,
message_background_color:
"#009999"
,
email_header_and_footer_enabled:
true
email_header_and_footer_enabled:
true
}
}
put
api
(
"/application/appearance"
,
admin
),
params:
settings
put
api
(
"/application/appearance"
,
admin
),
params:
settings
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
settings
.
each
do
|
attribute
,
value
|
settings
.
each
do
|
attribute
,
value
|
expect
(
Appearance
.
current
.
public_send
(
attribute
)).
to
eq
(
value
)
expect
(
Appearance
.
current
.
public_send
(
attribute
)).
to
eq
(
value
)
end
end
end
end
context
"fails on invalid color values"
do
context
"fails on invalid color values"
do
it
"with message_font_color"
do
it
"with message_font_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_font_color:
"No Color"
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_font_color:
"No Color"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'message_font_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
expect
(
json_response
[
'message'
][
'message_font_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
end
it
"with message_background_color"
do
it
"with message_background_color"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_background_color:
"#1"
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
message_background_color:
"#1"
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'message_background_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
expect
(
json_response
[
'message'
][
'message_background_color'
]).
to
contain_exactly
(
'must be a valid color code'
)
end
end
end
end
end
end
context
"instance logos"
do
context
"instance logos"
do
let_it_be
(
:appearance
)
{
create
(
:appearance
)
}
let_it_be
(
:appearance
)
{
create
(
:appearance
)
}
it
"allows updating the image files"
do
it
"allows updating the image files"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
header_logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
header_logo:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
),
favicon:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
)
favicon:
fixture_file_upload
(
"spec/fixtures/dk.png"
,
"image/png"
)
}
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'logo'
]).
to
eq
(
"/uploads/-/system/appearance/logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'logo'
]).
to
eq
(
"/uploads/-/system/appearance/logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'header_logo'
]).
to
eq
(
"/uploads/-/system/appearance/header_logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'header_logo'
]).
to
eq
(
"/uploads/-/system/appearance/header_logo/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'favicon'
]).
to
eq
(
"/uploads/-/system/appearance/favicon/
#{
appearance
.
id
}
/dk.png"
)
expect
(
json_response
[
'favicon'
]).
to
eq
(
"/uploads/-/system/appearance/favicon/
#{
appearance
.
id
}
/dk.png"
)
end
end
context
"fails on invalid color images"
do
context
"fails on invalid color images"
do
it
"with string instead of file"
do
it
"with string instead of file"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
'not-a-file.png'
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
logo:
'not-a-file.png'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'error'
]).
to
eq
(
"logo is invalid"
)
expect
(
json_response
[
'error'
]).
to
eq
(
"logo is invalid"
)
end
end
it
"with .svg file instead of .png"
do
it
"with .svg file instead of .png"
do
put
api
(
"/application/appearance"
,
admin
),
params:
{
favicon:
fixture_file_upload
(
"spec/fixtures/logo_sample.svg"
,
"image/svg"
)
}
put
api
(
"/application/appearance"
,
admin
),
params:
{
favicon:
fixture_file_upload
(
"spec/fixtures/logo_sample.svg"
,
"image/svg"
)
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'favicon'
]).
to
contain_exactly
(
"You are not allowed to upload
\"
svg
\"
files, allowed types: png, ico"
)
expect
(
json_response
[
'message'
][
'favicon'
]).
to
contain_exactly
(
"You are not allowed to upload
\"
svg
\"
files, allowed types: png, ico"
)
end
end
end
end
end
end
end
end
end
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