Commit 76d28f2a authored by Dylan Griffith's avatar Dylan Griffith

Fix spec violations in commit_statuses API request spec

Whenever we create pipelines we need to call `ensure_project_iid!` on
them before saving them otherwise we trigger a write to the
`internal_ids` table in the transaction for saving the model which
causes as cross-database modification.

These cases are all false positives because we already call
`ensure_project_iid!` everywhere we create a pipeline in real
application code.
parent e8a14346
......@@ -14,8 +14,19 @@ RSpec.describe API::CommitStatuses do
let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" }
context 'ci commit exists' do
let!(:master) { project.ci_pipelines.create!(source: :push, sha: commit.id, ref: 'master', protected: false) }
let!(:develop) { project.ci_pipelines.create!(source: :push, sha: commit.id, ref: 'develop', protected: false) }
let!(:master) do
project.ci_pipelines.build(source: :push, sha: commit.id, ref: 'master', protected: false).tap do |p|
p.ensure_project_iid! # Necessary to avoid cross-database modification error
p.save!
end
end
let!(:develop) do
project.ci_pipelines.build(source: :push, sha: commit.id, ref: 'develop', protected: false).tap do |p|
p.ensure_project_iid! # Necessary to avoid cross-database modification error
p.save!
end
end
context "reporter user" do
let(:statuses_id) { json_response.map { |status| status['id'] } }
......@@ -310,8 +321,19 @@ RSpec.describe API::CommitStatuses do
end
context 'when a pipeline id is specified' do
let!(:first_pipeline) { project.ci_pipelines.create!(source: :push, sha: commit.id, ref: 'master', status: 'created') }
let!(:other_pipeline) { project.ci_pipelines.create!(source: :push, sha: commit.id, ref: 'master', status: 'created') }
let!(:first_pipeline) do
project.ci_pipelines.build(source: :push, sha: commit.id, ref: 'master', status: 'created').tap do |p|
p.ensure_project_iid! # Necessary to avoid cross-database modification error
p.save!
end
end
let!(:other_pipeline) do
project.ci_pipelines.build(source: :push, sha: commit.id, ref: 'master', status: 'created').tap do |p|
p.ensure_project_iid! # Necessary to avoid cross-database modification error
p.save!
end
end
subject do
post api(post_url, developer), params: {
......
......@@ -62,7 +62,6 @@
- "./spec/models/user_status_spec.rb"
- "./spec/requests/api/ci/pipeline_schedules_spec.rb"
- "./spec/requests/api/ci/pipelines_spec.rb"
- "./spec/requests/api/commit_statuses_spec.rb"
- "./spec/requests/api/commits_spec.rb"
- "./spec/requests/api/graphql/mutations/ci/pipeline_destroy_spec.rb"
- "./spec/requests/api/resource_access_tokens_spec.rb"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment