From 10d9df28ec3b494361abcee27ffddece580bbf3a Mon Sep 17 00:00:00 2001 From: Katarzyna Kobierska Date: Mon, 18 Jul 2016 13:58:08 +0200 Subject: Add gitlab-workhorse version to admin dashboard Test for showing GitLab Workhorse version on Admin Dashboard Refactoring --- CHANGELOG | 1 + app/views/admin/dashboard/index.html.haml | 4 ++++ lib/gitlab/workhorse.rb | 7 +++++++ spec/views/admin/dashboard/index.html.haml_spec.rb | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 spec/views/admin/dashboard/index.html.haml_spec.rb diff --git a/CHANGELOG b/CHANGELOG index fa272755033..e3a8c3731bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -164,6 +164,7 @@ v 8.10.0 - Export and import avatar as part of project import/export - Fix migration corrupting import data for old version upgrades - Show tooltip on GitLab export link in new project page + - Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska) v 8.9.6 - Fix importing of events under notes for GitLab projects. !5154 diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index a2ac407c159..452fc25ab07 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -79,6 +79,10 @@ GitLab Shell %span.pull-right = Gitlab::Shell.new.version + %p + GitLab Workhorse + %span.pull-right + = Gitlab::Workhorse.version %p GitLab API %span.pull-right diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 6aeb49c0219..97610b1f962 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -4,6 +4,7 @@ require 'json' module Gitlab class Workhorse SEND_DATA_HEADER = 'Gitlab-Workhorse-Send-Data' + VERSION_FILE = 'GITLAB_WORKHORSE_VERSION' class << self def git_http_ok(repository, user) @@ -75,6 +76,12 @@ module Gitlab ] end + def version + if File.readable?(File.join(Rails.root, VERSION_FILE)) + File.read(File.join(Rails.root, VERSION_FILE)) + end + end + protected def encode(hash) diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb new file mode 100644 index 00000000000..dae858a52f6 --- /dev/null +++ b/spec/views/admin/dashboard/index.html.haml_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'admin/dashboard/index.html.haml' do + include Devise::TestHelpers + + before do + assign(:projects, create_list(:empty_project, 1)) + assign(:users, create_list(:user, 1)) + assign(:groups, create_list(:group, 1)) + + allow(view).to receive(:admin?).and_return(true) + end + + it "shows version of GitLab Workhorse" do + render + + expect(rendered).to have_content 'GitLab Workhorse' + expect(rendered).to have_content Gitlab::Workhorse.version + end +end -- cgit v1.2.1