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
a570ea9e
Commit
a570ea9e
authored
Jul 06, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add addon_data method for presenting addon data properties
parent
a86108e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
9 deletions
+36
-9
ee/app/helpers/subscriptions_helper.rb
ee/app/helpers/subscriptions_helper.rb
+18
-8
ee/app/views/subscriptions/buy_minutes.html.haml
ee/app/views/subscriptions/buy_minutes.html.haml
+1
-1
ee/spec/helpers/subscriptions_helper_spec.rb
ee/spec/helpers/subscriptions_helper_spec.rb
+17
-0
No files found.
ee/app/helpers/subscriptions_helper.rb
View file @
a570ea9e
...
...
@@ -16,6 +16,14 @@ module SubscriptionsHelper
}
end
def
addon_data
(
group
)
{
group_data:
[
present_group
(
group
)].
to_json
,
namespace_id:
params
[
:namespace_id
],
source:
params
[
:source
]
}
end
def
plan_title
strong_memoize
(
:plan_title
)
do
plan
=
subscription_available_plans
.
find
{
|
plan
|
plan
[
:id
]
==
params
[
:plan_id
]
}
...
...
@@ -45,13 +53,15 @@ module SubscriptionsHelper
end
def
present_groups
(
groups
)
groups
.
map
do
|
namespace
|
{
id:
namespace
.
id
,
name:
namespace
.
name
,
users:
namespace
.
member_count
,
guests:
namespace
.
guest_count
}
end
groups
.
map
{
|
namespace
|
present_group
(
namespace
)
}
end
def
present_group
(
namespace
)
{
id:
namespace
.
id
,
name:
namespace
.
name
,
users:
namespace
.
member_count
,
guests:
namespace
.
guest_count
}
end
end
ee/app/views/subscriptions/buy_minutes.html.haml
View file @
a570ea9e
-
page_title
_
(
'Buy CI Minutes'
)
#js-buy-minutes
{
data:
subscription_data
(
@eligible_groups
)
}
#js-buy-minutes
{
data:
addon_data
(
@group
)
}
ee/spec/helpers/subscriptions_helper_spec.rb
View file @
a570ea9e
...
...
@@ -132,4 +132,21 @@ RSpec.describe SubscriptionsHelper do
it
{
is_expected
.
to
eq
(
nil
)
}
end
end
describe
'#addon_data'
do
subject
(
:addon_data
)
{
helper
.
addon_data
(
group
)
}
let_it_be
(
:user
)
{
create
(
:user
,
name:
'First Last'
)
}
let_it_be
(
:group
)
{
create
(
:group
,
name:
'My Namespace'
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:params
).
and_return
({
namespace_id:
group
.
id
.
to_s
,
source:
'some_source'
})
group
.
add_owner
(
user
)
end
it
{
is_expected
.
to
include
(
namespace_id:
group
.
id
.
to_s
)
}
it
{
is_expected
.
to
include
(
source:
'some_source'
)
}
it
{
is_expected
.
to
include
(
group_data:
%Q{[{"id":
#{
group
.
id
}
,"name":"My Namespace","users":1,"guests":0}]}
)
}
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