diff --git a/app/controllers/api/v1/systems_controller.rb b/app/controllers/api/v1/systems_controller.rb new file mode 100644 index 00000000..c63c2cf0 --- /dev/null +++ b/app/controllers/api/v1/systems_controller.rb @@ -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 diff --git a/app/views/api/v1/systems/show.json.jbuilder b/app/views/api/v1/systems/show.json.jbuilder new file mode 100644 index 00000000..12253198 --- /dev/null +++ b/app/views/api/v1/systems/show.json.jbuilder @@ -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 diff --git a/config/routes.rb b/config/routes.rb index c06ba985..214d0e9c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/test/controllers/api/v1/systems_controller_test.rb b/test/controllers/api/v1/systems_controller_test.rb new file mode 100644 index 00000000..d5864a1e --- /dev/null +++ b/test/controllers/api/v1/systems_controller_test.rb @@ -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