Skip to content
Snippets Groups Projects
Commit 42422dcc authored by Douwe Maan's avatar Douwe Maan
Browse files

Add internal broadcast message API.

parent d3c2253c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -270,5 +270,9 @@ module API
class Contributor < Grape::Entity
expose :name, :email, :commits, :additions, :deletions
end
class BroadcastMessage < Grape::Entity
expose :message, :starts_at, :ends_at, :color, :font
end
end
end
Loading
Loading
@@ -69,6 +69,14 @@ module API
gitlab_rev: Gitlab::REVISION,
}
end
get "/broadcast_message" do
if message = BroadcastMessage.current
present message, with: Entities::BroadcastMessage
else
not_found!
end
end
end
end
end
Loading
Loading
@@ -16,6 +16,27 @@ describe API::API, api: true do
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
it do
get(api("/internal/discover"), key_id: key.id, secret_token: secret_token)
Loading
Loading
@@ -37,7 +58,7 @@ describe API::API, api: true do
pull(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_true
json_response["status"].should be_true
end
end
 
Loading
Loading
@@ -46,7 +67,7 @@ describe API::API, api: true do
push(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_true
json_response["status"].should be_true
end
end
end
Loading
Loading
@@ -61,7 +82,7 @@ describe API::API, api: true do
pull(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
 
Loading
Loading
@@ -70,7 +91,7 @@ describe API::API, api: true do
push(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
end
Loading
Loading
@@ -87,7 +108,7 @@ describe API::API, api: true do
pull(key, personal_project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
 
Loading
Loading
@@ -96,7 +117,7 @@ describe API::API, api: true do
push(key, personal_project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
end
Loading
Loading
@@ -114,7 +135,7 @@ describe API::API, api: true do
pull(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_true
json_response["status"].should be_true
end
end
 
Loading
Loading
@@ -123,7 +144,7 @@ describe API::API, api: true do
push(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
end
Loading
Loading
@@ -140,7 +161,7 @@ describe API::API, api: true do
archive(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_true
json_response["status"].should be_true
end
end
 
Loading
Loading
@@ -149,7 +170,7 @@ describe API::API, api: true do
archive(key, project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
end
Loading
Loading
@@ -159,7 +180,7 @@ describe API::API, api: true do
pull(key, OpenStruct.new(path_with_namespace: 'gitlab/notexists'))
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
 
Loading
Loading
@@ -168,7 +189,7 @@ describe API::API, api: true do
pull(OpenStruct.new(id: 0), project)
 
response.status.should == 200
JSON.parse(response.body)["status"].should be_false
json_response["status"].should be_false
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment