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
8e0c0a46
Commit
8e0c0a46
authored
Apr 05, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add service desk controller
parent
902f49e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
1 deletion
+72
-1
app/controllers/projects/service_desk_controller.rb
app/controllers/projects/service_desk_controller.rb
+25
-0
config/routes/project.rb
config/routes/project.rb
+4
-0
spec/controllers/projects/service_desk_controller_spec.rb
spec/controllers/projects/service_desk_controller_spec.rb
+42
-0
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
+1
-1
No files found.
app/controllers/projects/service_desk_controller.rb
0 → 100644
View file @
8e0c0a46
class
Projects::ServiceDeskController
<
Projects
::
ApplicationController
before_action
:authorize_admin_project!
,
only: :update
before_action
:authorize_read_project!
,
only: :show
def
show
json_response
end
def
update
Projects
::
UpdateService
.
new
(
project
,
current_user
,
{
service_desk_enabled:
params
[
:service_desk_enabled
]
}).
execute
json_response
end
private
def
json_response
respond_to
do
|
format
|
attributes
=
{
service_desk_address:
project
.
service_desk_address
,
service_desk_enabled:
project
.
service_desk_enabled
}
format
.
json
{
render
json:
attributes
.
to_json
,
status: :ok
}
end
end
end
config/routes/project.rb
View file @
8e0c0a46
...
...
@@ -155,6 +155,10 @@ constraints(ProjectUrlConstrainer.new) do
end
end
## EE-specific
get
'/service_desk'
=>
'service_desk#show'
,
as: :service_desk
put
'/service_desk'
=>
'service_desk#update'
,
as: :service_desk_refresh
resources
:protected_branches
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
,
:patch
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
do
scope
module: :protected_branches
do
resources
:merge_access_levels
,
only:
[
:destroy
]
...
...
spec/controllers/projects/service_desk_controller_spec.rb
0 → 100644
View file @
8e0c0a46
require
'spec_helper'
describe
Projects
::
ServiceDeskController
do
let
(
:project
)
{
create
(
:project_empty_repo
,
:private
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
)
{
true
}
end
describe
'GET service desk properties'
do
it
'returns service_desk JSON data'
do
project
.
update
(
service_desk_enabled:
true
)
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
format: :json
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
[
"service_desk_address"
]).
to
match
(
/\A[^@]+@[^@]+\z/
)
expect
(
body
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
response
.
status
).
to
eq
(
200
)
end
end
describe
'PUT service desk properties'
do
it
'toggles services desk incoming email'
do
project
.
update
(
service_desk_enabled:
true
)
old_address
=
project
.
service_desk_address
project
.
update
(
service_desk_enabled:
false
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
service_desk_enabled:
true
,
format: :json
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
[
"service_desk_address"
]).
to
be_present
expect
(
body
[
"service_desk_address"
]).
not_to
eq
(
old_address
)
expect
(
body
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
View file @
8e0c0a46
...
...
@@ -59,7 +59,7 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
end
it
'does not create an issue or send email'
do
expect
(
Notify
).
not_to
receive
(
:service_desk_thank_you_email
)
expect
(
Notify
).
not_to
receive
(
:service_desk_thank_you_email
)
expect
{
receiver
.
execute
rescue
nil
}.
not_to
change
{
Issue
.
count
}
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