Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/serializers/pipeline_entity.rb9
-rw-r--r--app/serializers/status_entity.rb2
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb15
-rw-r--r--spec/serializers/status_entity_spec.rb10
4 files changed, 21 insertions, 15 deletions
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index e071c03e20b..613a18e6357 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -4,7 +4,7 @@ class PipelineEntity < Grape::Entity
expose :id
expose :user, using: UserEntity
- expose :url do |pipeline|
+ expose :path do |pipeline|
namespace_project_pipeline_path(
pipeline.project.namespace,
pipeline.project,
@@ -12,7 +12,12 @@ class PipelineEntity < Grape::Entity
end
expose :details do
- expose :detailed_status, as: :status, using: StatusEntity
+ expose :status do |pipeline, options|
+ StatusEntity.represent(
+ pipeline.detailed_status(request.user),
+ options)
+ end
+
expose :duration
expose :finished_at
expose :stages, using: PipelineStageEntity
diff --git a/app/serializers/status_entity.rb b/app/serializers/status_entity.rb
index ae14dd57f61..261faa67527 100644
--- a/app/serializers/status_entity.rb
+++ b/app/serializers/status_entity.rb
@@ -1,7 +1,7 @@
class StatusEntity < Grape::Entity
include RequestAwareEntity
- expose :icon, :text, :label, :title
+ expose :icon, :text, :label
expose :has_details?, as: :has_details
expose :details_path
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index f6b7d1eb1dd..d85c6ae5ad6 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -1,15 +1,18 @@
require 'spec_helper'
describe PipelineSerializer do
+ let(:user) { create(:user) }
+ let(:pipeline) { create(:ci_empty_pipeline) }
+
let(:serializer) do
described_class.new(user: user)
end
- let(:pipelines) do
- create_list(:ci_pipeline, 2)
- end
-
- let(:user) { create(:user) }
+ describe '#represent' do
+ subject { serializer.represent(pipeline) }
- # TODO add some tests here.
+ it 'serializers the pipeline object' do
+ expect(subject.as_json).to include :id
+ end
+ end
end
diff --git a/spec/serializers/status_entity_spec.rb b/spec/serializers/status_entity_spec.rb
index 5afa1c25a42..c3da61321de 100644
--- a/spec/serializers/status_entity_spec.rb
+++ b/spec/serializers/status_entity_spec.rb
@@ -1,12 +1,10 @@
require 'spec_helper'
describe StatusEntity do
- let(:entity) do
- described_class.new(status)
- end
+ let(:entity) { described_class.new(status) }
- let(:status) do # TODO, add statuses factory
- Gitlab::Ci::Status::Success.new(double('object'))
+ let(:status) do
+ Gitlab::Ci::Status::Success.new(double('object'), double('user'))
end
before do
@@ -17,7 +15,7 @@ describe StatusEntity do
subject { entity.as_json }
it 'contains status details' do
- expect(subject).to include :text, :icon, :label, :title
+ expect(subject).to include :text, :icon, :label
expect(subject).to include :has_details
expect(subject).to include :details_path
end