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 ...@@ -9,4 +9,17 @@ module VersionCheckHelper
image_url = VersionCheck.new.url image_url = VersionCheck.new.url
image_tag image_url, class: 'js-version-status-badge' image_tag image_url, class: 'js-version-status-badge'
end 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 end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
GitLab GitLab
Community Edition Community Edition
- if user_signed_in? - 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 = version_status_badge
%hr %hr
......
---
title: Show SHA for pre-release versions on the help page
merge_request: 22026
author:
type: changed
...@@ -47,4 +47,8 @@ module Gitlab ...@@ -47,4 +47,8 @@ module Gitlab
def self.dev_env_or_com? def self.dev_env_or_com?
Rails.env.development? || org? || com? Rails.env.development? || org? || com?
end end
def self.pre_release?
VERSION.include?('pre')
end
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' require 'rails_helper'
describe 'help/index' do describe 'help/index' do
include StubVersion
describe 'version information' do describe 'version information' do
before do
stub_helpers
end
it 'is hidden from guests' do it 'is hidden from guests' do
stub_user(nil) stub_user(nil)
stub_version('8.0.2', 'abcdefg') stub_version('8.0.2', 'abcdefg')
stub_helpers
render render
...@@ -13,15 +20,28 @@ describe 'help/index' do ...@@ -13,15 +20,28 @@ describe 'help/index' do
expect(rendered).not_to match 'abcdefg' expect(rendered).not_to match 'abcdefg'
end end
it 'is shown to users' do context 'when logged in' do
before do
stub_user stub_user
end
it 'shows a link to the tag to users' do
stub_version('8.0.2', 'abcdefg') stub_version('8.0.2', 'abcdefg')
stub_helpers
render render
expect(rendered).to match '8.0.2' 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
end end
...@@ -37,11 +57,6 @@ describe 'help/index' do ...@@ -37,11 +57,6 @@ describe 'help/index' do
allow(view).to receive(:user_signed_in?).and_return(user) allow(view).to receive(:user_signed_in?).and_return(user)
end end
def stub_version(version, revision)
stub_const('Gitlab::VERSION', version)
allow(Gitlab).to receive(:revision).and_return(revision)
end
def stub_helpers def stub_helpers
allow(view).to receive(:markdown).and_return('') allow(view).to receive(:markdown).and_return('')
allow(view).to receive(:version_status_badge).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