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
742cf277
Commit
742cf277
authored
Jul 18, 2018
by
Tuğçe Nur Taş
Committed by
Phil Hughes
Jul 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Features/show project id on home panel
parent
9bdc9b1a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
34 deletions
+98
-34
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+3
-0
changelogs/unreleased/features-show-project-id-on-home-panel.yml
...ogs/unreleased/features-show-project-id-on-home-panel.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/views/projects/_home_panel.html.haml_spec.rb
spec/views/projects/_home_panel.html.haml_spec.rb
+87
-34
No files found.
app/views/projects/_home_panel.html.haml
View file @
742cf277
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
.project-home-desc
.project-home-desc
-
if
@project
.
description
.
present?
-
if
@project
.
description
.
present?
=
markdown_field
(
@project
,
:description
)
=
markdown_field
(
@project
,
:description
)
-
if
can?
(
current_user
,
:read_project
,
@project
)
.text-secondary.prepend-top-8
=
s_
(
'ProjectPage|Project ID: %{project_id}'
)
%
{
project_id:
@project
.
id
}
-
if
@project
.
forked?
-
if
@project
.
forked?
%p
%p
...
...
changelogs/unreleased/features-show-project-id-on-home-panel.yml
0 → 100644
View file @
742cf277
---
title
:
Show Project ID on project home panel
merge_request
:
20305
author
:
Tuğçe Nur Taş
type
:
added
locale/gitlab.pot
View file @
742cf277
...
@@ -4057,6 +4057,9 @@ msgstr ""
...
@@ -4057,6 +4057,9 @@ msgstr ""
msgid "ProjectLifecycle|Stage"
msgid "ProjectLifecycle|Stage"
msgstr ""
msgstr ""
msgid "ProjectPage|Project ID: %{project_id}"
msgstr ""
msgid "Projects"
msgid "Projects"
msgstr ""
msgstr ""
...
...
spec/views/projects/_home_panel.html.haml_spec.rb
View file @
742cf277
require
'spec_helper'
require
'spec_helper'
describe
'projects/_home_panel'
do
describe
'projects/_home_panel'
do
let
(
:group
)
{
create
(
:group
)
}
context
'notifications'
do
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:notification_settings
)
do
user
&
.
notification_settings_for
(
project
)
end
before
do
before
do
assign
(
:project
,
project
)
assign
(
:project
,
project
)
assign
(
:notification_setting
,
notification_settings
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
false
)
allow
(
view
).
to
receive
(
:can?
).
with
(
user
,
:read_project
,
project
).
and_return
(
false
)
end
end
context
'when user is signed in'
do
context
'when user is signed in'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
notification_settings
=
user
.
notification_settings_for
(
project
)
assign
(
:notification_setting
,
notification_settings
)
end
it
'makes it possible to set notification level'
do
it
'makes it possible to set notification level'
do
render
render
...
@@ -30,26 +30,19 @@ describe 'projects/_home_panel' do
...
@@ -30,26 +30,19 @@ describe 'projects/_home_panel' do
context
'when user is signed out'
do
context
'when user is signed out'
do
let
(
:user
)
{
nil
}
let
(
:user
)
{
nil
}
before
do
assign
(
:notification_setting
,
nil
)
end
it
'is not possible to set notification level'
do
it
'is not possible to set notification level'
do
render
render
expect
(
rendered
).
not_to
have_selector
(
'.notification_dropdown'
)
expect
(
rendered
).
not_to
have_selector
(
'.notification_dropdown'
)
end
end
end
end
context
'when project'
do
let!
(
:user
)
{
create
(
:user
)
}
let
(
:badges
)
{
project
.
badges
}
context
'has no badges'
do
it
'should not render any badge'
do
render
expect
(
rendered
).
to
have_selector
(
'.project-badges'
)
expect
(
rendered
).
not_to
have_selector
(
'.project-badges > a'
)
end
end
end
context
'badges'
do
shared_examples
'show badges'
do
shared_examples
'show badges'
do
it
'should render the all badges'
do
it
'should render the all badges'
do
render
render
...
@@ -62,7 +55,31 @@ describe 'projects/_home_panel' do
...
@@ -62,7 +55,31 @@ describe 'projects/_home_panel' do
end
end
end
end
let
(
:user
)
{
create
(
:user
)
}
let
(
:badges
)
{
project
.
badges
}
before
do
assign
(
:project
,
project
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:can?
).
with
(
user
,
:read_project
,
project
).
and_return
(
false
)
end
context
'has no badges'
do
let
(
:project
)
{
create
(
:project
)
}
it
'should not render any badge'
do
render
expect
(
rendered
).
to
have_selector
(
'.project-badges'
)
expect
(
rendered
).
not_to
have_selector
(
'.project-badges > a'
)
end
end
context
'only has group badges'
do
context
'only has group badges'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
before
do
before
do
create
(
:group_badge
,
group:
project
.
group
)
create
(
:group_badge
,
group:
project
.
group
)
end
end
...
@@ -71,6 +88,8 @@ describe 'projects/_home_panel' do
...
@@ -71,6 +88,8 @@ describe 'projects/_home_panel' do
end
end
context
'only has project badges'
do
context
'only has project badges'
do
let
(
:project
)
{
create
(
:project
)
}
before
do
before
do
create
(
:project_badge
,
project:
project
)
create
(
:project_badge
,
project:
project
)
end
end
...
@@ -79,6 +98,9 @@ describe 'projects/_home_panel' do
...
@@ -79,6 +98,9 @@ describe 'projects/_home_panel' do
end
end
context
'has both group and project badges'
do
context
'has both group and project badges'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
before
do
before
do
create
(
:project_badge
,
project:
project
)
create
(
:project_badge
,
project:
project
)
create
(
:group_badge
,
group:
project
.
group
)
create
(
:group_badge
,
group:
project
.
group
)
...
@@ -87,4 +109,35 @@ describe 'projects/_home_panel' do
...
@@ -87,4 +109,35 @@ describe 'projects/_home_panel' do
it_behaves_like
'show badges'
it_behaves_like
'show badges'
end
end
end
end
context
'project id'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
assign
(
:project
,
project
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
end
context
'user can read project'
do
it
'is shown'
do
allow
(
view
).
to
receive
(
:can?
).
with
(
user
,
:read_project
,
project
).
and_return
(
true
)
render
expect
(
rendered
).
to
have_content
(
"Project ID:
#{
project
.
id
}
"
)
end
end
context
'user cannot read project'
do
it
'is not shown'
do
allow
(
view
).
to
receive
(
:can?
).
with
(
user
,
:read_project
,
project
).
and_return
(
false
)
render
expect
(
rendered
).
not_to
have_content
(
"Project ID:
#{
project
.
id
}
"
)
end
end
end
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