Commit df1e1df0 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-show-pre-release-sha' into 'master'

Show the commit-sha for pre-release versions

Closes #52050

See merge request gitlab-org/gitlab-ce!22026
parents d5184e0d b09e4062
......@@ -9,4 +9,17 @@ module VersionCheckHelper
image_url = VersionCheck.new.url
image_tag image_url, class: 'js-version-status-badge'
end
def link_to_version
if Gitlab.pre_release?
commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', source_code_project, Gitlab.revision))
[Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
else
link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', source_code_project, "v#{Gitlab::VERSION}")
end
end
def source_code_project
'gitlab-ce'
end
end
......@@ -7,7 +7,7 @@
GitLab
Community Edition
- if user_signed_in?
%span= link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', 'gitlab-ce', "v#{Gitlab::VERSION}")
%span= link_to_version
= version_status_badge
%hr
......
---
title: Show SHA for pre-release versions on the help page
merge_request: 22026
author:
type: changed
......@@ -47,4 +47,8 @@ module Gitlab
def self.dev_env_or_com?
Rails.env.development? || org? || com?
end
def self.pre_release?
VERSION.include?('pre')
end
end
# frozen_string_literal: true
module StubVersion
def stub_version(version, revision)
stub_const('Gitlab::VERSION', version)
allow(Gitlab).to receive(:revision).and_return(revision)
end
end
# frozen_string_literal: true
require 'rails_helper'
describe 'help/index' do
include StubVersion
describe 'version information' do
before do
stub_helpers
end
it 'is hidden from guests' do
stub_user(nil)
stub_version('8.0.2', 'abcdefg')
stub_helpers
render
......@@ -13,15 +20,28 @@ describe 'help/index' do
expect(rendered).not_to match 'abcdefg'
end
it 'is shown to users' do
context 'when logged in' do
before do
stub_user
end
it 'shows a link to the tag to users' do
stub_version('8.0.2', 'abcdefg')
stub_helpers
render
expect(rendered).to match '8.0.2'
expect(rendered).to have_link('8.0.2', href: 'https://gitlab.com/gitlab-org/gitlab-ce/tags/v8.0.2')
expect(rendered).to have_link('8.0.2', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/tags/v8.0.2})
end
it 'shows a link to the commit for pre-releases' do
stub_version('8.0.2-pre', 'abcdefg')
render
expect(rendered).to match '8.0.2'
expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/commits/abcdefg})
end
end
end
......@@ -37,11 +57,6 @@ describe 'help/index' do
allow(view).to receive(:user_signed_in?).and_return(user)
end
def stub_version(version, revision)
stub_const('Gitlab::VERSION', version)
allow(Gitlab).to receive(:revision).and_return(revision)
end
def stub_helpers
allow(view).to receive(:markdown).and_return('')
allow(view).to receive(:version_status_badge).and_return('')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment