diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945..707153d0b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,5 @@ module ApplicationHelper + def version + @version ||= File.read('VERSION') + end end diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 0de7fcdc8..3bd227dcb 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -32,4 +32,5 @@ %p= link_to 'Download all regular schedules as CSV', admin_csv_regular_schedules_path, class: 'btn btn-primary' %p= link_to 'Download all services as CSV', admin_csv_services_path, class: 'btn btn-primary' - + %hr + Ohana API #{link_to "v#{version}", 'https://github.com/codeforamerica/ohana-api/blob/master/CHANGELOG.md'} \ No newline at end of file diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index 7bdace8e1..feb8e3bfb 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -221,4 +221,29 @@ to have_link('Download all services as CSV', admin_csv_services_path) end end + + describe 'Ohana API version' do + before do + allow(File).to receive(:read).with('VERSION').and_return('1.0.0') + end + let(:prefix) { 'https://github.com/codeforamerica/ohana-api/blob/master/' } + + context 'super admin' do + it 'displays Ohana API version number' do + login_super_admin + visit '/admin' + + expect(page).to have_link 'v1.0.0', href: "#{prefix}CHANGELOG.md" + end + end + + context 'regular admin' do + it 'does not display Ohana API version number' do + login_admin + visit '/admin' + + expect(page).to_not have_link 'v1.0.0', href: "#{prefix}CHANGELOG.md" + end + end + end end