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
33555bc7
Commit
33555bc7
authored
Apr 06, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove plan from namespaces factory
This column is not used anymore and setting this causes incorrect tests.
parent
4dc3a316
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
58 additions
and
101 deletions
+58
-101
ee/app/models/ee/namespace.rb
ee/app/models/ee/namespace.rb
+0
-1
ee/spec/factories/groups.rb
ee/spec/factories/groups.rb
+17
-0
ee/spec/factories/namespaces.rb
ee/spec/factories/namespaces.rb
+0
-10
ee/spec/features/billings/billing_plans_spec.rb
ee/spec/features/billings/billing_plans_spec.rb
+19
-24
ee/spec/features/groups/group_overview_spec.rb
ee/spec/features/groups/group_overview_spec.rb
+2
-4
ee/spec/finders/ee/projects_finder_spec.rb
ee/spec/finders/ee/projects_finder_spec.rb
+4
-1
ee/spec/finders/group_projects_finder_spec.rb
ee/spec/finders/group_projects_finder_spec.rb
+1
-3
ee/spec/lib/gitlab/group_plans_preloader_spec.rb
ee/spec/lib/gitlab/group_plans_preloader_spec.rb
+1
-1
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+1
-1
ee/spec/models/ee/namespace_spec.rb
ee/spec/models/ee/namespace_spec.rb
+2
-36
ee/spec/models/gitlab_subscription_spec.rb
ee/spec/models/gitlab_subscription_spec.rb
+2
-2
ee/spec/requests/api/groups_spec.rb
ee/spec/requests/api/groups_spec.rb
+1
-3
ee/spec/support/shared_examples/controllers/boards_actions_shared_examples.rb
...ed_examples/controllers/boards_actions_shared_examples.rb
+4
-10
ee/spec/support/shared_examples/features/gold_trial_callout_shared_examples.rb
...d_examples/features/gold_trial_callout_shared_examples.rb
+2
-1
ee/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
ee/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
+2
-4
No files found.
ee/app/models/ee/namespace.rb
View file @
33555bc7
...
...
@@ -36,7 +36,6 @@ module EE
scope
:include_gitlab_subscription
,
->
{
includes
(
:gitlab_subscription
)
}
scope
:join_gitlab_subscription
,
->
{
joins
(
"LEFT OUTER JOIN gitlab_subscriptions ON gitlab_subscriptions.namespace_id=namespaces.id"
)
}
scope
:with_plan
,
->
{
where
.
not
(
plan_id:
nil
)
}
scope
:with_shared_runners_minutes_limit
,
->
{
where
(
"namespaces.shared_runners_minutes_limit > 0"
)
}
scope
:with_extra_shared_runners_minutes_limit
,
->
{
where
(
"namespaces.extra_shared_runners_minutes_limit > 0"
)
}
scope
:with_shared_runners_minutes_exceeding_default_limit
,
->
do
...
...
ee/spec/factories/groups.rb
View file @
33555bc7
...
...
@@ -60,4 +60,21 @@ FactoryBot.define do
group:
group
)
end
end
factory
:group_with_plan
,
parent: :group
do
transient
do
plan
{
:default_plan
}
trial_ends_on
{
nil
}
end
after
(
:create
)
do
|
group
,
evaluator
|
if
evaluator
.
plan
create
(
:gitlab_subscription
,
namespace:
group
,
hosted_plan:
create
(
evaluator
.
plan
),
trial:
evaluator
.
trial_ends_on
.
present?
,
trial_ends_on:
evaluator
.
trial_ends_on
)
end
end
end
end
ee/spec/factories/namespaces.rb
View file @
33555bc7
...
...
@@ -2,16 +2,6 @@
FactoryBot
.
modify
do
factory
:namespace
do
transient
do
plan
{
nil
}
end
before
(
:create
)
do
|
namespace
,
evaluator
|
if
evaluator
.
plan
.
present?
namespace
.
plan
=
create
(
evaluator
.
plan
)
end
end
trait
:with_build_minutes
do
namespace_statistics
factory: :namespace_statistics
,
shared_runners_seconds:
400
.
minutes
.
to_i
end
...
...
ee/spec/features/billings/billing_plans_spec.rb
View file @
33555bc7
...
...
@@ -370,23 +370,19 @@ describe 'Billing plan pages', :feature do
end
context
'on sub-group'
do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
plan: :bronze_plan
)
}
let!
(
:group_member
)
{
create
(
:group_member
,
:owner
,
group:
group
,
user:
user
)
}
let
(
:subgroup1
)
{
create
(
:group
,
parent:
group
,
plan: :silver_plan
)
}
let!
(
:subgroup1_member
)
{
create
(
:group_member
,
:owner
,
group:
subgroup1
,
user:
user2
)
}
let
(
:subgroup2
)
{
create
(
:group
,
parent:
subgroup1
)
}
let!
(
:subgroup2_member
)
{
create
(
:group_member
,
:owner
,
group:
subgroup2
,
user:
user3
)
}
let
(
:page_path
)
{
group_billings_path
(
subgroup2
)
}
let
(
:group
)
{
create
(
:group_with_plan
,
plan: :bronze_plan
)
}
let
(
:plan
)
{
bronze_plan
}
let
(
:namespace
)
{
group
}
context
'on bronze'
do
let
(
:plan
)
{
bronze_plan
}
let!
(
:group_member
)
{
create
(
:group_member
,
:owner
,
group:
group
,
user:
user
)
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
let
(
:subgroup1
)
{
create
(
:group
,
parent:
group
)
}
let!
(
:subgroup1_member
)
{
create
(
:group_member
,
:owner
,
group:
subgroup1
)
}
let
(
:subgroup2
)
{
create
(
:group
,
parent:
subgroup1
)
}
let!
(
:subgroup2_member
)
{
create
(
:group_member
,
:owner
,
group:
subgroup2
)
}
let
(
:page_path
)
{
group_billings_path
(
subgroup2
)
}
before
do
visit
page_path
...
...
@@ -402,7 +398,6 @@ describe 'Billing plan pages', :feature do
expect
(
page
).
not_to
have_css
(
'.billing-plans'
)
end
end
end
context
'with unexpected JSON'
do
let
(
:plan
)
{
free_plan
}
...
...
ee/spec/features/groups/group_overview_spec.rb
View file @
33555bc7
...
...
@@ -28,14 +28,12 @@ describe 'Group overview', :js do
before
do
stub_licensed_features
(
security_dashboard:
true
)
enable_namespace_license_check!
create
(
:gitlab_subscription
,
hosted_plan:
group
.
plan
,
namespace:
group
)
end
let
(
:user
)
{
create
(
:user
,
group_view: :security_dashboard
)
}
context
'and Security Dashboard feature is available for a group'
do
let
(
:group
)
{
create
(
:group
,
plan: :gold_plan
)
}
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :gold_plan
)
}
it
'displays the Security Dashboard view'
do
visit
group_path
(
group
)
...
...
@@ -54,7 +52,7 @@ describe 'Group overview', :js do
end
context
'and Security Dashboard feature is not available for a group'
do
let
(
:group
)
{
create
(
:group
,
plan: :bronze_plan
)
}
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :bronze_plan
)
}
it
'displays the "Security Dashboard unavailable" empty state'
do
visit
group_path
(
group
)
...
...
ee/spec/finders/ee/projects_finder_spec.rb
View file @
33555bc7
...
...
@@ -50,7 +50,10 @@ describe ProjectsFinder do
private
def
create_project
(
plan
)
create
(
:project
,
:public
,
namespace:
create
(
:namespace
,
plan:
plan
))
namespace
=
create
(
:namespace_with_plan
,
plan:
plan
)
namespace
.
update
(
plan:
namespace
.
gitlab_subscription
&
.
hosted_plan
)
create
(
:project
,
:public
,
namespace:
namespace
)
end
end
end
...
...
ee/spec/finders/group_projects_finder_spec.rb
View file @
33555bc7
...
...
@@ -39,13 +39,11 @@ describe GroupProjectsFinder do
end
context
'when security dashboard is enabled for a group'
do
let
(
:group
)
{
create
(
:group
,
plan: :gold_plan
)
}
# overriding group from 'GroupProjectsFinder context'
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :gold_plan
)
}
# overriding group from 'GroupProjectsFinder context'
before
do
stub_licensed_features
(
security_dashboard:
true
)
enable_namespace_license_check!
create
(
:gitlab_subscription
,
hosted_plan:
group
.
plan
,
namespace:
group
)
end
it
{
is_expected
.
to
contain_exactly
(
project_with_reports
)
}
...
...
ee/spec/lib/gitlab/group_plans_preloader_spec.rb
View file @
33555bc7
...
...
@@ -17,7 +17,7 @@ describe Gitlab::GroupPlansPreloader do
group1
=
create
(
:group
,
name:
'group-1'
)
create
(
:gitlab_subscription
,
namespace:
group1
,
hosted_plan_id:
plan1
.
id
)
group2
=
create
(
:group
,
name:
'group-2'
,
plan_id:
plan2
.
id
)
group2
=
create
(
:group
,
name:
'group-2'
)
create
(
:gitlab_subscription
,
namespace:
group2
,
hosted_plan_id:
plan2
.
id
)
create
(
:group
,
name:
'group-3'
,
parent:
group1
)
...
...
ee/spec/models/ci/build_spec.rb
View file @
33555bc7
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
describe
Ci
::
Build
do
let_it_be
(
:group
)
{
create
(
:group
,
plan: :bronze_plan
)
}
let_it_be
(
:group
)
{
create
(
:group
_with_plan
,
plan: :bronze_plan
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
let
(
:pipeline
)
do
...
...
ee/spec/models/ee/namespace_spec.rb
View file @
33555bc7
...
...
@@ -214,53 +214,19 @@ describe Namespace do
end
context
'scopes'
do
describe
'.with_plan'
do
let!
(
:namespace
)
{
create
:namespace
,
plan:
namespace_plan
}
context
'plan is set'
do
let
(
:namespace_plan
)
{
:bronze_plan
}
it
'returns namespaces with plan'
do
expect
(
described_class
.
with_plan
).
to
eq
([
namespace
])
end
end
context
'plan is not set'
do
context
'plan is empty string'
do
let
(
:namespace_plan
)
{
''
}
it
'returns no namespace'
do
expect
(
described_class
.
with_plan
).
to
be_empty
end
end
context
'plan is nil'
do
let
(
:namespace_plan
)
{
nil
}
it
'returns no namespace'
do
expect
(
described_class
.
with_plan
).
to
be_empty
end
end
end
end
describe
'.with_feature_available_in_plan'
do
let!
(
:namespace
)
{
create
:namespace
,
plan:
namespace_plan
}
let!
(
:namespace
)
{
create
(
:namespace
)
}
context
'plan is nil'
do
let
(
:namespace_plan
)
{
nil
}
it
'returns no namespace'
do
expect
(
described_class
.
with_feature_available_in_plan
(
:group_project_templates
)).
to
be_empty
end
end
context
'plan is set'
do
let
(
:namespace_plan
)
{
:bronze_plan
}
it
'returns namespaces with plan'
do
create
(
:gitlab_subscription
,
:bronze
,
namespace:
namespace
)
create
(
:
gitlab_subscription
,
:free
,
namespace:
create
(
:namespace
)
)
create
(
:
namespace_with_plan
,
plan: :free_plan
)
expect
(
described_class
.
with_feature_available_in_plan
(
:audit_events
)).
to
eq
([
namespace
])
end
...
...
ee/spec/models/gitlab_subscription_spec.rb
View file @
33555bc7
...
...
@@ -121,8 +121,8 @@ describe GitlabSubscription do
end
it
'always returns 1 seat'
do
%w[bronze silver gold
]
.
each
do
|
plan
|
user_namespace
.
update!
(
plan:
plan
)
[
bronze_plan
,
silver_plan
,
gold_plan
].
each
do
|
plan
|
gitlab_subscription
.
update!
(
hosted_
plan:
plan
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
1
)
end
...
...
ee/spec/requests/api/groups_spec.rb
View file @
33555bc7
...
...
@@ -302,13 +302,11 @@ describe API::Groups do
subject
{
get
api
(
"/groups/
#{
group
.
id
}
/projects"
,
user
),
params:
{
with_security_reports:
true
}
}
context
'when security dashboard is enabled for a group'
do
let
(
:group
)
{
create
(
:group
,
plan: :gold_plan
)
}
# overriding group from parent context
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :gold_plan
)
}
# overriding group from parent context
before
do
stub_licensed_features
(
security_dashboard:
true
)
enable_namespace_license_check!
create
(
:gitlab_subscription
,
hosted_plan:
group
.
plan
,
namespace:
group
)
end
it
"returns only projects with security reports"
do
...
...
ee/spec/support/shared_examples/controllers/boards_actions_shared_examples.rb
View file @
33555bc7
# frozen_string_literal: true
RSpec
.
shared_examples
'pushes wip limits to frontend'
do
let
(
:plan_license
)
{
:free_plan
}
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
let
(
:global_license
)
{
create
(
:license
)
}
context
'self-hosted with correct license'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
global_licens
e
)
stub_licensed_features
(
wip_limits:
tru
e
)
end
context
'self-hosted with correct license'
do
let
(
:plan_license
)
{
:bronze_plan
}
it
'is enabled for all groups if the license is correct'
do
expect
(
subject
).
to
receive
(
:push_frontend_feature_flag
).
at_least
(
:once
)
...
...
@@ -27,7 +21,7 @@ RSpec.shared_examples 'pushes wip limits to frontend' do
context
'for group with correct plan'
do
before
do
namespace
=
parent
.
is_a?
(
Group
)
?
parent
:
parent
.
namespace
namespace
.
plan
=
create
(
:bronze_plan
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
create
(
:bronze_plan
)
)
end
it
'is enabled'
do
...
...
ee/spec/support/shared_examples/features/gold_trial_callout_shared_examples.rb
View file @
33555bc7
...
...
@@ -48,7 +48,8 @@ RSpec.shared_examples 'dashboard gold trial callout' do
end
it
'hides promotion callout if a gold plan is active'
,
:js
do
group
=
create
(
:group
,
name:
'gold group'
,
plan: :gold_plan
)
group
=
create
(
:group_with_plan
,
name:
'gold group'
,
plan: :gold_plan
)
group
.
update
(
plan:
group
.
gitlab_subscription
.
hosted_plan
)
group
.
add_owner
(
user
)
visit
page_path
...
...
ee/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
View file @
33555bc7
...
...
@@ -98,12 +98,10 @@ describe 'layouts/nav/sidebar/_group' do
end
describe
'security dashboard tab'
do
let
(
:group
)
{
create
(
:group
,
plan: :gold_plan
)
}
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :gold_plan
)
}
before
do
enable_namespace_license_check!
create
(
:gitlab_subscription
,
hosted_plan:
group
.
plan
,
namespace:
group
)
end
context
'when security dashboard feature is enabled'
do
...
...
@@ -192,7 +190,7 @@ describe 'layouts/nav/sidebar/_group' do
end
context
'when security dashboard feature is disabled'
do
let
(
:group
)
{
create
(
:group
,
plan: :bronze_plan
)
}
let
(
:group
)
{
create
(
:group
_with_plan
,
plan: :bronze_plan
)
}
it
'is not visible'
do
render
...
...
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