Commit f3e4692f authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'pl-spec-banzai-milestone-ref-filter-perf' into 'master'

Speed up banzai milestone reference filter specs

See merge request gitlab-org/gitlab!43053
parents 83aa6108 2d814be4
...@@ -5,9 +5,11 @@ require 'spec_helper' ...@@ -5,9 +5,11 @@ require 'spec_helper'
RSpec.describe Banzai::Filter::MilestoneReferenceFilter do RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
include FilterSpecHelper include FilterSpecHelper
let(:parent_group) { create(:group, :public) } let_it_be(:parent_group) { create(:group, :public) }
let(:group) { create(:group, :public, parent: parent_group) } let_it_be(:group) { create(:group, :public, parent: parent_group) }
let(:project) { create(:project, :public, group: group) } let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:namespace) { create(:namespace) }
let_it_be(:another_project) { create(:project, :public, namespace: namespace) }
it 'requires project context' do it 'requires project context' do
expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
...@@ -188,9 +190,7 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -188,9 +190,7 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
end end
shared_examples 'cross-project / cross-namespace complete reference' do shared_examples 'cross-project / cross-namespace complete reference' do
let(:namespace) { create(:namespace) } let_it_be(:milestone) { create(:milestone, project: another_project) }
let(:another_project) { create(:project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
...@@ -226,10 +226,8 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -226,10 +226,8 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
end end
shared_examples 'cross-project / same-namespace complete reference' do shared_examples 'cross-project / same-namespace complete reference' do
let(:namespace) { create(:namespace) } let_it_be(:project) { create(:project, :public, namespace: namespace) }
let(:project) { create(:project, :public, namespace: namespace) } let_it_be(:milestone) { create(:milestone, project: another_project) }
let(:another_project) { create(:project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
...@@ -265,10 +263,8 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -265,10 +263,8 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
end end
shared_examples 'cross project shorthand reference' do shared_examples 'cross project shorthand reference' do
let(:namespace) { create(:namespace) } let_it_be(:project) { create(:project, :public, namespace: namespace) }
let(:project) { create(:project, :public, namespace: namespace) } let_it_be(:milestone) { create(:milestone, project: another_project) }
let(:another_project) { create(:project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.path}%#{milestone.iid}" } let(:reference) { "#{another_project.path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
...@@ -439,13 +435,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -439,13 +435,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
context 'when milestone is open' do context 'when milestone is open' do
context 'project milestones' do context 'project milestones' do
let(:milestone) { create(:milestone, project: project) } let_it_be_with_reload(:milestone) { create(:milestone, project: project) }
include_context 'project milestones' include_context 'project milestones'
end end
context 'group milestones' do context 'group milestones' do
let(:milestone) { create(:milestone, group: group) } let_it_be_with_reload(:milestone) { create(:milestone, group: group) }
include_context 'group milestones' include_context 'group milestones'
end end
...@@ -453,13 +449,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -453,13 +449,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do
context 'when milestone is closed' do context 'when milestone is closed' do
context 'project milestones' do context 'project milestones' do
let(:milestone) { create(:milestone, :closed, project: project) } let_it_be_with_reload(:milestone) { create(:milestone, :closed, project: project) }
include_context 'project milestones' include_context 'project milestones'
end end
context 'group milestones' do context 'group milestones' do
let(:milestone) { create(:milestone, :closed, group: group) } let_it_be_with_reload(:milestone) { create(:milestone, :closed, group: group) }
include_context 'group milestones' include_context 'group milestones'
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