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
ec555fbe
Commit
ec555fbe
authored
Sep 04, 2017
by
Sean McGivern
Committed by
Bryce Johnson
Sep 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for issues#service_desk action
parent
1b3bb52a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
33 deletions
+76
-33
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+18
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-15
ee/app/controllers/ee/projects/issues_controller.rb
ee/app/controllers/ee/projects/issues_controller.rb
+4
-18
spec/ee/spec/controllers/projects/issues_controller_spec.rb~c187b69... Add specs for issues#service_desk action
...ec.rb~c187b69... Add specs for issues#service_desk action
+53
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
ec555fbe
...
...
@@ -10,6 +10,24 @@ module IssuableCollections
private
def
set_issues_index
@collection_type
=
"Issue"
@issues
=
issues_collection
@issues
=
@issues
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issues
,
@collection_type
)
if
@issues
.
out_of_range?
&&
@issues
.
total_pages
!=
0
return
redirect_to
url_for
(
params
.
merge
(
page:
@issues
.
total_pages
,
only_path:
true
))
end
if
params
[
:label_name
].
present?
@labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
@project
.
id
,
title:
params
[
:label_name
]).
execute
end
@users
=
[]
end
def
issues_collection
issues_finder
.
execute
.
preload
(
:project
,
:author
,
:assignees
,
:labels
,
:milestone
,
project: :namespace
)
end
...
...
app/controllers/projects/issues_controller.rb
View file @
ec555fbe
...
...
@@ -25,21 +25,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to
:html
def
index
@collection_type
=
"Issue"
@issues
=
issues_collection
@issues
=
@issues
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issues
,
@collection_type
)
if
@issues
.
out_of_range?
&&
@issues
.
total_pages
!=
0
return
redirect_to
url_for
(
params
.
merge
(
page:
@issues
.
total_pages
,
only_path:
true
))
end
if
params
[
:label_name
].
present?
@labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
@project
.
id
,
title:
params
[
:label_name
]).
execute
end
@users
=
[]
set_issues_index
if
params
[
:assignee_id
].
present?
assignee
=
User
.
find_by_id
(
params
[
:assignee_id
])
...
...
ee/app/controllers/ee/projects/issues_controller.rb
View file @
ec555fbe
...
...
@@ -10,21 +10,7 @@ module EE
end
def
service_desk
@collection_type
=
"Issue"
@issues
=
issues_collection
@issues
=
@issues
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issues
,
@collection_type
)
if
@issues
.
out_of_range?
&&
@issues
.
total_pages
!=
0
return
redirect_to
url_for
(
params
.
merge
(
page:
@issues
.
total_pages
,
only_path:
true
))
end
if
params
[
:label_name
].
present?
@labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
@project
.
id
,
title:
params
[
:label_name
]).
execute
end
@users
=
[]
set_issues_index
if
params
[
:assignee_id
].
present?
assignee
=
User
.
find_by_id
(
params
[
:assignee_id
])
...
...
@@ -54,7 +40,7 @@ module EE
params
=
super
params
.
reject!
{
|
key
|
key
==
'weight'
}
unless
project
.
feature_available?
(
:issue_weights
)
if
action_name
==
'service_desk'
if
service_desk?
params
.
reject!
{
|
key
|
key
==
'author_username'
||
key
==
'author_id'
}
params
[
:author_id
]
=
::
User
.
support_bot
end
...
...
@@ -62,8 +48,8 @@ module EE
params
end
def
se
lf
.
skip_issue_actions
super
+
[
:service_desk
]
def
se
rvice_desk?
action_name
==
'service_desk'
end
end
end
...
...
spec/ee/spec/controllers/projects/issues_controller_spec.rb~c187b69... Add specs for issues#service_desk action
0 → 100644
View file @
ec555fbe
require 'spec_helper'
describe Projects::IssuesController do
let(:project) { create(:project, :public) }
describe 'GET service_desk' do
def get_service_desk(extra_params = {})
get :service_desk, extra_params.merge(namespace_id: project.namespace, project_id: project)
end
context 'when Service Desk is available on the project' do
let(:support_bot) { User.support_bot }
let(:other_user) { create(:user) }
let!(:service_desk_issue_1) { create(:issue, project: project, author: support_bot) }
let!(:service_desk_issue_2) { create(:issue, project: project, author: support_bot, assignees: [other_user]) }
let!(:other_user_issue) { create(:issue, project: project, author: other_user) }
before do
stub_licensed_features(service_desk: true)
end
it 'adds an author filter for the support bot user' do
get_service_desk
expect(assigns(:issues)).to contain_exactly(service_desk_issue_1, service_desk_issue_2)
end
it 'does not allow any other author to be set' do
get_service_desk(author_username: other_user.username)
expect(assigns(:issues)).to contain_exactly(service_desk_issue_1, service_desk_issue_2)
end
it 'supports other filters' do
get_service_desk(assignee_username: other_user.username)
expect(assigns(:issues)).to contain_exactly(service_desk_issue_2)
end
end
context 'when Service Desk is not available on the project' do
before do
stub_licensed_features(service_desk: false)
end
it 'returns a 404' do
get_service_desk
expect(response).to have_http_status(404)
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