summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/concerns/user_status_tooltip.rb19
-rw-r--r--app/serializers/discussion_entity.rb1
-rw-r--r--app/serializers/merge_request_widget_entity.rb10
-rw-r--r--app/serializers/pipeline_serializer.rb9
-rw-r--r--app/serializers/test_case_entity.rb7
-rw-r--r--app/serializers/test_reports_comparer_entity.rb11
-rw-r--r--app/serializers/test_reports_comparer_serializer.rb3
-rw-r--r--app/serializers/test_suite_comparer_entity.rb14
-rw-r--r--app/serializers/user_entity.rb1
9 files changed, 72 insertions, 3 deletions
diff --git a/app/serializers/concerns/user_status_tooltip.rb b/app/serializers/concerns/user_status_tooltip.rb
new file mode 100644
index 00000000000..aa6e67e3351
--- /dev/null
+++ b/app/serializers/concerns/user_status_tooltip.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module UserStatusTooltip
+ extend ActiveSupport::Concern
+ include ActionView::Helpers::TagHelper
+ include ActionView::Context
+ include EmojiHelper
+ include UsersHelper
+
+ included do
+ expose :user_status_if_loaded, as: :status_tooltip_html
+
+ def user_status_if_loaded
+ return nil unless object.association(:status).loaded?
+
+ user_status(object)
+ end
+ end
+end
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb
index 6f95e6f9ca1..b8321037fa5 100644
--- a/app/serializers/discussion_entity.rb
+++ b/app/serializers/discussion_entity.rb
@@ -6,7 +6,6 @@ class DiscussionEntity < Grape::Entity
expose :id, :reply_id
expose :position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
- expose :original_position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
expose :line_code, if: -> (d, _) { d.diff_discussion? }
expose :expanded?, as: :expanded
expose :active?, as: :active, if: -> (d, _) { d.diff_discussion? }
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index 4fe04e4b206..f55d448235a 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -132,6 +132,10 @@ class MergeRequestWidgetEntity < IssuableEntity
can?(request.current_user, :create_note, merge_request)
end
+ expose :can_create_issue do |merge_request|
+ can?(current_user, :create_issue, merge_request.project)
+ end
+
expose :can_update do |merge_request|
can?(request.current_user, :update_merge_request, merge_request)
end
@@ -227,6 +231,12 @@ class MergeRequestWidgetEntity < IssuableEntity
end
end
+ expose :test_reports_path do |merge_request|
+ if merge_request.has_test_reports?
+ test_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
+ end
+ end
+
private
delegate :current_user, to: :request
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index 4a33160afa1..3205578b83e 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -11,10 +11,15 @@ class PipelineSerializer < BaseSerializer
:retryable_builds,
:cancelable_statuses,
:trigger_requests,
- :project,
:manual_actions,
:artifacts,
- { pending_builds: :project }
+ {
+ pending_builds: :project,
+ project: [:route, { namespace: :route }],
+ artifacts: {
+ project: [:route, { namespace: :route }]
+ }
+ }
])
end
diff --git a/app/serializers/test_case_entity.rb b/app/serializers/test_case_entity.rb
new file mode 100644
index 00000000000..5c1cbf37182
--- /dev/null
+++ b/app/serializers/test_case_entity.rb
@@ -0,0 +1,7 @@
+class TestCaseEntity < Grape::Entity
+ expose :status
+ expose :name
+ expose :execution_time
+ expose :system_output
+ expose :stack_trace
+end
diff --git a/app/serializers/test_reports_comparer_entity.rb b/app/serializers/test_reports_comparer_entity.rb
new file mode 100644
index 00000000000..b95d820d093
--- /dev/null
+++ b/app/serializers/test_reports_comparer_entity.rb
@@ -0,0 +1,11 @@
+class TestReportsComparerEntity < Grape::Entity
+ expose :total_status, as: :status
+
+ expose :summary do
+ expose :total_count, as: :total
+ expose :resolved_count, as: :resolved
+ expose :failed_count, as: :failed
+ end
+
+ expose :suite_comparers, as: :suites, using: TestSuiteComparerEntity
+end
diff --git a/app/serializers/test_reports_comparer_serializer.rb b/app/serializers/test_reports_comparer_serializer.rb
new file mode 100644
index 00000000000..a739858efb2
--- /dev/null
+++ b/app/serializers/test_reports_comparer_serializer.rb
@@ -0,0 +1,3 @@
+class TestReportsComparerSerializer < BaseSerializer
+ entity TestReportsComparerEntity
+end
diff --git a/app/serializers/test_suite_comparer_entity.rb b/app/serializers/test_suite_comparer_entity.rb
new file mode 100644
index 00000000000..a3965ba3930
--- /dev/null
+++ b/app/serializers/test_suite_comparer_entity.rb
@@ -0,0 +1,14 @@
+class TestSuiteComparerEntity < Grape::Entity
+ expose :name
+ expose :total_status, as: :status
+
+ expose :summary do
+ expose :total_count, as: :total
+ expose :resolved_count, as: :resolved
+ expose :failed_count, as: :failed
+ end
+
+ expose :new_failures, using: TestCaseEntity
+ expose :resolved_failures, using: TestCaseEntity
+ expose :existing_failures, using: TestCaseEntity
+end
diff --git a/app/serializers/user_entity.rb b/app/serializers/user_entity.rb
index 6236d66ff4a..656900bb8af 100644
--- a/app/serializers/user_entity.rb
+++ b/app/serializers/user_entity.rb
@@ -2,6 +2,7 @@
class UserEntity < API::Entities::UserBasic
include RequestAwareEntity
+ include UserStatusTooltip
expose :path do |user|
user_path(user)