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
8e6c5621
Commit
8e6c5621
authored
May 11, 2021
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ultimate trial banner for non-group owning users
parent
526b222a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
13 deletions
+59
-13
ee/app/helpers/ee/user_callouts_helper.rb
ee/app/helpers/ee/user_callouts_helper.rb
+1
-1
ee/app/helpers/ee/users_helper.rb
ee/app/helpers/ee/users_helper.rb
+1
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+4
-4
ee/changelogs/unreleased/327043-remove-ultimate-trial-banner-for-users-that-are-not-already-a-g.yml
...imate-trial-banner-for-users-that-are-not-already-a-g.yml
+5
-0
ee/spec/helpers/ee/user_callouts_helper_spec.rb
ee/spec/helpers/ee/user_callouts_helper_spec.rb
+2
-2
ee/spec/helpers/users_helper_spec.rb
ee/spec/helpers/users_helper_spec.rb
+1
-1
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+33
-3
ee/spec/support/shared_examples/features/ultimate_trial_callout_shared_examples.rb
...amples/features/ultimate_trial_callout_shared_examples.rb
+12
-1
No files found.
ee/app/helpers/ee/user_callouts_helper.rb
View file @
8e6c5621
...
...
@@ -48,7 +48,7 @@ module EE
return
unless
show_ultimate_trial?
(
user
,
ULTIMATE_TRIAL
)
&&
user_default_dashboard?
(
user
)
&&
!
user
.
owns_paid_namespace?
&&
user
.
any_namespace
_without_trial?
user
.
owns_group
_without_trial?
render
'shared/ultimate_trial_callout_content'
end
...
...
ee/app/helpers/ee/users_helper.rb
View file @
8e6c5621
...
...
@@ -36,7 +36,7 @@ module EE
return
unless
::
Gitlab
.
com?
Rails
.
cache
.
fetch
([
'users'
,
user
.
id
,
'trials_allowed?'
],
expires_in:
10
.
minutes
)
do
!
user
.
has_paid_namespace?
&&
user
.
any_namespace
_without_trial?
!
user
.
has_paid_namespace?
&&
user
.
owns_group
_without_trial?
end
end
end
...
...
ee/app/models/ee/user.rb
View file @
8e6c5621
...
...
@@ -229,12 +229,12 @@ module EE
super
||
DEFAULT_GROUP_VIEW
end
# Returns true if the user
is a Reporter or higher on any namespace
# Returns true if the user
owns a group
# that has never had a trial (now or in the past)
def
any_namespace_without_trial?
::
Namespace
.
from
(
"(
#{
namespace_union_for_reporter_developer_maintainer_owned
}
)
#{
::
Namespace
.
table_name
}
"
)
def
owns_group_without_trial?
owned_groups
.
include_gitlab_subscription
.
where
(
parent_id:
nil
)
.
where
(
gitlab_subscriptions:
{
trial_ends_on:
nil
})
.
any?
end
...
...
ee/changelogs/unreleased/327043-remove-ultimate-trial-banner-for-users-that-are-not-already-a-g.yml
0 → 100644
View file @
8e6c5621
---
title
:
Remove ultimate trial banner for users that are not already a group admin
merge_request
:
59611
author
:
type
:
changed
ee/spec/helpers/ee/user_callouts_helper_spec.rb
View file @
8e6c5621
...
...
@@ -138,7 +138,7 @@ RSpec.describe EE::UserCalloutsHelper do
let
(
:user
)
{
namespace
.
owner
}
where
(
:
any_namespace
_without_trial?
,
:show_ultimate_trial?
,
:user_default_dashboard?
,
:has_no_trial_or_paid_plan?
,
:should_render?
)
do
where
(
:
owns_group
_without_trial?
,
:show_ultimate_trial?
,
:user_default_dashboard?
,
:has_no_trial_or_paid_plan?
,
:should_render?
)
do
true
|
true
|
true
|
true
|
true
true
|
true
|
true
|
false
|
false
true
|
true
|
false
|
true
|
false
...
...
@@ -161,7 +161,7 @@ RSpec.describe EE::UserCalloutsHelper do
before
do
allow
(
helper
).
to
receive
(
:show_ultimate_trial?
)
{
show_ultimate_trial?
}
allow
(
helper
).
to
receive
(
:user_default_dashboard?
)
{
user_default_dashboard?
}
allow
(
user
).
to
receive
(
:
any_namespace_without_trial?
)
{
any_namespace
_without_trial?
}
allow
(
user
).
to
receive
(
:
owns_group_without_trial?
)
{
owns_group
_without_trial?
}
unless
has_no_trial_or_paid_plan?
create
(
:gitlab_subscription
,
hosted_plan:
ultimate_plan
,
namespace:
namespace
)
...
...
ee/spec/helpers/users_helper_spec.rb
View file @
8e6c5621
...
...
@@ -21,7 +21,7 @@ RSpec.describe UsersHelper do
allow
(
helper
).
to
receive
(
:can?
).
and_return
(
false
)
allow
(
::
Gitlab
).
to
receive
(
:com?
)
{
gitlab_com?
}
allow
(
user
).
to
receive
(
:
any_namespace
_without_trial?
)
{
user_eligible?
}
allow
(
user
).
to
receive
(
:
owns_group
_without_trial?
)
{
user_eligible?
}
allow
(
user
).
to
receive
(
:has_paid_namespace?
)
{
has_paid_namespace?
}
end
...
...
ee/spec/models/ee/user_spec.rb
View file @
8e6c5621
...
...
@@ -136,7 +136,7 @@ RSpec.describe User do
it
'returns the user'
do
expect
(
described_class
.
find_by_smartcard_identity
(
smartcard_identity
.
subject
,
smartcard_identity
.
issuer
))
smartcard_identity
.
issuer
))
.
to
eq
(
user
)
end
end
...
...
@@ -1249,7 +1249,7 @@ RSpec.describe User do
before
do
allow
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:should_check_namespace_plan?
)
.
and_return
(
false
)
.
and_return
(
false
)
end
it
{
is_expected
.
to
contain_exactly
private_group
,
project_group
,
minimal_access_group
}
...
...
@@ -1263,7 +1263,7 @@ RSpec.describe User do
before
do
allow
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:should_check_namespace_plan?
)
.
and_return
(
true
)
.
and_return
(
true
)
create
(
:gitlab_subscription
,
:ultimate
,
namespace:
minimal_access_group
)
create
(
:group_member
,
:minimal_access
,
user:
user
,
source:
create
(
:group
))
end
...
...
@@ -1711,4 +1711,34 @@ RSpec.describe User do
it
{
is_expected
.
to
eq
(
result
)
}
end
end
describe
"#owns_group_without_trial"
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
subject
{
user
.
owns_group_without_trial?
}
it
'returns true if owns a group'
do
group
.
add_owner
(
user
)
is_expected
.
to
be
(
true
)
end
it
'returns false if is a member group'
do
group
.
add_maintainer
(
user
)
is_expected
.
to
be
(
false
)
end
it
'returns false if is not a member of any group'
do
is_expected
.
to
be
(
false
)
end
it
'returns false if owns a group with a plan on a trial with an end date'
do
group_with_plan
=
create
(
:group_with_plan
,
name:
'trial group'
,
plan: :premium_plan
,
trial_ends_on:
1
.
year
.
from_now
)
group_with_plan
.
add_owner
(
user
)
is_expected
.
to
be
(
false
)
end
end
end
ee/spec/support/shared_examples/features/ultimate_trial_callout_shared_examples.rb
View file @
8e6c5621
...
...
@@ -18,7 +18,10 @@ RSpec.shared_examples 'dashboard ultimate trial callout' do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
end
it
'shows dismissable promotion callout if default dashboard'
,
:js
do
it
'shows dismissable promotion callout if default dashboard for an owner'
,
:js
do
group
=
create
(
:group
)
group
.
add_owner
(
user
)
allow_any_instance_of
(
EE
::
DashboardHelper
).
to
receive
(
:user_default_dashboard?
).
and_return
(
true
)
visit
page_path
...
...
@@ -30,6 +33,14 @@ RSpec.shared_examples 'dashboard ultimate trial callout' do
expect
(
page
).
not_to
have_selector
'.promotion-callout'
end
it
'hides dismissable promotion callout if default dashboard for a non group owner'
do
allow_any_instance_of
(
EE
::
DashboardHelper
).
to
receive
(
:user_default_dashboard?
).
and_return
(
true
)
visit
page_path
expect
(
page
).
not_to
have_selector
'.promotion-callout'
end
it
'hides dismissable promotion callout if not default dashboard'
,
:js
do
allow_any_instance_of
(
EE
::
DashboardHelper
).
to
receive
(
:user_default_dashboard?
).
and_return
(
false
)
...
...
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