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
b6f56547
Commit
b6f56547
authored
Jul 13, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper method for displaying the extend/reactivate trial button
parent
e7a075f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
ee/app/helpers/ee/trial_helper.rb
ee/app/helpers/ee/trial_helper.rb
+22
-0
ee/spec/helpers/ee/trial_helper_spec.rb
ee/spec/helpers/ee/trial_helper_spec.rb
+63
-0
No files found.
ee/app/helpers/ee/trial_helper.rb
View file @
b6f56547
...
...
@@ -52,6 +52,28 @@ module EE
namespace
&
.
errors
&
.
full_messages
&
.
to_sentence
&
.
presence
||
service_result
&
.
dig
(
:errors
)
&
.
presence
end
def
show_extend_reactivate_trial_button?
(
namespace
)
return
false
unless
::
Feature
.
enabled?
(
:allow_extend_reactivate_trial
,
namespace
,
default_enabled: :yaml
)
namespace
.
can_extend_trial?
||
namespace
.
can_reactivate_trial?
end
def
extend_reactivate_trial_button_data
(
namespace
)
action
=
if
namespace
.
can_extend_trial?
'extend'
elsif
namespace
.
can_reactivate_trial?
'reactivate'
else
nil
end
{
namespace_id:
namespace
.
id
,
plan_name:
namespace
.
actual_plan_name
.
titleize
,
action:
action
}
end
private
def
trial_group_namespaces
...
...
ee/spec/helpers/ee/trial_helper_spec.rb
View file @
b6f56547
...
...
@@ -180,4 +180,67 @@ RSpec.describe EE::TrialHelper do
end
end
end
describe
'#show_extend_reactivate_trial_button?'
do
let
(
:namespace
)
{
build
(
:namespace
)
}
subject
(
:show_extend_reactivate_trial_button
)
{
helper
.
show_extend_reactivate_trial_button?
(
namespace
)
}
context
'when feature flag is disabled'
do
before
do
allow
(
namespace
).
to
receive
(
:can_extend_trial?
).
and_return
(
true
)
allow
(
namespace
).
to
receive
(
:can_reactivate_trial?
).
and_return
(
true
)
stub_feature_flags
(
allow_extend_reactivate_trial:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when feature flag is enabled'
do
where
(
:can_extend_trial
,
:can_reactivate_trial
,
:result
)
do
false
|
false
|
false
true
|
false
|
true
false
|
true
|
true
true
|
true
|
true
end
with_them
do
before
do
stub_feature_flags
(
allow_extend_reactivate_trial:
true
)
allow
(
namespace
).
to
receive
(
:can_extend_trial?
).
and_return
(
can_extend_trial
)
allow
(
namespace
).
to
receive
(
:can_reactivate_trial?
).
and_return
(
can_reactivate_trial
)
end
it
{
is_expected
.
to
eq
(
result
)
}
end
end
end
describe
'#extend_reactivate_trial_button_data'
do
let
(
:namespace
)
{
build
(
:namespace
,
id:
1
)
}
subject
(
:extend_reactivate_trial_button_data
)
{
helper
.
extend_reactivate_trial_button_data
(
namespace
)
}
before
do
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
'ultimate'
)
end
context
'when trial can be extended'
do
before
do
allow
(
namespace
).
to
receive
(
:can_extend_trial?
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
({
namespace_id:
1
,
plan_name:
'Ultimate'
,
action:
'extend'
})
}
end
context
'when trial can be reactivated'
do
before
do
allow
(
namespace
).
to
receive
(
:can_reactivate_trial?
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
({
namespace_id:
1
,
plan_name:
'Ultimate'
,
action:
'reactivate'
})
}
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