Commit eda668d5 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'fix-specs-to-support-parent-strategy-in-factories-1' into 'master'

Refactor tests to support Parent Strategy in factories

See merge request gitlab-org/gitlab!41753
parents a1fbd4cc 6aa0094d
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::DataBuilder::Deployment do
describe '.build' do
it 'returns the object kind for a deployment' do
deployment = build(:deployment)
deployment = build(:deployment, deployable: nil, environment: create(:environment))
data = described_class.build(deployment)
......
......@@ -61,7 +61,8 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
end
describe 'namespace uniqueness validation' do
let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace, namespace: 'my-namespace') }
let_it_be(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace, cluster: cluster, namespace: 'my-namespace') }
subject { kubernetes_namespace }
......
......@@ -81,6 +81,8 @@ RSpec.describe Event do
describe 'validations' do
describe 'action' do
context 'for a design' do
let_it_be(:author) { create(:user) }
where(:action, :valid) do
valid = described_class::DESIGN_ACTIONS.map(&:to_s).to_set
......@@ -90,7 +92,7 @@ RSpec.describe Event do
end
with_them do
let(:event) { build(:design_event, action: action) }
let(:event) { build(:design_event, author: author, action: action) }
specify { expect(event.valid?).to eq(valid) }
end
......@@ -731,7 +733,8 @@ RSpec.describe Event do
end
target = kind == :project ? nil : build(kind, **extra_data)
[kind, build(:event, :created, project: project, target: target)]
[kind, build(:event, :created, author: project.owner, project: project, target: target)]
end.to_h
end
......
......@@ -210,11 +210,13 @@ RSpec.describe Notes::QuickActionsService do
let(:service) { described_class.new(project, maintainer) }
it_behaves_like 'note on noteable that supports quick actions' do
let(:note) { build(:note_on_issue, project: project) }
let_it_be(:issue, reload: true) { create(:issue, project: project) }
let(:note) { build(:note_on_issue, project: project, noteable: issue) }
end
it_behaves_like 'note on noteable that supports quick actions' do
let(:note) { build(:note_on_merge_request, project: project) }
let_it_be(:merge_request, reload: true) { create(:merge_request, source_project: project) }
let(:note) { build(:note_on_merge_request, project: project, noteable: merge_request) }
end
end
......
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