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:
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/board_serializer_spec.rb20
-rw-r--r--spec/serializers/board_simple_entity_spec.rb16
-rw-r--r--spec/serializers/build_trace_entity_spec.rb7
-rw-r--r--spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb33
-rw-r--r--spec/serializers/deployment_entity_spec.rb72
-rw-r--r--spec/serializers/environment_status_entity_spec.rb35
-rw-r--r--spec/serializers/group_access_token_entity_spec.rb4
-rw-r--r--spec/serializers/import/github_org_entity_spec.rb25
-rw-r--r--spec/serializers/import/github_org_serializer_spec.rb47
-rw-r--r--spec/serializers/issue_entity_spec.rb2
-rw-r--r--spec/serializers/merge_request_poll_widget_entity_spec.rb18
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb74
-rw-r--r--spec/serializers/project_access_token_entity_spec.rb4
13 files changed, 195 insertions, 162 deletions
diff --git a/spec/serializers/board_serializer_spec.rb b/spec/serializers/board_serializer_spec.rb
deleted file mode 100644
index 9e6d5a93d53..00000000000
--- a/spec/serializers/board_serializer_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe BoardSerializer do
- let(:resource) { create(:board) }
- let(:json_entity) do
- described_class.new
- .represent(resource, serializer: serializer)
- .with_indifferent_access
- end
-
- context 'serialization' do
- let(:serializer) { 'board' }
-
- it 'matches issue_sidebar json schema' do
- expect(json_entity).to match_schema('board')
- end
- end
-end
diff --git a/spec/serializers/board_simple_entity_spec.rb b/spec/serializers/board_simple_entity_spec.rb
deleted file mode 100644
index c5ab9833adf..00000000000
--- a/spec/serializers/board_simple_entity_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe BoardSimpleEntity do
- let_it_be(:project) { create(:project) }
- let_it_be(:board) { create(:board, project: project) }
-
- subject { described_class.new(board).as_json }
-
- describe '#name' do
- it 'has `name` attribute' do
- is_expected.to include(:name)
- end
- end
-end
diff --git a/spec/serializers/build_trace_entity_spec.rb b/spec/serializers/build_trace_entity_spec.rb
index 82bd56caaac..f3d1d0a21a8 100644
--- a/spec/serializers/build_trace_entity_spec.rb
+++ b/spec/serializers/build_trace_entity_spec.rb
@@ -38,8 +38,9 @@ RSpec.describe BuildTraceEntity do
end
it 'includes the trace content in json' do
- expect(subject[:lines]).to eq([
- { offset: 0, content: [{ text: 'the-trace' }] }
- ])
+ expect(subject[:lines]).to eq(
+ [
+ { offset: 0, content: [{ text: 'the-trace' }] }
+ ])
end
end
diff --git a/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb b/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb
index ddeeb367afe..6fe1376b890 100644
--- a/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb
+++ b/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb
@@ -18,22 +18,23 @@ RSpec.describe Ci::DailyBuildGroupReportResultSerializer do
let(:json) { Gitlab::Json.parse(serializer.to_json) }
it 'returns an array of group results' do
- expect(json).to eq([
- {
- 'group_name' => 'rspec',
- 'data' => [
- { 'date' => '2020-05-20', 'coverage' => 79.1 },
- { 'date' => '2020-05-19', 'coverage' => 77.1 }
- ]
- },
- {
- 'group_name' => 'karma',
- 'data' => [
- { 'date' => '2020-05-20', 'coverage' => 90.1 },
- { 'date' => '2020-05-19', 'coverage' => 89.1 }
- ]
- }
- ])
+ expect(json).to eq(
+ [
+ {
+ 'group_name' => 'rspec',
+ 'data' => [
+ { 'date' => '2020-05-20', 'coverage' => 79.1 },
+ { 'date' => '2020-05-19', 'coverage' => 77.1 }
+ ]
+ },
+ {
+ 'group_name' => 'karma',
+ 'data' => [
+ { 'date' => '2020-05-20', 'coverage' => 90.1 },
+ { 'date' => '2020-05-19', 'coverage' => 89.1 }
+ ]
+ }
+ ])
end
end
end
diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb
index 433ce344680..0746e68d7c5 100644
--- a/spec/serializers/deployment_entity_spec.rb
+++ b/spec/serializers/deployment_entity_spec.rb
@@ -3,56 +3,47 @@
require 'spec_helper'
RSpec.describe DeploymentEntity do
- let(:user) { developer }
- let(:developer) { create(:user) }
- let(:reporter) { create(:user) }
- let(:project) { create(:project, :repository) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:reporter) { create(:user) }
+ let_it_be(:user) { developer }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:environment) { create(:environment, project: project) }
+ let_it_be_with_reload(:pipeline) { create(:ci_pipeline, project: project, user: user) }
+ let_it_be_with_reload(:build) { create(:ci_build, :manual, :environment_with_deployment_tier, pipeline: pipeline) }
+
+ let_it_be_with_refind(:deployment) { create(:deployment, deployable: build, environment: environment) }
+
let(:request) { double('request') }
- let(:deployment) { create(:deployment, deployable: build, project: project) }
- let(:build) { create(:ci_build, :manual, :environment_with_deployment_tier, pipeline: pipeline) }
- let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:entity) { described_class.new(deployment, request: request) }
subject { entity.as_json }
- before do
+ before_all do
project.add_developer(developer)
project.add_reporter(reporter)
+ end
+
+ before do
allow(request).to receive(:current_user).and_return(user)
allow(request).to receive(:project).and_return(project)
end
- it 'exposes internal deployment id' do
+ it 'exposes fields', :aggregate_failures do
expect(subject).to include(:iid)
- end
-
- it 'exposes nested information about branch' do
expect(subject[:ref][:name]).to eq 'master'
- end
-
- it 'exposes status' do
expect(subject).to include(:status)
- end
-
- it 'exposes creation date' do
expect(subject).to include(:created_at)
- end
-
- it 'exposes deployed_at' do
expect(subject).to include(:deployed_at)
- end
-
- it 'exposes last? as is_last' do
expect(subject).to include(:is_last)
- end
-
- it 'exposes deployment tier in yaml' do
expect(subject).to include(:tier_in_yaml)
end
context 'when deployable is nil' do
let(:entity) { described_class.new(deployment, request: request, deployment_details: false) }
- let(:deployment) { create(:deployment, deployable: nil, project: project) }
+
+ before do
+ deployment.update!(deployable: nil)
+ end
it 'does not expose deployable entry' do
expect(subject).not_to include(:deployable)
@@ -60,19 +51,19 @@ RSpec.describe DeploymentEntity do
end
context 'when the pipeline has another manual action' do
- let!(:other_build) do
+ let_it_be(:other_build) do
create(:ci_build, :manual, name: 'another deploy', pipeline: pipeline, environment: build.environment)
end
- let!(:other_deployment) { create(:deployment, deployable: build) }
+ let_it_be(:other_deployment) { create(:deployment, deployable: build, environment: environment) }
it 'returns another manual action' do
- expect(subject[:manual_actions].count).to eq(2)
- expect(subject[:manual_actions].pluck(:name)).to match_array(['test', 'another deploy'])
+ expect(subject[:manual_actions].count).to eq(1)
+ expect(subject[:manual_actions].pluck(:name)).to match_array(['another deploy'])
end
context 'when user is a reporter' do
- let(:user) { reporter }
+ let_it_be(:user) { reporter }
it 'returns another manual action' do
expect(subject[:manual_actions]).not_to be_present
@@ -91,14 +82,15 @@ RSpec.describe DeploymentEntity do
end
describe 'scheduled_actions' do
- let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
- let(:deployment) { create(:deployment, deployable: build) }
+
+ before do
+ deployment.update!(deployable: build)
+ end
context 'when the same pipeline has a scheduled action' do
let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other build') }
- let!(:other_deployment) { create(:deployment, deployable: other_build) }
+ let!(:other_deployment) { create(:deployment, deployable: other_build, environment: environment) }
it 'returns other scheduled actions' do
expect(subject[:scheduled_actions][0][:name]).to eq 'other build'
@@ -123,7 +115,9 @@ RSpec.describe DeploymentEntity do
end
describe 'playable_build' do
- let_it_be(:project) { create(:project, :repository) }
+ before do
+ deployment.update!(deployable: build)
+ end
context 'when the deployment has a playable deployable' do
context 'when this build is ready to be played' do
@@ -144,7 +138,7 @@ RSpec.describe DeploymentEntity do
end
context 'when the deployment does not have a playable deployable' do
- let(:build) { create(:ci_build) }
+ let(:build) { create(:ci_build, pipeline: pipeline) }
it 'is not exposed' do
expect(subject[:playable_build]).to be_nil
diff --git a/spec/serializers/environment_status_entity_spec.rb b/spec/serializers/environment_status_entity_spec.rb
index 77ef06f90c2..2ee4e8ade8f 100644
--- a/spec/serializers/environment_status_entity_spec.rb
+++ b/spec/serializers/environment_status_entity_spec.rb
@@ -3,21 +3,26 @@
require 'spec_helper'
RSpec.describe EnvironmentStatusEntity do
- let(:user) { create(:user) }
+ let_it_be(:non_member) { create(:user) }
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:deployment) { create(:deployment, :succeed, :review_app) }
+ let_it_be(:merge_request) { create(:merge_request, :deployed_review_app, deployment: deployment) }
+ let_it_be(:environment) { deployment.environment }
+ let_it_be(:project) { deployment.project }
+
+ let(:user) { non_member }
let(:request) { double('request', project: project) }
-
- let(:deployment) { create(:deployment, :succeed, :review_app) }
- let(:environment) { deployment.environment }
- let(:project) { deployment.project }
- let(:merge_request) { create(:merge_request, :deployed_review_app, deployment: deployment) }
-
let(:environment_status) { EnvironmentStatus.new(project, environment, merge_request, merge_request.diff_head_sha) }
- let(:entity) { described_class.new(environment_status, request: request) }
+ let(:entity) { described_class.new(environment_status, request: request) }
subject { entity.as_json }
- before do
+ before_all do
+ project.add_maintainer(maintainer)
deployment.update!(sha: merge_request.diff_head_sha)
+ end
+
+ before do
allow(request).to receive(:current_user).and_return(user)
end
@@ -37,14 +42,13 @@ RSpec.describe EnvironmentStatusEntity do
it { is_expected.not_to include(:metrics_monitoring_url) }
context 'when the user is project maintainer' do
- before do
- project.add_maintainer(user)
- end
+ let(:user) { maintainer }
it { is_expected.to include(:stop_url) }
end
context 'when deployment has metrics' do
+ let(:user) { maintainer }
let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true, configured?: true) }
let(:simple_metrics) do
@@ -56,7 +60,6 @@ RSpec.describe EnvironmentStatusEntity do
end
before do
- project.add_maintainer(user)
allow(deployment).to receive(:prometheus_adapter).and_return(prometheus_adapter)
allow(entity).to receive(:deployment).and_return(deployment)
@@ -69,8 +72,6 @@ RSpec.describe EnvironmentStatusEntity do
end
context 'when deployment succeeded' do
- let(:deployment) { create(:deployment, :succeed, :review_app) }
-
it 'returns metrics url' do
expect(subject[:metrics_url])
.to eq("/#{project.full_path}/-/environments/#{environment.id}/deployments/#{deployment.iid}/metrics")
@@ -78,7 +79,9 @@ RSpec.describe EnvironmentStatusEntity do
end
context 'when deployment is running' do
- let(:deployment) { create(:deployment, :running, :review_app) }
+ before do
+ deployment.update!(status: :running)
+ end
it 'does not return metrics url' do
expect(subject[:metrics_url]).to be_nil
diff --git a/spec/serializers/group_access_token_entity_spec.rb b/spec/serializers/group_access_token_entity_spec.rb
index 05609dc3c7a..586eb0a8588 100644
--- a/spec/serializers/group_access_token_entity_spec.rb
+++ b/spec/serializers/group_access_token_entity_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe GroupAccessTokenEntity do
expected_revoke_path = Gitlab::Routing.url_helpers
.revoke_group_settings_access_token_path(
{ id: token,
- group_id: group.path })
+ group_id: group.full_path })
expect(json).to(
include(
@@ -39,7 +39,7 @@ RSpec.describe GroupAccessTokenEntity do
expected_revoke_path = Gitlab::Routing.url_helpers
.revoke_group_settings_access_token_path(
{ id: token,
- group_id: group.path })
+ group_id: group.full_path })
expect(json).to(
include(
diff --git a/spec/serializers/import/github_org_entity_spec.rb b/spec/serializers/import/github_org_entity_spec.rb
new file mode 100644
index 00000000000..46fceb8ac60
--- /dev/null
+++ b/spec/serializers/import/github_org_entity_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Import::GithubOrgEntity do
+ let(:org_data) do
+ {
+ 'id' => 12345,
+ 'login' => 'org-name',
+ 'url' => 'https://api.github.com/orgs/org-name',
+ 'avatar_url' => 'https://avatars.githubusercontent.com/u/12345?v=4',
+ 'node_id' => 'O_teStT',
+ 'description' => ''
+ }
+ end
+
+ subject { described_class.new(org_data).as_json }
+
+ it 'exposes correct attributes' do
+ expect(subject.keys).to contain_exactly(
+ :description,
+ :name
+ )
+ end
+end
diff --git a/spec/serializers/import/github_org_serializer_spec.rb b/spec/serializers/import/github_org_serializer_spec.rb
new file mode 100644
index 00000000000..4206914cd6e
--- /dev/null
+++ b/spec/serializers/import/github_org_serializer_spec.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Import::GithubOrgSerializer do
+ it 'represents GithubOrgEntity entities' do
+ expect(described_class.entity_class).to eq(Import::GithubOrgEntity)
+ end
+
+ describe '#represent' do
+ let(:org_data) do
+ {
+ id: 123456,
+ login: 'org-name',
+ node_id: 'O_teStT',
+ url: 'https://api.github.com/orgs/org-name',
+ repos_url: 'https://api.github.com/orgs/org-name/repos',
+ events_url: 'https://api.github.com/orgs/org-name/events',
+ hooks_url: 'https://api.github.com/orgs/org-name/hooks',
+ issues_url: 'https://api.github.com/orgs/org-name/issues',
+ members_url: 'https://api.github.com/orgs/org-name/members{/member}',
+ public_members_url: 'https://api.github.com/orgs/org-name/public_members{/member}',
+ avatar_url: 'avatar_url',
+ description: 'description'
+ }
+ end
+
+ subject { described_class.new.represent(resource) }
+
+ context 'when a single object is being serialized' do
+ let(:resource) { org_data }
+
+ it 'serializes organization object' do
+ expect(subject).to eq({ name: 'org-name', description: 'description' })
+ end
+ end
+
+ context 'when multiple objects are being serialized' do
+ let(:count) { 3 }
+ let(:resource) { Array.new(count, org_data) }
+
+ it 'serializes array of organizations' do
+ expect(subject).to all(eq({ name: 'org-name', description: 'description' }))
+ end
+ end
+ end
+end
diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb
index 9335ca61b7d..25e9e8c17e2 100644
--- a/spec/serializers/issue_entity_spec.rb
+++ b/spec/serializers/issue_entity_spec.rb
@@ -150,4 +150,6 @@ RSpec.describe IssueEntity do
end
end
end
+
+ it_behaves_like 'issuable entity current_user properties'
end
diff --git a/spec/serializers/merge_request_poll_widget_entity_spec.rb b/spec/serializers/merge_request_poll_widget_entity_spec.rb
index 90a82d16e38..59ffba0e7a9 100644
--- a/spec/serializers/merge_request_poll_widget_entity_spec.rb
+++ b/spec/serializers/merge_request_poll_widget_entity_spec.rb
@@ -152,17 +152,19 @@ RSpec.describe MergeRequestPollWidgetEntity do
describe '#builds_with_coverage' do
it 'serializes the builds with coverage' do
- allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return([
- double(name: 'rspec', coverage: 91.5),
- double(name: 'jest', coverage: 94.1)
- ])
+ allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return(
+ [
+ double(name: 'rspec', coverage: 91.5),
+ double(name: 'jest', coverage: 94.1)
+ ])
result = subject[:builds_with_coverage]
- expect(result).to eq([
- { name: 'rspec', coverage: 91.5 },
- { name: 'jest', coverage: 94.1 }
- ])
+ expect(result).to eq(
+ [
+ { name: 'rspec', coverage: 91.5 },
+ { name: 'jest', coverage: 94.1 }
+ ])
end
end
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index f5398013a70..4d9bdc4bb17 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe PipelineSerializer do
end
context 'when a single object is being serialized' do
- let(:resource) { create(:ci_empty_pipeline, project: project) }
+ let(:resource) { build_stubbed(:ci_empty_pipeline, project: project) }
it 'serializers the pipeline object' do
expect(subject[:id]).to eq resource.id
@@ -27,10 +27,11 @@ RSpec.describe PipelineSerializer do
end
context 'when multiple objects are being serialized' do
- let(:resource) { create_list(:ci_pipeline, 2, project: project) }
+ let(:resource) { Array.new(2) { build_stubbed(:ci_pipeline, project: project) } }
it 'serializers the array of pipelines' do
expect(subject).not_to be_empty
+ expect(subject.size).to eq(2)
end
end
end
@@ -41,8 +42,7 @@ RSpec.describe PipelineSerializer do
let(:query) { {} }
let(:serializer) do
- described_class.new(current_user: user)
- .with_pagination(request, response)
+ described_class.new(current_user: user, project: project).with_pagination(request, response)
end
it 'created a paginated serializer' do
@@ -67,7 +67,7 @@ RSpec.describe PipelineSerializer do
context 'when a single pipeline object is present in relation' do
before do
- create(:ci_empty_pipeline)
+ create(:ci_empty_pipeline, project: project)
end
it 'serializes pipeline relation' do
@@ -77,7 +77,7 @@ RSpec.describe PipelineSerializer do
context 'when a multiple pipeline objects are being serialized' do
before do
- create_list(:ci_empty_pipeline, 3)
+ create_list(:ci_empty_pipeline, 3, project: project)
end
it 'serializes appropriate number of objects' do
@@ -100,28 +100,28 @@ RSpec.describe PipelineSerializer do
let!(:merge_request_1) do
create(:merge_request,
- :with_detached_merge_request_pipeline,
- target_project: project,
- target_branch: 'master',
- source_project: project,
- source_branch: 'feature')
+ :with_detached_merge_request_pipeline,
+ target_project: project,
+ target_branch: 'master',
+ source_project: project,
+ source_branch: 'feature')
end
let!(:merge_request_2) do
create(:merge_request,
- :with_detached_merge_request_pipeline,
- target_project: project,
- target_branch: 'master',
- source_project: project,
- source_branch: '2-mb-file')
+ :with_detached_merge_request_pipeline,
+ target_project: project,
+ target_branch: 'master',
+ source_project: project,
+ source_branch: '2-mb-file')
end
- before do
+ before_all do
project.add_developer(user)
end
it 'includes merge requests information' do
- expect(subject.all? { |entry| entry[:merge_request].present? }).to be_truthy
+ expect(subject).to be_all { |entry| entry[:merge_request].present? }
end
it 'preloads related merge requests' do
@@ -138,7 +138,8 @@ RSpec.describe PipelineSerializer do
let(:resource) { Ci::Pipeline.all }
- before do
+ # Create pipelines only once and change their attributes if needed.
+ before_all do
# Since RequestStore.active? is true we have to allow the
# gitaly calls in this block
# Issue: https://gitlab.com/gitlab-org/gitlab-foss/issues/37772
@@ -151,8 +152,6 @@ RSpec.describe PipelineSerializer do
end
context 'with the same ref' do
- let(:ref) { 'feature' }
-
it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject }
expected_queries = Gitlab.ee? ? 33 : 30
@@ -163,10 +162,11 @@ RSpec.describe PipelineSerializer do
end
context 'with different refs' do
- def ref
- @sequence ||= 0
- @sequence += 1
- "feature-#{@sequence}"
+ before do
+ # rubocop:disable Rails/SkipsModelValidations
+ Ci::Pipeline.update_all(%(ref = 'feature-' || id))
+ Ci::Build.update_all(%(ref = 'feature-' || stage_id))
+ # rubocop:enable Rails/SkipsModelValidations
end
it 'verifies number of queries', :request_store do
@@ -184,8 +184,6 @@ RSpec.describe PipelineSerializer do
end
context 'with triggered pipelines' do
- let(:ref) { 'feature' }
-
before do
pipeline_1 = create(:ci_pipeline)
build_1 = create(:ci_build, pipeline: pipeline_1)
@@ -210,8 +208,6 @@ RSpec.describe PipelineSerializer do
end
context 'with build environments' do
- let(:ref) { 'feature' }
-
let_it_be(:production) { create(:environment, :production, project: project) }
let_it_be(:staging) { create(:environment, :staging, project: project) }
@@ -222,13 +218,11 @@ RSpec.describe PipelineSerializer do
create(:ci_build, :scheduled, pipeline: pipeline, environment: production.name)
create(:ci_build, :scheduled, pipeline: pipeline, environment: staging.name)
- expect { subject }.not_to exceed_query_limit(1).for_query /SELECT "environments".*/
+ expect { subject }.not_to exceed_query_limit(1).for_query(/SELECT "environments".*/)
end
end
context 'with scheduled and manual builds' do
- let(:ref) { 'feature' }
-
before do
create(:ci_build, :scheduled, pipeline: resource.first)
create(:ci_build, :scheduled, pipeline: resource.second)
@@ -238,7 +232,7 @@ RSpec.describe PipelineSerializer do
it 'sends at most one metadata query for each type of build', :request_store do
# 1 for the existing failed builds and 2 for the added scheduled and manual builds
- expect { subject }.not_to exceed_query_limit(1 + 2).for_query /SELECT "ci_builds_metadata".*/
+ expect { subject }.not_to exceed_query_limit(1 + 2).for_query(/SELECT "ci_builds_metadata".*/)
end
end
@@ -246,25 +240,25 @@ RSpec.describe PipelineSerializer do
create(:ci_empty_pipeline,
project: project,
status: status,
- ref: ref).tap do |pipeline|
- Ci::Build::AVAILABLE_STATUSES.each do |status|
- create_build(pipeline, status, status)
+ ref: 'feature').tap do |pipeline|
+ Ci::Build::AVAILABLE_STATUSES.each do |build_status|
+ create_build(pipeline, status, build_status)
end
end
end
def create_build(pipeline, stage, status)
create(:ci_build, :tags, :triggered, :artifacts,
- pipeline: pipeline, stage: stage,
- name: stage, status: status, ref: pipeline.ref)
+ pipeline: pipeline, stage: stage,
+ name: stage, status: status, ref: pipeline.ref)
end
end
end
describe '#represent_status' do
context 'when represents only status' do
- let(:resource) { create(:ci_pipeline) }
- let(:status) { resource.detailed_status(double('user')) }
+ let(:resource) { build_stubbed(:ci_pipeline) }
+ let(:status) { resource.detailed_status(instance_double('User')) }
subject { serializer.represent_status(resource) }
diff --git a/spec/serializers/project_access_token_entity_spec.rb b/spec/serializers/project_access_token_entity_spec.rb
index 4b5b4d4d77d..8af09b0a45d 100644
--- a/spec/serializers/project_access_token_entity_spec.rb
+++ b/spec/serializers/project_access_token_entity_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe ProjectAccessTokenEntity do
expected_revoke_path = Gitlab::Routing.url_helpers
.revoke_namespace_project_settings_access_token_path(
{ id: token,
- namespace_id: project.namespace.path,
+ namespace_id: project.namespace.full_path,
project_id: project.path })
expect(json).to(
@@ -42,7 +42,7 @@ RSpec.describe ProjectAccessTokenEntity do
expected_revoke_path = Gitlab::Routing.url_helpers
.revoke_namespace_project_settings_access_token_path(
{ id: token,
- namespace_id: project.namespace.path,
+ namespace_id: project.namespace.full_path,
project_id: project.path })
expect(json).to(