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
556649ef
Commit
556649ef
authored
Mar 31, 2017
by
http://jneen.net/
Committed by
Felipe Artur
Apr 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose service_desk_enabled and refresh the key
... automatically when it goes from false to true
parent
03fb2a56
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/models/ee/project.rb
app/models/ee/project.rb
+12
-0
spec/models/ee/project_spec.rb
spec/models/ee/project_spec.rb
+29
-0
No files found.
app/controllers/projects_controller.rb
View file @
556649ef
...
...
@@ -349,6 +349,7 @@ class ProjectsController < Projects::ApplicationController
mirror_user_id
repository_size_limit
reset_approvals_on_push
service_desk_enabled
]
end
...
...
app/models/ee/project.rb
View file @
556649ef
...
...
@@ -14,6 +14,8 @@ module EE
delegate
:actual_shared_runners_minutes_limit
,
:shared_runners_minutes_used?
,
to: :namespace
before_validation
:refresh_service_desk_key
end
def
shared_runners_available?
...
...
@@ -23,5 +25,15 @@ module EE
def
shared_runners_minutes_limit_enabled?
!
public
?
&&
shared_runners_enabled?
&&
namespace
.
shared_runners_minutes_limit_enabled?
end
private
def
refresh_service_desk_key
return
unless
::
Gitlab
::
EE
::
ServiceDesk
.
enabled?
return
unless
self
.
service_desk_enabled?
if
service_desk_mail_key
.
blank?
||
service_desk_enabled_changed?
self
.
service_desk_mail_key
=
Devise
.
friendly_token
(
16
)
end
end
end
end
spec/models/ee/project_spec.rb
View file @
556649ef
...
...
@@ -115,4 +115,33 @@ describe Project, models: true do
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#regenerate_service_desk_key'
do
subject
{
create
(
:project
)
}
it
'leaves it blank by default'
do
expect
(
subject
.
service_desk_mail_key
).
to
be_blank
end
it
'updates when enabled'
do
subject
.
service_desk_enabled
=
true
subject
.
validate
expect
(
subject
.
service_desk_mail_key
).
not_to
be_blank
end
it
'changes when enabled'
do
subject
.
update!
(
service_desk_mail_key:
'12345'
)
subject
.
service_desk_enabled
=
true
expect
{
subject
.
validate
}.
to
change
{
subject
.
service_desk_mail_key
}
end
it
'ensures mail key is never nil when enabled'
do
subject
.
update!
(
service_desk_enabled:
true
)
expect
{
subject
.
update!
(
service_desk_mail_key:
nil
)
}
.
to
change
{
subject
.
service_desk_mail_key
}
expect
(
subject
.
service_desk_mail_key
).
not_to
be_blank
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