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
d580d4e1
Commit
d580d4e1
authored
Mar 26, 2020
by
Sean McGivern
Committed by
Heinrich Lee Yu
Apr 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EE::User#has_paid_namespace? plan check
parent
a2982624
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+3
-2
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+35
-0
No files found.
ee/app/models/ee/user.rb
View file @
d580d4e1
...
@@ -231,8 +231,9 @@ module EE
...
@@ -231,8 +231,9 @@ module EE
def
has_paid_namespace?
def
has_paid_namespace?
::
Namespace
::
Namespace
.
from
(
"(
#{
namespace_union_for_reporter_developer_maintainer_owned
(
:plan_id
)
}
)
#{
::
Namespace
.
table_name
}
"
)
.
from
(
"(
#{
namespace_union_for_reporter_developer_maintainer_owned
}
)
#{
::
Namespace
.
table_name
}
"
)
.
where
(
plan_id:
Plan
.
where
(
name:
Plan
::
PAID_HOSTED_PLANS
).
select
(
:id
))
.
include_gitlab_subscription
.
where
(
gitlab_subscriptions:
{
hosted_plan_id:
Plan
.
where
(
name:
Plan
::
PAID_HOSTED_PLANS
)
})
.
any?
.
any?
end
end
...
...
ee/spec/models/user_spec.rb
View file @
d580d4e1
...
@@ -1029,4 +1029,39 @@ describe User do
...
@@ -1029,4 +1029,39 @@ describe User do
end
end
end
end
end
end
describe
'#has_paid_namespace?'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:gold_group
)
{
create
(
:group_with_plan
,
plan: :gold_plan
)
}
let_it_be
(
:bronze_group
)
{
create
(
:group_with_plan
,
plan: :bronze_plan
)
}
let_it_be
(
:free_group
)
{
create
(
:group_with_plan
,
plan: :free_plan
)
}
let_it_be
(
:group_without_plan
)
{
create
(
:group
)
}
context
'when the user has Reporter or higher on at least one paid group'
do
it
'returns true'
do
gold_group
.
add_reporter
(
user
)
bronze_group
.
add_guest
(
user
)
expect
(
user
.
has_paid_namespace?
).
to
eq
(
true
)
end
end
context
'when the user is only a Guest on paid groups'
do
it
'returns false'
do
gold_group
.
add_guest
(
user
)
bronze_group
.
add_guest
(
user
)
free_group
.
add_owner
(
user
)
expect
(
user
.
has_paid_namespace?
).
to
eq
(
false
)
end
end
context
'when the user is not a member of any groups with plans'
do
it
'returns false'
do
group_without_plan
.
add_owner
(
user
)
expect
(
user
.
has_paid_namespace?
).
to
eq
(
false
)
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