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
Tatuya Kamada
gitlab-ce
Commits
42422dcc
Commit
42422dcc
authored
Feb 07, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add internal broadcast message API.
parent
d3c2253c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
12 deletions
+45
-12
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/internal.rb
lib/api/internal.rb
+8
-0
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+33
-12
No files found.
lib/api/entities.rb
View file @
42422dcc
...
@@ -270,5 +270,9 @@ module API
...
@@ -270,5 +270,9 @@ module API
class
Contributor
<
Grape
::
Entity
class
Contributor
<
Grape
::
Entity
expose
:name
,
:email
,
:commits
,
:additions
,
:deletions
expose
:name
,
:email
,
:commits
,
:additions
,
:deletions
end
end
class
BroadcastMessage
<
Grape
::
Entity
expose
:message
,
:starts_at
,
:ends_at
,
:color
,
:font
end
end
end
end
end
lib/api/internal.rb
View file @
42422dcc
...
@@ -69,6 +69,14 @@ module API
...
@@ -69,6 +69,14 @@ module API
gitlab_rev:
Gitlab
::
REVISION
,
gitlab_rev:
Gitlab
::
REVISION
,
}
}
end
end
get
"/broadcast_message"
do
if
message
=
BroadcastMessage
.
current
present
message
,
with:
Entities
::
BroadcastMessage
else
not_found!
end
end
end
end
end
end
end
end
spec/requests/api/internal_spec.rb
View file @
42422dcc
...
@@ -16,6 +16,27 @@ describe API::API, api: true do
...
@@ -16,6 +16,27 @@ describe API::API, api: true do
end
end
end
end
describe
"GET /internal/broadcast_message"
do
context
"broadcast message exists"
do
let!
(
:broadcast_message
)
{
create
(
:broadcast_message
,
starts_at:
Time
.
now
.
yesterday
,
ends_at:
Time
.
now
.
tomorrow
)
}
it
do
get
api
(
"/internal/broadcast_message"
),
secret_token:
secret_token
response
.
status
.
should
==
200
json_response
[
"message"
].
should
==
broadcast_message
.
message
end
end
context
"broadcast message doesn't exist"
do
it
do
get
api
(
"/internal/broadcast_message"
),
secret_token:
secret_token
response
.
status
.
should
==
404
end
end
end
describe
"GET /internal/discover"
do
describe
"GET /internal/discover"
do
it
do
it
do
get
(
api
(
"/internal/discover"
),
key_id:
key
.
id
,
secret_token:
secret_token
)
get
(
api
(
"/internal/discover"
),
key_id:
key
.
id
,
secret_token:
secret_token
)
...
@@ -37,7 +58,7 @@ describe API::API, api: true do
...
@@ -37,7 +58,7 @@ describe API::API, api: true do
pull
(
key
,
project
)
pull
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_true
json_response
[
"status"
].
should
be_true
end
end
end
end
...
@@ -46,7 +67,7 @@ describe API::API, api: true do
...
@@ -46,7 +67,7 @@ describe API::API, api: true do
push
(
key
,
project
)
push
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_true
json_response
[
"status"
].
should
be_true
end
end
end
end
end
end
...
@@ -61,7 +82,7 @@ describe API::API, api: true do
...
@@ -61,7 +82,7 @@ describe API::API, api: true do
pull
(
key
,
project
)
pull
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
...
@@ -70,7 +91,7 @@ describe API::API, api: true do
...
@@ -70,7 +91,7 @@ describe API::API, api: true do
push
(
key
,
project
)
push
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
end
end
...
@@ -87,7 +108,7 @@ describe API::API, api: true do
...
@@ -87,7 +108,7 @@ describe API::API, api: true do
pull
(
key
,
personal_project
)
pull
(
key
,
personal_project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
...
@@ -96,7 +117,7 @@ describe API::API, api: true do
...
@@ -96,7 +117,7 @@ describe API::API, api: true do
push
(
key
,
personal_project
)
push
(
key
,
personal_project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
end
end
...
@@ -114,7 +135,7 @@ describe API::API, api: true do
...
@@ -114,7 +135,7 @@ describe API::API, api: true do
pull
(
key
,
project
)
pull
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_true
json_response
[
"status"
].
should
be_true
end
end
end
end
...
@@ -123,7 +144,7 @@ describe API::API, api: true do
...
@@ -123,7 +144,7 @@ describe API::API, api: true do
push
(
key
,
project
)
push
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
end
end
...
@@ -140,7 +161,7 @@ describe API::API, api: true do
...
@@ -140,7 +161,7 @@ describe API::API, api: true do
archive
(
key
,
project
)
archive
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_true
json_response
[
"status"
].
should
be_true
end
end
end
end
...
@@ -149,7 +170,7 @@ describe API::API, api: true do
...
@@ -149,7 +170,7 @@ describe API::API, api: true do
archive
(
key
,
project
)
archive
(
key
,
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
end
end
...
@@ -159,7 +180,7 @@ describe API::API, api: true do
...
@@ -159,7 +180,7 @@ describe API::API, api: true do
pull
(
key
,
OpenStruct
.
new
(
path_with_namespace:
'gitlab/notexists'
))
pull
(
key
,
OpenStruct
.
new
(
path_with_namespace:
'gitlab/notexists'
))
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
end
end
end
end
...
@@ -168,7 +189,7 @@ describe API::API, api: true do
...
@@ -168,7 +189,7 @@ describe API::API, api: true do
pull
(
OpenStruct
.
new
(
id:
0
),
project
)
pull
(
OpenStruct
.
new
(
id:
0
),
project
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
JSON
.
parse
(
response
.
body
)
[
"status"
].
should
be_false
json_response
[
"status"
].
should
be_false
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