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
2720e7d8
Commit
2720e7d8
authored
Sep 08, 2021
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repository#license returns nil when license_key unrecognized
parent
54293337
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
app/models/repository.rb
app/models/repository.rb
+6
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+6
-0
No files found.
app/models/repository.rb
View file @
2720e7d8
...
@@ -627,7 +627,12 @@ class Repository
...
@@ -627,7 +627,12 @@ class Repository
def
license
def
license
return
unless
license_key
return
unless
license_key
Licensee
::
License
.
new
(
license_key
)
licensee_object
=
Licensee
::
License
.
new
(
license_key
)
return
if
licensee_object
.
name
.
blank?
licensee_object
rescue
Licensee
::
InvalidLicense
end
end
memoize_method
:license
memoize_method
:license
...
...
spec/models/repository_spec.rb
View file @
2720e7d8
...
@@ -1308,6 +1308,12 @@ RSpec.describe Repository do
...
@@ -1308,6 +1308,12 @@ RSpec.describe Repository do
expect
(
repository
.
license
).
to
be_nil
expect
(
repository
.
license
).
to
be_nil
end
end
it
'returns nil when license_key is not recognized'
do
expect
(
repository
).
to
receive
(
:license_key
).
twice
.
and_return
(
'not-recognized'
)
expect
(
repository
.
license
).
to
be_nil
end
it
'returns other when the content is not recognizable'
do
it
'returns other when the content is not recognizable'
do
license
=
Licensee
::
License
.
new
(
'other'
)
license
=
Licensee
::
License
.
new
(
'other'
)
repository
.
create_file
(
user
,
'LICENSE'
,
'Gitlab B.V.'
,
repository
.
create_file
(
user
,
'LICENSE'
,
'Gitlab B.V.'
,
...
...
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