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
7538ae81
Commit
7538ae81
authored
Oct 04, 2016
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSV format supported in Issues#index
parent
8800c0da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
0 deletions
+53
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-0
app/views/projects/issues/index.csv.ruby
app/views/projects/issues/index.csv.ruby
+19
-0
spec/features/issues/csv_spec.rb
spec/features/issues/csv_spec.rb
+24
-0
spec/support/csv_helpers.rb
spec/support/csv_helpers.rb
+9
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
7538ae81
...
...
@@ -51,6 +51,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
format
.
atom
{
render
layout:
false
}
format
.
csv
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"projects/issues/_issues"
),
...
...
app/views/projects/issues/index.csv.ruby
0 → 100644
View file @
7538ae81
columns
=
{
'Issue ID'
=>
'iid'
,
'Title'
=>
'title'
,
'State'
=>
'state'
,
'Description'
=>
'description'
,
'Author Id'
=>
'author_id'
,
'Assignee Id'
=>
'assignee_id'
,
'Due Date'
=>
'due_date'
,
'Created At'
=>
'created_at'
,
'Updated At'
=>
'updated_at'
}
CSV
.
generate
do
|
csv
|
csv
<<
columns
.
keys
@issues
.
pluck
(
*
columns
.
values
).
each
do
|
row
|
csv
<<
row
end
end
spec/features/issues/csv_spec.rb
0 → 100644
View file @
7538ae81
require
'spec_helper'
describe
'Issues csv'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
before
do
login_as
(
user
)
visit
namespace_project_issues_path
(
project
.
namespace
,
project
,
format: :csv
)
end
it
'downloads as a file'
do
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
include
(
'csv'
)
end
it
'includes title'
do
expect
(
csv
[
0
][
'Title'
]).
to
eq
issue
.
title
end
it
'includes description'
do
expect
(
csv
[
0
][
'Description'
]).
to
eq
issue
.
description
end
end
spec/support/csv_helpers.rb
0 → 100644
View file @
7538ae81
module
CsvHelpers
def
csv
CSV
.
parse
(
body
,
headers:
true
)
end
end
RSpec
.
configure
do
|
config
|
config
.
include
CsvHelpers
,
type: :feature
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