Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cc281afb
Commit
cc281afb
authored
Jan 14, 2019
by
Brandon Labuschagne
Committed by
Dmitriy Zaporozhets
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Add "What's new" menu item in top navigation"
parent
31af7daf
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
303 additions
and
15 deletions
+303
-15
app/helpers/release_blog_post_helper.rb
app/helpers/release_blog_post_helper.rb
+7
-0
app/views/layouts/header/_help_dropdown.html.haml
app/views/layouts/header/_help_dropdown.html.haml
+5
-1
changelogs/unreleased/25341-add-what-s-new-menu-item-in-top-navigation.yml
...ased/25341-add-what-s-new-menu-item-in-top-navigation.yml
+5
-0
lib/gitlab.rb
lib/gitlab.rb
+40
-8
lib/gitlab/release_blog_post.rb
lib/gitlab/release_blog_post.rb
+40
-0
lib/gitlab/version_info.rb
lib/gitlab/version_info.rb
+8
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/features/dashboard/help_spec.rb
spec/features/dashboard/help_spec.rb
+16
-6
spec/lib/gitlab/release_blog_post_spec.rb
spec/lib/gitlab/release_blog_post_spec.rb
+97
-0
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+77
-0
spec/spec_helper.rb
spec/spec_helper.rb
+5
-0
No files found.
app/helpers/release_blog_post_helper.rb
0 → 100644
View file @
cc281afb
# frozen_string_literal: true
module
ReleaseBlogPostHelper
def
blog_post_url
Gitlab
::
ReleaseBlogPost
.
instance
.
blog_post_url
end
end
app/views/layouts/header/_help_dropdown.html.haml
View file @
cc281afb
-
show_blog_link
=
current_user_menu?
(
:help
)
&&
blog_post_url
.
present?
%ul
%ul
-
if
current_user_menu?
(
:help
)
-
if
current_user_menu?
(
:help
)
%li
%li
=
link_to
_
(
"Help"
),
help_path
=
link_to
_
(
"Help"
),
help_path
%li
.divider
%li
.divider
-
if
show_blog_link
%li
%li
=
link_to
_
(
"Submit feedback"
),
"https://about.gitlab.com/submit-feedback"
=
link_to
_
(
"What's new?"
),
blog_post_url
%li
=
link_to
_
(
"Submit feedback"
),
"https://about.gitlab.com/submit-feedback"
-
if
current_user_menu?
(
:help
)
||
current_user_menu?
(
:settings
)
||
current_user_menu?
(
:profile
)
-
if
current_user_menu?
(
:help
)
||
current_user_menu?
(
:settings
)
||
current_user_menu?
(
:profile
)
=
render
'shared/user_dropdown_contributing_link'
=
render
'shared/user_dropdown_contributing_link'
changelogs/unreleased/25341-add-what-s-new-menu-item-in-top-navigation.yml
0 → 100644
View file @
cc281afb
---
title
:
Resolve Add What's new menu item in top navigation
merge_request
:
23186
author
:
type
:
added
lib/gitlab.rb
View file @
cc281afb
...
@@ -27,12 +27,52 @@ module Gitlab
...
@@ -27,12 +27,52 @@ module Gitlab
end
end
end
end
def
self
.
version_info
Gitlab
::
VersionInfo
.
parse
(
Gitlab
::
VERSION
)
end
COM_URL
=
'https://gitlab.com'
.
freeze
COM_URL
=
'https://gitlab.com'
.
freeze
APP_DIRS_PATTERN
=
%r{^/?(app|config|ee|lib|spec|
\(\w
*
\)
)}
APP_DIRS_PATTERN
=
%r{^/?(app|config|ee|lib|spec|
\(\w
*
\)
)}
SUBDOMAIN_REGEX
=
%r{
\A
https://[a-z0-9]+
\.
gitlab
\.
com
\z
}
SUBDOMAIN_REGEX
=
%r{
\A
https://[a-z0-9]+
\.
gitlab
\.
com
\z
}
VERSION
=
File
.
read
(
root
.
join
(
"VERSION"
)).
strip
.
freeze
VERSION
=
File
.
read
(
root
.
join
(
"VERSION"
)).
strip
.
freeze
INSTALLATION_TYPE
=
File
.
read
(
root
.
join
(
"INSTALLATION_TYPE"
)).
strip
.
freeze
INSTALLATION_TYPE
=
File
.
read
(
root
.
join
(
"INSTALLATION_TYPE"
)).
strip
.
freeze
def
self
.
pre_release?
VERSION
.
include?
(
'pre'
)
end
def
self
.
final_release?
!
VERSION
.
include?
(
'rc'
)
&&
!
pre_release?
end
def
self
.
minor_release
"
#{
version_info
.
major
}
.
#{
version_info
.
minor
}
"
end
def
self
.
prev_minor_release
"
#{
version_info
.
major
}
.
#{
version_info
.
minor
-
1
}
"
end
def
self
.
prev_major_release
"
#{
version_info
.
major
.
to_i
-
1
}
"
end
def
self
.
new_major_release?
version_info
.
minor
.
to_i
.
zero?
end
def
self
.
previous_release
if
version_info
.
minor_version?
if
version_info
.
patch_version?
minor_release
else
prev_minor_release
end
else
prev_major_release
end
end
def
self
.
com?
def
self
.
com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com
# Check `gl_subdomain?` as well to keep parity with gitlab.com
Gitlab
.
config
.
gitlab
.
url
==
COM_URL
||
gl_subdomain?
Gitlab
.
config
.
gitlab
.
url
==
COM_URL
||
gl_subdomain?
...
@@ -49,12 +89,4 @@ module Gitlab
...
@@ -49,12 +89,4 @@ 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
def
self
.
version_info
Gitlab
::
VersionInfo
.
parse
(
Gitlab
::
VERSION
)
end
end
end
lib/gitlab/release_blog_post.rb
0 → 100644
View file @
cc281afb
# frozen_string_literal: true
require
'singleton'
module
Gitlab
class
ReleaseBlogPost
include
Singleton
RELEASE_RSS_URL
=
'https://about.gitlab.com/releases.xml'
def
blog_post_url
@url
||=
fetch_blog_post_url
end
private
def
fetch_blog_post_url
installed_version
=
Gitlab
.
final_release?
?
Gitlab
.
minor_release
:
Gitlab
.
previous_release
response
=
Gitlab
::
HTTP
.
get
(
RELEASE_RSS_URL
,
verify:
false
)
return
unless
response
.
code
==
200
blog_entry
=
find_installed_blog_entry
(
response
,
installed_version
)
blog_entry
[
'id'
]
if
blog_entry
end
def
find_installed_blog_entry
(
response
,
installed_version
)
response
[
'feed'
][
'entry'
].
find
do
|
entry
|
entry
[
'release'
]
==
installed_version
||
matches_previous_release_post
(
entry
[
'release'
],
installed_version
)
end
end
def
should_match_previous_release_post?
Gitlab
.
new_major_release?
&&
!
Gitlab
.
final_release?
end
def
matches_previous_release_post
(
rss_release_version
,
installed_version
)
should_match_previous_release_post?
&&
rss_release_version
[
/\d+/
]
==
installed_version
end
end
end
lib/gitlab/version_info.rb
View file @
cc281afb
...
@@ -20,6 +20,14 @@ module Gitlab
...
@@ -20,6 +20,14 @@ module Gitlab
@patch
=
patch
@patch
=
patch
end
end
def
minor_version?
minor
.
to_i
>
0
end
def
patch_version?
patch
.
to_i
>
0
end
def
<
=>
(
other
)
def
<
=>
(
other
)
return
unless
other
.
is_a?
VersionInfo
return
unless
other
.
is_a?
VersionInfo
return
unless
valid?
&&
other
.
valid?
return
unless
valid?
&&
other
.
valid?
...
...
locale/gitlab.pot
View file @
cc281afb
...
@@ -7659,6 +7659,9 @@ msgstr ""
...
@@ -7659,6 +7659,9 @@ msgstr ""
msgid "Web terminal"
msgid "Web terminal"
msgstr ""
msgstr ""
msgid "What's new?"
msgstr ""
msgid "When a runner is locked, it cannot be assigned to other projects"
msgid "When a runner is locked, it cannot be assigned to other projects"
msgstr ""
msgstr ""
...
...
spec/features/dashboard/help_spec.rb
View file @
cc281afb
...
@@ -5,13 +5,23 @@ RSpec.describe 'Dashboard Help' do
...
@@ -5,13 +5,23 @@ RSpec.describe 'Dashboard Help' do
sign_in
(
create
(
:user
))
sign_in
(
create
(
:user
))
end
end
it
'renders correctly markdown'
do
context
'help dropdown'
do
visit
help_page_path
(
"administration/raketasks/maintenance"
)
it
'shows the "What\'s new?" menu item'
do
visit
root_dashboard_path
expect
(
page
).
to
have_content
(
'Gather information about GitLab and the system it runs on'
)
expect
(
page
.
find
(
'.header-help .dropdown-menu'
)).
to
have_text
(
"What's new?"
)
end
end
context
'documentation'
do
it
'renders correctly markdown'
do
visit
help_page_path
(
"administration/raketasks/maintenance"
)
expect
(
page
).
to
have_content
(
'Gather information about GitLab and the system it runs on'
)
node
=
find
(
'.documentation h2 a#user-content-check-gitlab-configuration'
)
node
=
find
(
'.documentation h2 a#user-content-check-gitlab-configuration'
)
expect
(
node
[
:href
]).
to
eq
'#check-gitlab-configuration'
expect
(
node
[
:href
]).
to
eq
'#check-gitlab-configuration'
expect
(
find
(
:xpath
,
"
#{
node
.
path
}
/.."
).
text
).
to
eq
'Check GitLab configuration'
expect
(
find
(
:xpath
,
"
#{
node
.
path
}
/.."
).
text
).
to
eq
'Check GitLab configuration'
end
end
end
end
end
spec/lib/gitlab/release_blog_post_spec.rb
0 → 100644
View file @
cc281afb
require
'spec_helper'
describe
Gitlab
::
ReleaseBlogPost
do
describe
'.blog_post_url'
do
let
(
:releases_xml
)
do
<<~
EOS
<?xml version='1.0' encoding='utf-8' ?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<entry>
<release>11.2</release>
<id>https://about.gitlab.com/2018/08/22/gitlab-11-2-released/</id>
</entry>
<entry>
<release>11.1</release>
<id>https://about.gitlab.com/2018/07/22/gitlab-11-1-released/</id>
</entry>
<entry>
<release>11.0</release>
<id>https://about.gitlab.com/2018/06/22/gitlab-11-0-released/</id>
</entry>
<entry>
<release>10.8</release>
<id>https://about.gitlab.com/2018/05/22/gitlab-10-8-released/</id>
</entry>
</feed>
EOS
end
subject
{
described_class
.
send
(
:new
).
blog_post_url
}
before
do
stub_request
(
:get
,
'https://about.gitlab.com/releases.xml'
)
.
to_return
(
status:
200
,
headers:
{
'content-type'
=>
[
'text/xml'
]
},
body:
releases_xml
)
end
context
'matches GitLab version to blog post url'
do
it
'returns the correct url for major pre release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.0-pre'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/05/22/gitlab-10-8-released/'
)
end
it
'returns the correct url for major release candidate'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.0-rc3'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/05/22/gitlab-10-8-released/'
)
end
it
'returns the correct url for major release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.0'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/06/22/gitlab-11-0-released/'
)
end
it
'returns the correct url for minor pre release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.0-pre'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/07/22/gitlab-11-1-released/'
)
end
it
'returns the correct url for minor release candidate'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.0-rc3'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/07/22/gitlab-11-1-released/'
)
end
it
'returns the correct url for minor release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.0'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/08/22/gitlab-11-2-released/'
)
end
it
'returns the correct url for patch pre release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.1-pre'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/08/22/gitlab-11-2-released/'
)
end
it
'returns the correct url for patch release candidate'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.1-rc3'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/08/22/gitlab-11-2-released/'
)
end
it
'returns the correct url for patch release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.1'
)
expect
(
subject
).
to
eql
(
'https://about.gitlab.com/2018/08/22/gitlab-11-2-released/'
)
end
it
'returns nil when no blog post is matched'
do
stub_const
(
'Gitlab::VERSION'
,
'9.0.0'
)
expect
(
subject
).
to
be
(
nil
)
end
end
end
end
spec/lib/gitlab_spec.rb
View file @
cc281afb
...
@@ -8,6 +8,7 @@ describe Gitlab do
...
@@ -8,6 +8,7 @@ describe Gitlab do
expect
(
described_class
.
root
).
to
eq
(
Pathname
.
new
(
File
.
expand_path
(
'../..'
,
__dir__
)))
expect
(
described_class
.
root
).
to
eq
(
Pathname
.
new
(
File
.
expand_path
(
'../..'
,
__dir__
)))
end
end
end
end
describe
'.revision'
do
describe
'.revision'
do
let
(
:cmd
)
{
%W[
#{
described_class
.
config
.
git
.
bin_path
}
log --pretty=format:%h -n 1]
}
let
(
:cmd
)
{
%W[
#{
described_class
.
config
.
git
.
bin_path
}
log --pretty=format:%h -n 1]
}
...
@@ -69,6 +70,82 @@ describe Gitlab do
...
@@ -69,6 +70,82 @@ describe Gitlab do
end
end
end
end
describe
'.final_release?'
do
subject
{
described_class
.
final_release?
}
context
'returns the corrent boolean value'
do
it
'is false for a pre release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.0-pre'
)
expect
(
subject
).
to
be
false
end
it
'is false for a release candidate'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.0-rc2'
)
expect
(
subject
).
to
be
false
end
it
'is true for a final release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.2'
)
expect
(
subject
).
to
be
true
end
end
end
describe
'.minor_release'
do
subject
{
described_class
.
minor_release
}
it
'returns the minor release of the full GitLab version'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.1-rc3'
)
expect
(
subject
).
to
eql
'11.0'
end
end
describe
'.previous_release'
do
subject
{
described_class
.
previous_release
}
context
'it should return the previous release'
do
it
'returns the previous major version when GitLab major version is not final'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.1-pre'
)
expect
(
subject
).
to
eql
'10'
end
it
'returns the current minor version when the GitLab patch version is RC and > 0'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.1-rc3'
)
expect
(
subject
).
to
eql
'11.2'
end
it
'returns the previous minor version when the GitLab patch version is RC and 0'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.0-rc3'
)
expect
(
subject
).
to
eql
'11.1'
end
end
end
describe
'.new_major_release?'
do
subject
{
described_class
.
new_major_release?
}
context
'returns the corrent boolean value'
do
it
'is true when the minor version is 0 and the patch is a pre release'
do
stub_const
(
'Gitlab::VERSION'
,
'11.0.1-pre'
)
expect
(
subject
).
to
be
true
end
it
'is false when the minor version is above 0'
do
stub_const
(
'Gitlab::VERSION'
,
'11.2.1-rc3'
)
expect
(
subject
).
to
be
false
end
end
end
describe
'.com?'
do
describe
'.com?'
do
it
'is true when on GitLab.com'
do
it
'is true when on GitLab.com'
do
stub_config_setting
(
url:
'https://gitlab.com'
)
stub_config_setting
(
url:
'https://gitlab.com'
)
...
...
spec/spec_helper.rb
View file @
cc281afb
...
@@ -127,6 +127,11 @@ RSpec.configure do |config|
...
@@ -127,6 +127,11 @@ RSpec.configure do |config|
.
and_return
(
false
)
.
and_return
(
false
)
end
end
config
.
before
(
:suite
)
do
# Set latest release blog post URL for "What's new?" link
Gitlab
::
ReleaseBlogPost
.
instance
.
instance_variable_set
(
:@url
,
'https://about.gitlab.com'
)
end
config
.
before
(
:example
,
:request_store
)
do
config
.
before
(
:example
,
:request_store
)
do
RequestStore
.
begin!
RequestStore
.
begin!
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment