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
4a1cc00c
Commit
4a1cc00c
authored
Jun 29, 2020
by
Brett Walker
Committed by
Arturo Herrero
Jul 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIra issue serializer and entity
to be used for MVC
parent
4ba5d833
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
259 additions
and
0 deletions
+259
-0
ee/app/serializers/integrations/jira/issue_entity.rb
ee/app/serializers/integrations/jira/issue_entity.rb
+73
-0
ee/app/serializers/integrations/jira/issue_serializer.rb
ee/app/serializers/integrations/jira/issue_serializer.rb
+9
-0
ee/spec/serializers/integrations/jira/issue_entity_spec.rb
ee/spec/serializers/integrations/jira/issue_entity_spec.rb
+128
-0
ee/spec/serializers/integrations/jira/issue_serializer_spec.rb
...ec/serializers/integrations/jira/issue_serializer_spec.rb
+49
-0
No files found.
ee/app/serializers/integrations/jira/issue_entity.rb
0 → 100644
View file @
4a1cc00c
# frozen_string_literal: true
module
Integrations
module
Jira
class
IssueEntity
<
Grape
::
Entity
expose
:project_id
do
|
_jira_issue
|
options
[
:project
].
id
end
expose
:title
do
|
jira_issue
|
jira_issue
.
summary
end
expose
:created_at
do
|
jira_issue
|
jira_issue
.
created
end
expose
:updated_at
do
|
jira_issue
|
jira_issue
.
updated
end
expose
:closed_at
do
|
jira_issue
|
jira_issue
.
resolutiondate
end
expose
:labels
do
|
jira_issue
|
jira_issue
.
labels
.
map
do
|
name
|
{
name:
name
,
color:
"#b728d9"
,
text_color:
"#FFFFFF"
}
end
end
expose
:author
do
|
jira_issue
|
{
id:
1
,
name:
jira_issue
.
creator
[
'displayName'
],
username:
jira_issue
.
creator
[
'name'
],
avatar_url:
'http://127.0.0.1:3000/uploads/-/system/user/avatar/1/avatar.png'
,
web_url:
'http://127.0.0.1:3000/root'
}
end
expose
:assignees
do
|
jira_issue
|
[
{
id:
1
,
name:
jira_issue
.
assignee
&
.
displayName
,
# username: jira_issue.assignee&.name,
avatar_url:
"http://127.0.0.1:3000/uploads/-/system/user/avatar/1/avatar.png"
,
web_url:
"http://127.0.0.1:3000/root"
}
]
end
expose
:weburl
do
|
jira_issue
|
"
#{
jira_issue
.
client
.
options
[
:site
]
}
projects/
#{
jira_issue
.
project
.
key
}
/issues/
#{
jira_issue
.
key
}
"
end
# TODO
# {
# references: {
# short: "#39",
# relative: jira_issue.key,
# full: "gitlab-org/gitlab-shell#39"
# }
# }
end
end
end
ee/app/serializers/integrations/jira/issue_serializer.rb
0 → 100644
View file @
4a1cc00c
# frozen_string_literal: true
module
Integrations
module
Jira
class
IssueSerializer
<
BaseSerializer
entity
::
Integrations
::
Jira
::
IssueEntity
end
end
end
ee/spec/serializers/integrations/jira/issue_entity_spec.rb
0 → 100644
View file @
4a1cc00c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Integrations
::
Jira
::
IssueEntity
do
# TODO
# let(:project) { create(:project) }
# let(:resource) { create(:issue, project: project) }
# let(:user) { create(:user) }
#
# let(:request) { double('request', current_user: user) }
#
# subject { described_class.new(resource, project: project, request: request).as_json }
#
# it 'has Issuable attributes' do
# expect(subject).to include(:id, :iid, :author_id, :description, :lock_version, :milestone_id,
# :title, :updated_by_id, :created_at, :updated_at, :milestone, :labels)
# end
#
# it 'has time estimation attributes' do
# expect(subject).to include(:time_estimate, :total_time_spent, :human_time_estimate, :human_total_time_spent)
# end
#
# context 'when issue got moved' do
# let(:public_project) { create(:project, :public) }
# let(:member) { create(:user) }
# let(:non_member) { create(:user) }
# let(:issue) { create(:issue, project: public_project) }
#
# before do
# project.add_developer(member)
# public_project.add_developer(member)
# Issues::MoveService.new(public_project, member).execute(issue, project)
# end
#
# context 'when user cannot read target project' do
# it 'does not return moved_to_id' do
# request = double('request', current_user: non_member)
#
# response = described_class.new(issue, request: request).as_json
#
# expect(response[:moved_to_id]).to be_nil
# end
# end
#
# context 'when user can read target project' do
# it 'returns moved moved_to_id' do
# request = double('request', current_user: member)
#
# response = described_class.new(issue, request: request).as_json
#
# expect(response[:moved_to_id]).to eq(issue.moved_to_id)
# end
# end
# end
#
# context 'when issue got duplicated' do
# let(:private_project) { create(:project, :private) }
# let(:member) { create(:user) }
# let(:issue) { create(:issue, project: project) }
# let(:new_issue) { create(:issue, project: private_project) }
#
# before do
# Issues::DuplicateService
# .new(project, member)
# .execute(issue, new_issue)
# end
#
# context 'when user cannot read new issue' do
# let(:non_member) { create(:user) }
#
# it 'does not return duplicated_to_id' do
# request = double('request', current_user: non_member)
#
# response = described_class.new(issue, request: request).as_json
#
# expect(response[:duplicated_to_id]).to be_nil
# end
# end
#
# context 'when user can read target project' do
# before do
# project.add_developer(member)
# private_project.add_developer(member)
# end
#
# it 'returns duplicated duplicated_to_id' do
# request = double('request', current_user: member)
#
# response = described_class.new(issue, request: request).as_json
#
# expect(response[:duplicated_to_id]).to eq(issue.duplicated_to_id)
# end
# end
# end
#
# context 'when issuable in active or archived project' do
# before do
# project.add_developer(user)
# end
#
# context 'when project is active' do
# it 'returns archived false' do
# expect(subject[:is_project_archived]).to eq(false)
# end
#
# it 'returns nil for archived project doc' do
# response = described_class.new(resource, request: request).as_json
#
# expect(response[:archived_project_docs_path]).to be nil
# end
# end
#
# context 'when project is archived' do
# before do
# project.update(archived: true)
# end
#
# it 'returns archived true' do
# expect(subject[:is_project_archived]).to eq(true)
# end
#
# it 'returns archived project doc' do
# expect(subject[:archived_project_docs_path]).to eq('/help/user/project/settings/index.md#archiving-a-project')
# end
# end
# end
end
ee/spec/serializers/integrations/jira/issue_serializer_spec.rb
0 → 100644
View file @
4a1cc00c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Integrations
::
Jira
::
IssueSerializer
do
# TODO
# let(:user) { create(:user) }
#
# let(:serializer) do
# described_class.new(user: user)
# end
#
# subject { serializer.represent(resource) }
#
# describe '#represent' do
# context 'when a single object is being serialized' do
# let(:resource) { create(:label) }
#
# it 'serializes the label object' do
# expect(subject[:id]).to eq resource.id
# end
# end
#
# context 'when multiple objects are being serialized' do
# let(:num_labels) { 2 }
# let(:resource) { create_list(:label, num_labels) }
#
# it 'serializes the array of labels' do
# expect(subject.size).to eq(num_labels)
# end
# end
# end
#
# describe '#represent_appearance' do
# context 'when represents only appearance' do
# let(:resource) { create(:label) }
#
# subject { serializer.represent_appearance(resource) }
#
# it 'serializes only attributes used for appearance' do
# expect(subject.keys).to eq([:id, :title, :color, :text_color])
# expect(subject[:id]).to eq(resource.id)
# expect(subject[:title]).to eq(resource.title)
# expect(subject[:color]).to eq(resource.color)
# expect(subject[:text_color]).to eq(resource.text_color)
# 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