Skip to content

Commit

Permalink
Merge pull request #82 from yorch/add-envs-to-html
Browse files Browse the repository at this point in the history
Add env variables to HTML page
  • Loading branch information
lbeder committed Mar 15, 2022
2 parents d92cdb7 + 629de9e commit 59231bb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
25 changes: 24 additions & 1 deletion app/views/health_monitor/health/check.html.erb
Expand Up @@ -17,7 +17,7 @@
<main>
<div class="max-w-7xl mx-auto py-12 sm:px-6 lg:px-8">
<div class="max-w-4xl mx-auto">
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="services bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
Services
Expand All @@ -43,6 +43,29 @@
</dl>
</div>
</div>
<% if @statuses[:environment_variables].present? %>
<div class="env-variables bg-white shadow overflow-hidden sm:rounded-lg my-6">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
Environment Variables
</h3>
</div>
<div class="border-t border-gray-200">
<dl>
<% @statuses[:environment_variables].each_with_index do |env_var, index| %>
<div class="<%= index.odd? ? 'bg-gray-50' : 'bg-white' %> px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
<%= env_var[0] %>
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= env_var[1] %>
</dd>
</div>
<% end %>
</dl>
</div>
</div>
<% end %>
</div>
</div>
</main>
Expand Down
Binary file modified docs/screenshots/page.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 30 additions & 5 deletions spec/features/health_monitor/health_monitor_spec.rb
Expand Up @@ -6,8 +6,10 @@
context 'when check is ok' do
it 'renders html' do
visit '/check'
expect(page).to have_css('dt', class: 'name', text: 'Database')
expect(page).to have_css('div', class: 'state', text: 'OK')
expect(page).to have_css('h3', count: 1)
expect(page).to have_css('h3', text: 'Services')
expect(page).to have_css('.services dt.name', text: 'Database')
expect(page).to have_css('.services div.state', text: 'OK')
end
end

Expand All @@ -17,9 +19,32 @@
end
it 'renders html' do
visit '/check'
expect(page).to have_css('dt', class: 'name', text: 'Database')
expect(page).to have_css('div', class: 'state', text: 'ERROR')
expect(page).to have_css('div', class: 'message', text: 'Exception')
expect(page).to have_css('h3', count: 1)
expect(page).to have_css('h3', text: 'Services')
expect(page).to have_css('.services dt.name', text: 'Database')
expect(page).to have_css('.services div.state', text: 'ERROR')
expect(page).to have_css('.services div.message', text: 'Exception')
end
end

context 'when env variables are configured' do
let(:environment_variables) { { build_number: '12', git_sha: 'example_sha' } }

before do
HealthMonitor.configure do |config|
config.environment_variables = environment_variables
end
end
it 'renders html' do
visit '/check'
expect(page).to have_css('h3', count: 2)
expect(page).to have_css('h3', text: 'Services')
expect(page).to have_css('h3', text: 'Environment Variables')
expect(page).to have_css('.env-variables dt', count: 2)
expect(page).to have_css('.env-variables dt', text: 'build_number')
expect(page).to have_css('.env-variables dd', text: '12')
expect(page).to have_css('.env-variables dt', text: 'git_sha')
expect(page).to have_css('.env-variables dd', text: 'example_sha')
end
end
end

0 comments on commit 59231bb

Please sign in to comment.