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
3afd7062
Commit
3afd7062
authored
Jul 19, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Methods can_{extend,reactivate}_trial? must rely on FF value
parent
555ab4f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
39 deletions
+89
-39
ee/app/models/ee/namespace.rb
ee/app/models/ee/namespace.rb
+4
-0
ee/spec/helpers/ee/trial_helper_spec.rb
ee/spec/helpers/ee/trial_helper_spec.rb
+23
-5
ee/spec/models/ee/namespace_spec.rb
ee/spec/models/ee/namespace_spec.rb
+62
-34
No files found.
ee/app/models/ee/namespace.rb
View file @
3afd7062
...
...
@@ -303,10 +303,14 @@ module EE
end
def
can_extend_trial?
return
false
unless
::
Feature
.
enabled?
(
:allow_extend_reactivate_trial
,
default_enabled: :yaml
)
trial_active?
&&
!
trial_extended_or_reactivated?
end
def
can_reactivate_trial?
return
false
unless
::
Feature
.
enabled?
(
:allow_extend_reactivate_trial
,
default_enabled: :yaml
)
!
trial_active?
&&
!
never_had_trial?
&&
!
trial_extended_or_reactivated?
&&
free_plan?
end
...
...
ee/spec/helpers/ee/trial_helper_spec.rb
View file @
3afd7062
...
...
@@ -228,14 +228,32 @@ RSpec.describe EE::TrialHelper do
end
context
'when feature flag is disabled'
do
it
{
is_expected
.
to
eq
({
namespace_id:
1
,
plan_name:
'Ultimate'
,
action:
nil
})}
end
context
'when feature flag is enabled'
do
before
do
stub_feature_flags
(
allow_extend_reactivate_trial:
true
)
stub_feature_flags
(
allow_extend_reactivate_trial:
false
)
end
context
'when trial can be extended'
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
true
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
false
)
end
it
{
is_expected
.
to
eq
({
namespace_id:
1
,
plan_name:
'Ultimate'
,
action:
nil
})}
end
context
'when trial can be reactivated'
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:never_had_trial?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:free_plan?
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
({
namespace_id:
1
,
plan_name:
'Ultimate'
,
action:
nil
})
}
end
end
context
'when feature flag is enabled'
do
context
'when trial can be extended'
do
before
do
allow
(
namespace
).
to
receive
(
:can_extend_trial?
).
and_return
(
true
)
...
...
ee/spec/models/ee/namespace_spec.rb
View file @
3afd7062
...
...
@@ -1232,54 +1232,82 @@ RSpec.describe Namespace do
describe
'#can_extend_trial?'
do
subject
{
namespace
.
can_extend_trial?
}
where
(
:trial_active
,
:trial_extended_or_reactivated
,
:can_extend_trial
)
do
false
|
false
|
false
false
|
true
|
false
true
|
false
|
true
true
|
true
|
false
context
'feature flag is disabled'
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
true
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
false
)
stub_feature_flags
(
allow_extend_reactivate_trial:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
with_them
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
trial_active
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
trial_extended_or_reactivated
)
context
'when feature flag is enabled'
do
where
(
:trial_active
,
:trial_extended_or_reactivated
,
:can_extend_trial
)
do
false
|
false
|
false
false
|
true
|
false
true
|
false
|
true
true
|
true
|
false
end
it
{
is_expected
.
to
be
can_extend_trial
}
with_them
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
trial_active
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
trial_extended_or_reactivated
)
end
it
{
is_expected
.
to
be
can_extend_trial
}
end
end
end
describe
'#can_reactivate_trial?'
do
subject
{
namespace
.
can_reactivate_trial?
}
where
(
:trial_active
,
:never_had_trial
,
:trial_extended_or_reactivated
,
:free_plan
,
:can_reactivate_trial
)
do
false
|
false
|
false
|
false
|
false
false
|
false
|
false
|
true
|
true
false
|
false
|
true
|
false
|
false
false
|
false
|
true
|
true
|
false
false
|
true
|
false
|
false
|
false
false
|
true
|
false
|
true
|
false
false
|
true
|
true
|
false
|
false
false
|
true
|
true
|
true
|
false
true
|
false
|
false
|
false
|
false
true
|
false
|
false
|
true
|
false
true
|
false
|
true
|
false
|
false
true
|
false
|
true
|
true
|
false
true
|
true
|
false
|
false
|
false
true
|
true
|
false
|
true
|
false
true
|
true
|
true
|
false
|
false
true
|
true
|
true
|
true
|
false
context
'when feature flag is disabled'
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:never_had_trial?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
false
)
allow
(
namespace
).
to
receive
(
:free_plan?
).
and_return
(
true
)
stub_feature_flags
(
allow_extend_reactivate_trial:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
with_them
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
trial_active
)
allow
(
namespace
).
to
receive
(
:never_had_trial?
).
and_return
(
never_had_trial
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
trial_extended_or_reactivated
)
allow
(
namespace
).
to
receive
(
:free_plan?
).
and_return
(
free_plan
)
context
'when feature flag is enabled'
do
where
(
:trial_active
,
:never_had_trial
,
:trial_extended_or_reactivated
,
:free_plan
,
:can_reactivate_trial
)
do
false
|
false
|
false
|
false
|
false
false
|
false
|
false
|
true
|
true
false
|
false
|
true
|
false
|
false
false
|
false
|
true
|
true
|
false
false
|
true
|
false
|
false
|
false
false
|
true
|
false
|
true
|
false
false
|
true
|
true
|
false
|
false
false
|
true
|
true
|
true
|
false
true
|
false
|
false
|
false
|
false
true
|
false
|
false
|
true
|
false
true
|
false
|
true
|
false
|
false
true
|
false
|
true
|
true
|
false
true
|
true
|
false
|
false
|
false
true
|
true
|
false
|
true
|
false
true
|
true
|
true
|
false
|
false
true
|
true
|
true
|
true
|
false
end
it
{
is_expected
.
to
be
can_reactivate_trial
}
with_them
do
before
do
allow
(
namespace
).
to
receive
(
:trial_active?
).
and_return
(
trial_active
)
allow
(
namespace
).
to
receive
(
:never_had_trial?
).
and_return
(
never_had_trial
)
allow
(
namespace
).
to
receive
(
:trial_extended_or_reactivated?
).
and_return
(
trial_extended_or_reactivated
)
allow
(
namespace
).
to
receive
(
:free_plan?
).
and_return
(
free_plan
)
end
it
{
is_expected
.
to
be
can_reactivate_trial
}
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