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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
19d5c15b
Commit
19d5c15b
authored
May 12, 2020
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI minutes notification when unauthenticated
Don't display notification if user is unauthenticated
parent
c1fa2a2c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
8 deletions
+75
-8
ee/app/models/ci/minutes/context.rb
ee/app/models/ci/minutes/context.rb
+3
-5
ee/app/policies/ee/group_policy.rb
ee/app/policies/ee/group_policy.rb
+1
-0
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+1
-0
ee/changelogs/unreleased/fix-minutes-notification-when-unauthenticated.yml
...eleased/fix-minutes-notification-when-unauthenticated.yml
+5
-0
ee/spec/features/ci_shared_runner_warnings_spec.rb
ee/spec/features/ci_shared_runner_warnings_spec.rb
+3
-1
ee/spec/models/ci/minutes/context_spec.rb
ee/spec/models/ci/minutes/context_spec.rb
+17
-1
ee/spec/models/ci/minutes/notification_spec.rb
ee/spec/models/ci/minutes/notification_spec.rb
+3
-1
ee/spec/policies/group_policy_spec.rb
ee/spec/policies/group_policy_spec.rb
+21
-0
ee/spec/policies/project_policy_spec.rb
ee/spec/policies/project_policy_spec.rb
+21
-0
No files found.
ee/app/models/ci/minutes/context.rb
View file @
19d5c15b
...
@@ -18,11 +18,9 @@ module Ci
...
@@ -18,11 +18,9 @@ module Ci
end
end
def
can_see_status?
def
can_see_status?
if
project
return
false
unless
level
user
.
can?
(
:create_pipeline
,
project
)
else
Ability
.
allowed?
(
user
,
:read_ci_minutes_quota
,
level
)
namespace
.
all_pipelines
.
for_user
(
user
).
any?
end
end
end
private
private
...
...
ee/app/policies/ee/group_policy.rb
View file @
19d5c15b
...
@@ -91,6 +91,7 @@ module EE
...
@@ -91,6 +91,7 @@ module EE
enable
:create_jira_connect_subscription
enable
:create_jira_connect_subscription
enable
:maintainer_access
enable
:maintainer_access
enable
:admin_wiki
enable
:admin_wiki
enable
:read_ci_minutes_quota
end
end
rule
{
owner
}.
policy
do
rule
{
owner
}.
policy
do
...
...
ee/app/policies/ee/project_policy.rb
View file @
19d5c15b
...
@@ -181,6 +181,7 @@ module EE
...
@@ -181,6 +181,7 @@ module EE
enable
:destroy_feature_flag
enable
:destroy_feature_flag
enable
:admin_feature_flag
enable
:admin_feature_flag
enable
:admin_feature_flags_user_lists
enable
:admin_feature_flags_user_lists
enable
:read_ci_minutes_quota
end
end
rule
{
can?
(
:developer_access
)
&
iterations_available
}.
policy
do
rule
{
can?
(
:developer_access
)
&
iterations_available
}.
policy
do
...
...
ee/changelogs/unreleased/fix-minutes-notification-when-unauthenticated.yml
0 → 100644
View file @
19d5c15b
---
title
:
Fix CI minutes notification when unauthenticated
merge_request
:
31724
author
:
type
:
fixed
ee/spec/features/ci_shared_runner_warnings_spec.rb
View file @
19d5c15b
...
@@ -87,7 +87,9 @@ describe 'CI shared runner limits' do
...
@@ -87,7 +87,9 @@ describe 'CI shared runner limits' do
end
end
context
'when on a group related page'
do
context
'when on a group related page'
do
let!
(
:user_pipeline
)
{
create
(
:ci_pipeline
,
user:
user
,
project:
project
)
}
before
do
group
.
add_owner
(
user
)
end
where
(
:case_name
,
:percent
,
:remaining_minutes
)
do
where
(
:case_name
,
:percent
,
:remaining_minutes
)
do
'warning level'
|
30
|
4
'warning level'
|
30
|
4
...
...
ee/spec/models/ci/minutes/context_spec.rb
View file @
19d5c15b
...
@@ -36,6 +36,14 @@ describe Ci::Minutes::Context do
...
@@ -36,6 +36,14 @@ describe Ci::Minutes::Context do
expect
(
subject
.
can_see_status?
).
to
be_falsey
expect
(
subject
.
can_see_status?
).
to
be_falsey
end
end
end
end
context
'when user is not authenticated'
do
let
(
:user
)
{
nil
}
it
'cannot see status'
do
expect
(
subject
.
can_see_status?
).
to
be_falsey
end
end
end
end
end
end
...
@@ -45,7 +53,7 @@ describe Ci::Minutes::Context do
...
@@ -45,7 +53,7 @@ describe Ci::Minutes::Context do
describe
'#can_see_status'
do
describe
'#can_see_status'
do
context
'when eligible to see status'
do
context
'when eligible to see status'
do
before
do
before
do
create
(
:ci_pipeline
,
user:
user
,
project:
project
)
group
.
add_owner
(
user
)
end
end
it
'can see status'
do
it
'can see status'
do
...
@@ -58,6 +66,14 @@ describe Ci::Minutes::Context do
...
@@ -58,6 +66,14 @@ describe Ci::Minutes::Context do
expect
(
subject
.
can_see_status?
).
to
be_falsey
expect
(
subject
.
can_see_status?
).
to
be_falsey
end
end
end
end
context
'when user is not authenticated'
do
let
(
:user
)
{
nil
}
it
'cannot see status'
do
expect
(
subject
.
can_see_status?
).
to
be_falsey
end
end
end
end
end
end
end
end
ee/spec/models/ci/minutes/notification_spec.rb
View file @
19d5c15b
...
@@ -127,7 +127,9 @@ describe Ci::Minutes::Notification do
...
@@ -127,7 +127,9 @@ describe Ci::Minutes::Notification do
context
'when at namespace level'
do
context
'when at namespace level'
do
describe
'#show?'
do
describe
'#show?'
do
context
'when eligible to see notifications'
do
context
'when eligible to see notifications'
do
let!
(
:user_pipeline
)
{
create
(
:ci_pipeline
,
user:
user
,
project:
project
)
}
before
do
group
.
add_owner
(
user
)
end
context
'with a project that has runners enabled inside namespace'
do
context
'with a project that has runners enabled inside namespace'
do
it_behaves_like
'queries for notifications'
do
it_behaves_like
'queries for notifications'
do
...
...
ee/spec/policies/group_policy_spec.rb
View file @
19d5c15b
...
@@ -880,6 +880,27 @@ describe GroupPolicy do
...
@@ -880,6 +880,27 @@ describe GroupPolicy do
end
end
end
end
describe
':read_ci_minutes_quota'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:policy
)
{
:read_ci_minutes_quota
}
where
(
:role
,
:allowed
)
do
:guest
|
false
:reporter
|
false
:developer
|
false
:maintainer
|
true
:owner
|
true
:admin
|
true
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
end
end
it_behaves_like
'model with wiki policies'
do
it_behaves_like
'model with wiki policies'
do
let_it_be
(
:container
)
{
create
(
:group
)
}
let_it_be
(
:container
)
{
create
(
:group
)
}
let_it_be
(
:user
)
{
owner
}
let_it_be
(
:user
)
{
owner
}
...
...
ee/spec/policies/project_policy_spec.rb
View file @
19d5c15b
...
@@ -1376,4 +1376,25 @@ describe ProjectPolicy do
...
@@ -1376,4 +1376,25 @@ describe ProjectPolicy do
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
end
end
end
end
describe
':read_ci_minutes_quota'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:policy
)
{
:read_ci_minutes_quota
}
where
(
:role
,
:allowed
)
do
:guest
|
false
:reporter
|
false
:developer
|
true
:maintainer
|
true
:owner
|
true
:admin
|
true
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
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