diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/lib/banzai | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/lib/banzai')
5 files changed, 33 insertions, 49 deletions
diff --git a/spec/lib/banzai/filter/design_reference_filter_spec.rb b/spec/lib/banzai/filter/design_reference_filter_spec.rb index 1b558754932..847c398964a 100644 --- a/spec/lib/banzai/filter/design_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/design_reference_filter_spec.rb @@ -74,26 +74,6 @@ RSpec.describe Banzai::Filter::DesignReferenceFilter do it_behaves_like 'a no-op filter' end - - context 'design reference filter is not enabled' do - before do - stub_feature_flags(described_class::FEATURE_FLAG => false) - end - - it_behaves_like 'a no-op filter' - - it 'issues no queries' do - expect { process(input_text) }.not_to exceed_query_limit(0) - end - end - - context 'the filter is enabled for the context project' do - before do - stub_feature_flags(described_class::FEATURE_FLAG => project) - end - - it_behaves_like 'a good link reference' - end end end diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index e7b6c910b8a..35ef2abfa63 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -5,6 +5,8 @@ require 'spec_helper' RSpec.describe Banzai::Filter::ExternalIssueReferenceFilter do include FilterSpecHelper + let_it_be_with_refind(:project) { create(:project) } + shared_examples_for "external issue tracker" do it_behaves_like 'a reference containing an element node' @@ -116,7 +118,7 @@ RSpec.describe Banzai::Filter::ExternalIssueReferenceFilter do end context "redmine project" do - let(:project) { create(:redmine_project) } + let_it_be(:service) { create(:redmine_service, project: project) } before do project.update!(issues_enabled: false) @@ -138,7 +140,7 @@ RSpec.describe Banzai::Filter::ExternalIssueReferenceFilter do end context "youtrack project" do - let(:project) { create(:youtrack_project) } + let_it_be(:service) { create(:youtrack_service, project: project) } before do project.update!(issues_enabled: false) @@ -181,7 +183,7 @@ RSpec.describe Banzai::Filter::ExternalIssueReferenceFilter do end context "jira project" do - let(:project) { create(:jira_project) } + let_it_be(:service) { create(:jira_service, project: project) } let(:reference) { issue.to_reference } context "with right markdown" do @@ -210,7 +212,7 @@ RSpec.describe Banzai::Filter::ExternalIssueReferenceFilter do end context "ewm project" do - let_it_be(:project) { create(:ewm_project) } + let_it_be(:service) { create(:ewm_service, project: project) } before do project.update!(issues_enabled: false) diff --git a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb index 8bdb24ab08c..d29af311ee5 100644 --- a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Banzai::Filter::InlineGrafanaMetricsFilter do it_behaves_like 'a metrics embed filter' around do |example| - Timecop.freeze(Time.utc(2019, 3, 17, 13, 10)) { example.run } + travel_to(Time.utc(2019, 3, 17, 13, 10)) { example.run } end context 'when grafana is not configured' do diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index 447802d18a7..4b8b575c1f0 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -296,6 +296,12 @@ RSpec.describe Banzai::Filter::IssueReferenceFilter do .to eq reference end + it 'link with trailing slash' do + doc = reference_filter("Fixed (#{issue_url + "/"}.)") + + expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(issue.to_reference(project))}</a>\.\)}) + end + it 'links with adjacent text' do doc = reference_filter("Fixed (#{reference}.)") diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index 62b1711ee57..276fa7952be 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -5,9 +5,11 @@ require 'spec_helper' RSpec.describe Banzai::Filter::MilestoneReferenceFilter do include FilterSpecHelper - let(:parent_group) { create(:group, :public) } - let(:group) { create(:group, :public, parent: parent_group) } - let(:project) { create(:project, :public, group: group) } + let_it_be(:parent_group) { create(:group, :public) } + let_it_be(:group) { create(:group, :public, parent: parent_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 expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) @@ -188,11 +190,9 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do end shared_examples 'cross-project / cross-namespace complete reference' do - let(:namespace) { create(:namespace) } - let(:another_project) { create(:project, :public, namespace: namespace) } - let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } - let!(:result) { reference_filter("See #{reference}") } + let_it_be(:milestone) { create(:milestone, project: another_project) } + let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } + let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls @@ -226,12 +226,10 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do end shared_examples 'cross-project / same-namespace complete reference' do - let(:namespace) { create(:namespace) } - let(:project) { create(:project, :public, namespace: namespace) } - let(:another_project) { create(:project, :public, namespace: namespace) } - let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } - let!(:result) { reference_filter("See #{reference}") } + let_it_be(:project) { create(:project, :public, namespace: namespace) } + let_it_be(:milestone) { create(:milestone, project: another_project) } + let(:reference) { "#{another_project.full_path}%#{milestone.iid}" } + let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls @@ -265,12 +263,10 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do end shared_examples 'cross project shorthand reference' do - let(:namespace) { create(:namespace) } - let(:project) { create(:project, :public, namespace: namespace) } - let(:another_project) { create(:project, :public, namespace: namespace) } - let(:milestone) { create(:milestone, project: another_project) } - let(:reference) { "#{another_project.path}%#{milestone.iid}" } - let!(:result) { reference_filter("See #{reference}") } + let_it_be(:project) { create(:project, :public, namespace: namespace) } + let_it_be(:milestone) { create(:milestone, project: another_project) } + let(:reference) { "#{another_project.path}%#{milestone.iid}" } + let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls @@ -439,13 +435,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do context 'when milestone is open' 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' end context 'group milestones' do - let(:milestone) { create(:milestone, group: group) } + let_it_be_with_reload(:milestone) { create(:milestone, group: group) } include_context 'group milestones' end @@ -453,13 +449,13 @@ RSpec.describe Banzai::Filter::MilestoneReferenceFilter do context 'when milestone is closed' 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' end 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' end |