Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/info_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class InfoController < ActionController::API
def release
render plain: ENV.fetch('HEROKU_SLUG_COMMIT', 'unknown')
end
Comment thread
zetter-rpf marked this conversation as resolved.
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
root to: 'projects#index'
end

get '/info/release', to: 'info#release'
Comment thread
zetter-rpf marked this conversation as resolved.

post '/test/reseed', to: 'test_utilities#reseed'
post '/test/enable_feature', to: 'test_utilities#enable_feature'
post '/test/disable_feature', to: 'test_utilities#disable_feature'
Expand Down
23 changes: 23 additions & 0 deletions spec/requests/info_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe InfoController do
describe 'GET /info/release' do
subject(:request) { get '/info/release' }

it 'returns the deployed commit sha as text' do
ClimateControl.modify(HEROKU_SLUG_COMMIT: 'abc123') do
request
expect(response.body).to eq('abc123')
end
end

it 'returns unknown when the sha is unavailable' do
ClimateControl.modify(HEROKU_SLUG_COMMIT: nil) do
request
expect(response.body).to eq('unknown')
end
end
Comment thread
zetter-rpf marked this conversation as resolved.
end
end
Loading