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
6c5d0064
Commit
6c5d0064
authored
Mar 23, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to read available add-ons on License.
parent
9310e6ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
app/models/license.rb
app/models/license.rb
+9
-0
spec/models/license_spec.rb
spec/models/license_spec.rb
+30
-0
No files found.
app/models/license.rb
View file @
6c5d0064
...
...
@@ -76,6 +76,15 @@ class License < ActiveRecord::Base
end
end
def
add_ons
return
{}
unless
self
.
license?
&&
self
.
restricted?
(
:add_ons
)
self
.
restrictions
[
:add_ons
]
end
def
add_on
(
code
)
add_ons
.
slice
(
code
).
presence
or
nil
end
private
def
reset_current
...
...
spec/models/license_spec.rb
View file @
6c5d0064
...
...
@@ -210,4 +210,34 @@ describe License do
end
end
end
describe
'reading add-ons'
do
context
"with add-ons"
do
before
do
gl_license
.
restrictions
=
{
add_ons:
{
support:
1
,
custom_domain:
2
}
}
end
it
'returns all available add-ons'
do
expect
(
license
.
add_ons
.
keys
).
to
include
(
'support'
,
'custom_domain'
)
end
it
'returns a single addon if it exists'
do
expect
(
license
.
add_on
(
'support'
)).
to
eq
({
'support'
=>
1
})
end
it
'returns Nil if add-on does not exists'
do
expect
(
license
.
add_on
(
'unknown'
)).
to
be_nil
end
end
context
"without add-ons"
do
it
'returns an empty Hash'
do
expect
(
license
.
add_ons
).
to
eq
({})
end
it
'returns nil when asking for a single add-on'
do
expect
(
license
.
add_on
(
'support'
)).
to
be_nil
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