Skip to content

Commit

Permalink
Add API for system info
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Jan 9, 2023
1 parent dc3d3c6 commit 06d4946
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/controllers/api/v1/systems_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Api
module V1
class SystemsController < ApiController
skip_before_action :find_current_user
skip_before_action :require_login

def show
end
end
end
end
6 changes: 6 additions & 0 deletions app/views/api/v1/systems/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
json.version do
json.major BlackCandy::Version::MAJOR
json.minor BlackCandy::Version::MINOR
json.patch BlackCandy::Version::PATCH
json.pre BlackCandy::Version::PRE
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
namespace :api do
namespace :v1 do
resource :authentication, only: [:create]
resource :system, only: [:show]
resources :songs, only: [:show]
resources :stream, only: [:new]
resources :transcoded_stream, only: [:new]
Expand Down
16 changes: 16 additions & 0 deletions test/controllers/api/v1/systems_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require "test_helper"

class Api::V1::SystemsControllerTest < ActionDispatch::IntegrationTest
test "should get system version" do
get api_v1_system_url, as: :json
response = @response.parsed_body["version"]

assert_response :success
assert_equal BlackCandy::Version::MAJOR, response["major"]
assert_equal BlackCandy::Version::MINOR, response["minor"]
assert_equal BlackCandy::Version::PATCH, response["patch"]
assert_equal BlackCandy::Version::PRE, response["pre"]
end
end

0 comments on commit 06d4946

Please sign in to comment.