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
Jérome Perrin
gitlab-ce
Commits
d47fca53
Commit
d47fca53
authored
Nov 16, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow commit note to be visible if repo is visible
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1263708d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
5 deletions
+36
-5
app/helpers/events_helper.rb
app/helpers/events_helper.rb
+2
-2
app/models/event.rb
app/models/event.rb
+3
-3
changelogs/unreleased/23824-activity-page-does-not-show-commits-comments.yml
...ed/23824-activity-page-does-not-show-commits-comments.yml
+4
-0
spec/models/event_spec.rb
spec/models/event_spec.rb
+27
-0
No files found.
app/helpers/events_helper.rb
View file @
d47fca53
...
@@ -86,7 +86,7 @@ module EventsHelper
...
@@ -86,7 +86,7 @@ module EventsHelper
elsif
event
.
merge_request?
elsif
event
.
merge_request?
namespace_project_merge_request_url
(
event
.
project
.
namespace
,
namespace_project_merge_request_url
(
event
.
project
.
namespace
,
event
.
project
,
event
.
merge_request
)
event
.
project
,
event
.
merge_request
)
elsif
event
.
note?
&&
event
.
commit_note?
elsif
event
.
commit_note?
namespace_project_commit_url
(
event
.
project
.
namespace
,
event
.
project
,
namespace_project_commit_url
(
event
.
project
.
namespace
,
event
.
project
,
event
.
note_target
)
event
.
note_target
)
elsif
event
.
note?
elsif
event
.
note?
...
@@ -127,7 +127,7 @@ module EventsHelper
...
@@ -127,7 +127,7 @@ module EventsHelper
end
end
def
event_note_target_path
(
event
)
def
event_note_target_path
(
event
)
if
event
.
note?
&&
event
.
commit_note?
if
event
.
commit_note?
namespace_project_commit_path
(
event
.
project
.
namespace
,
namespace_project_commit_path
(
event
.
project
.
namespace
,
event
.
project
,
event
.
project
,
event
.
note_target
,
event
.
note_target
,
...
...
app/models/event.rb
View file @
d47fca53
...
@@ -62,7 +62,7 @@ class Event < ActiveRecord::Base
...
@@ -62,7 +62,7 @@ class Event < ActiveRecord::Base
end
end
def
visible_to_user?
(
user
=
nil
)
def
visible_to_user?
(
user
=
nil
)
if
push?
if
push?
||
commit_note?
Ability
.
allowed?
(
user
,
:download_code
,
project
)
Ability
.
allowed?
(
user
,
:download_code
,
project
)
elsif
membership_changed?
elsif
membership_changed?
true
true
...
@@ -283,7 +283,7 @@ class Event < ActiveRecord::Base
...
@@ -283,7 +283,7 @@ class Event < ActiveRecord::Base
end
end
def
commit_note?
def
commit_note?
target
.
for_commit?
note?
&&
target
&&
target
.
for_commit?
end
end
def
issue_note?
def
issue_note?
...
@@ -295,7 +295,7 @@ class Event < ActiveRecord::Base
...
@@ -295,7 +295,7 @@ class Event < ActiveRecord::Base
end
end
def
project_snippet_note?
def
project_snippet_note?
target
.
for_snippet?
note?
&&
target
&&
target
.
for_snippet?
end
end
def
note_target
def
note_target
...
...
changelogs/unreleased/23824-activity-page-does-not-show-commits-comments.yml
0 → 100644
View file @
d47fca53
---
title
:
Allow commit note to be visible if repo is visible
merge_request
:
author
:
spec/models/event_spec.rb
View file @
d47fca53
...
@@ -94,6 +94,7 @@ describe Event, models: true do
...
@@ -94,6 +94,7 @@ describe Event, models: true do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
author
,
assignee:
assignee
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
author
,
assignee:
assignee
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
,
assignee:
assignee
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
,
assignee:
assignee
)
}
let
(
:note_on_commit
)
{
create
(
:note_on_commit
,
project:
project
)
}
let
(
:note_on_issue
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
project
)
}
let
(
:note_on_issue
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
project
)
}
let
(
:note_on_confidential_issue
)
{
create
(
:note_on_issue
,
noteable:
confidential_issue
,
project:
project
)
}
let
(
:note_on_confidential_issue
)
{
create
(
:note_on_issue
,
noteable:
confidential_issue
,
project:
project
)
}
let
(
:event
)
{
Event
.
new
(
project:
project
,
target:
target
,
author_id:
author
.
id
)
}
let
(
:event
)
{
Event
.
new
(
project:
project
,
target:
target
,
author_id:
author
.
id
)
}
...
@@ -103,6 +104,32 @@ describe Event, models: true do
...
@@ -103,6 +104,32 @@ describe Event, models: true do
project
.
team
<<
[
guest
,
:guest
]
project
.
team
<<
[
guest
,
:guest
]
end
end
context
'commit note event'
do
let
(
:target
)
{
note_on_commit
}
it
do
aggregate_failures
do
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
context
'private project'
do
let
(
:project
)
{
create
(
:empty_project
,
:private
)
}
it
do
aggregate_failures
do
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
end
context
'issue event'
do
context
'issue event'
do
context
'for non confidential issues'
do
context
'for non confidential issues'
do
let
(
:target
)
{
issue
}
let
(
:target
)
{
issue
}
...
...
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