diff options
Diffstat (limited to 'spec/lib/banzai/filter')
15 files changed, 226 insertions, 226 deletions
diff --git a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb index fb614762a0d..27684882435 100644 --- a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb @@ -23,11 +23,11 @@ describe Banzai::Filter::AbstractReferenceFilter do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new(%w[1]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new(%w[1]) }) - expect(filter.projects_per_reference) - .to eq({ project.path_with_namespace => project }) + expect(filter.projects_per_reference). + to eq({ project.path_with_namespace => project }) end end @@ -37,13 +37,13 @@ describe Banzai::Filter::AbstractReferenceFilter do context 'with RequestStore disabled' do it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])) - .to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])). + to eq([project]) end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end end @@ -58,14 +58,14 @@ describe Banzai::Filter::AbstractReferenceFilter do end it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])) - .to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])). + to eq([project]) end context "when no project with that path exists" do it "returns no value" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end it "adds the ref to the project refs cache" do @@ -84,8 +84,8 @@ describe Banzai::Filter::AbstractReferenceFilter do end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end end end diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index fc67c7ec3c4..deadc36524c 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -28,15 +28,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid two-dot reference' do doc = reference_filter("See #{reference2}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) end it 'links to a valid three-dot reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) end it 'links to a valid short ID' do @@ -105,15 +105,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -140,15 +140,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -175,15 +175,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -214,8 +214,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index c4d8d3b6682..a19aac61229 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -26,8 +26,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do doc = reference_filter("See #{reference[0...size]}") expect(doc.css('a').first.text).to eq commit.short_id - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project.namespace, project, reference) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_commit_url(project.namespace, project, reference) end end @@ -180,8 +180,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) end it 'links with adjacent text' do 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 5d625fe05bb..efd145e9452 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -33,8 +33,8 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do doc = filter("Issue #{reference}") issue_id = doc.css('a').first.attr("data-external-issue") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue_id, project) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue_id, project) end it 'links to the external tracker' do @@ -58,8 +58,8 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do end it 'escapes the title attribute' do - allow(project.external_issue_tracker).to receive(:title) - .and_return(%{"></a>whatever<a title="}) + allow(project.external_issue_tracker).to receive(:title). + and_return(%{"></a>whatever<a title="}) doc = filter("Issue #{reference}") expect(doc.text).to eq "Issue #{reference}" diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index 2fdf3251013..11607d4fb26 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -36,8 +36,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("Fixed #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project) end it 'links with adjacent text' do @@ -124,9 +124,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -135,8 +135,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -168,9 +168,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -179,8 +179,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -212,9 +212,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -223,8 +223,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -257,8 +257,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do @@ -279,8 +279,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'links with adjacent text' do @@ -301,8 +301,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + "#note_123" + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) + "#note_123" end it 'links with adjacent text' do @@ -317,14 +317,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:projects_per_reference) - .and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference). + and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new([issue.iid]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new([issue.iid]) }) - expect(filter.issues_per_project) - .to eq({ project => { issue.iid => issue } }) + expect(filter.issues_per_project). + to eq({ project => { issue.iid => issue } }) end end @@ -335,14 +335,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do expect(project).to receive(:default_issues_tracker?).and_return(false) - expect(filter).to receive(:projects_per_reference) - .and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference). + and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new([1]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new([1]) }) - expect(filter.issues_per_project[project][1]) - .to be_an_instance_of(ExternalIssue) + expect(filter.issues_per_project[project][1]). + to be_an_instance_of(ExternalIssue) end end end diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index cb3cf982351..5e16fd10ebe 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -72,8 +72,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -95,8 +95,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm' end @@ -119,8 +119,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2fa' end @@ -143,8 +143,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See ?g.fm&' end @@ -168,8 +168,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm references' end @@ -192,8 +192,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2 factor authentication' end @@ -216,8 +216,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See g.fm & references?' end @@ -287,8 +287,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -324,8 +324,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq 'See gfm references' end @@ -347,8 +347,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq "See gfm references" end @@ -372,8 +372,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end @@ -406,8 +406,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end @@ -440,15 +440,15 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')) - .to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')). + to match /background-color: #00ff00/ end it 'has valid link text' do @@ -476,25 +476,25 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(another_project.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(another_project.namespace, another_project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')) - .to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')). + to match /background-color: #00ff00/ end it 'has valid link text' do - expect(result.css('a').first.text) - .to eq "#{group_label.name} in #{another_project.name_with_namespace}" + expect(result.css('a').first.text). + to eq "#{group_label.name} in #{another_project.name_with_namespace}" end it 'has valid text' do - expect(result.text) - .to eq "See #{group_label.name} in #{another_project.name_with_namespace}" + expect(result.text). + to eq "See #{group_label.name} in #{another_project.name_with_namespace}" end it 'ignores invalid IDs on the referenced label' do @@ -513,25 +513,25 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(another_project.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(another_project.namespace, another_project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')) - .to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')). + to match /background-color: #00ff00/ end it 'has valid link text' do - expect(result.css('a').first.text) - .to eq "#{group_label.name} in #{another_project.name}" + expect(result.css('a').first.text). + to eq "#{group_label.name} in #{another_project.name}" end it 'has valid text' do - expect(result.text) - .to eq "See #{group_label.name} in #{another_project.name}" + expect(result.text). + to eq "See #{group_label.name} in #{another_project.name}" end it 'ignores invalid IDs on the referenced label' do @@ -549,15 +549,15 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(project.namespace, project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')) - .to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')). + to match /background-color: #00ff00/ end it 'has valid link text' do @@ -583,15 +583,15 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, + expect(result.css('a').first.attr('href')). + to eq urls.namespace_project_issues_url(project.namespace, project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')) - .to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')). + to match /background-color: #00ff00/ end it 'has valid link text' do diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 0fc017788bd..3d3d36061f4 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -23,8 +23,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_merge_request_url(project.namespace, project, merge) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_merge_request_url(project.namespace, project, merge) end it 'links with adjacent text' do @@ -94,8 +94,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -128,8 +128,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -162,8 +162,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -195,8 +195,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index fe88b9cb73e..a317c751d32 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -44,16 +44,16 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls - .namespace_project_milestone_path(project.namespace, project, milestone) + expect(link).to eq urls. + namespace_project_milestone_path(project.namespace, project, milestone) end context 'Integer-based references' do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -75,8 +75,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm' end @@ -99,8 +99,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm references' end @@ -122,8 +122,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -156,8 +156,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -165,15 +165,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path_with_namespace}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path_with_namespace}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") end it 'escapes the name attribute' do @@ -181,8 +181,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path_with_namespace}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path_with_namespace}" end end @@ -195,8 +195,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -204,15 +204,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -220,8 +220,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path}" end end @@ -234,8 +234,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -243,15 +243,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -259,8 +259,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path}" end end end diff --git a/spec/lib/banzai/filter/redactor_filter_spec.rb b/spec/lib/banzai/filter/redactor_filter_spec.rb index 84bddda723a..0140a91c7ba 100644 --- a/spec/lib/banzai/filter/redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/redactor_filter_spec.rb @@ -23,9 +23,9 @@ describe Banzai::Filter::RedactorFilter, lib: true do end before do - allow(Banzai::ReferenceParser).to receive(:[]) - .with('test') - .and_return(parser_class) + allow(Banzai::ReferenceParser).to receive(:[]). + with('test'). + and_return(parser_class) end context 'valid projects' do diff --git a/spec/lib/banzai/filter/reference_filter_spec.rb b/spec/lib/banzai/filter/reference_filter_spec.rb index ba0fa4a609a..55e681f6faf 100644 --- a/spec/lib/banzai/filter/reference_filter_spec.rb +++ b/spec/lib/banzai/filter/reference_filter_spec.rb @@ -8,8 +8,8 @@ describe Banzai::Filter::ReferenceFilter, lib: true do document = Nokogiri::HTML.fragment('<a href="foo">foo</a>') filter = described_class.new(document, project: project) - expect { |b| filter.each_node(&b) } - .to yield_with_args(an_instance_of(Nokogiri::XML::Element)) + expect { |b| filter.each_node(&b) }. + to yield_with_args(an_instance_of(Nokogiri::XML::Element)) end it 'returns an Enumerator when no block is given' do diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 1ce7bd7706e..1957ba739e2 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -72,15 +72,15 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'ignores ref if commit is passed' do doc = filter(link('non/existent.file'), commit: project.commit('empty-branch') ) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree end shared_examples :valid_repository do it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'ignores absolute URLs with two leading slashes' do @@ -90,71 +90,71 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'rebuilds relative URL for a file in the repo' do doc = filter(link('doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo with leading ./' do doc = filter(link('./doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up one directory' do relative_link = link('../api/README.md') doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up multiple directories' do relative_link = link('../../../api/README.md') doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repository root' do relative_link = link('../README.md') doc = filter(relative_link, requested_path: 'doc/some-file.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/README.md" end it 'rebuilds relative URL for a file in the repo with an anchor' do doc = filter(link('README.md#section')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md#section" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/README.md#section" end it 'rebuilds relative URL for a directory in the repo' do doc = filter(link('doc/api/')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/tree/#{ref}/doc/api" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/tree/#{ref}/doc/api" end it 'rebuilds relative URL for an image in the repo' do doc = filter(image('files/images/logo-black.png')) - expect(doc.at_css('img')['src']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('img')['src']). + to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for link to an image in the repo' do doc = filter(link('files/images/logo-black.png')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for a video in the repo' do doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') - expect(doc.at_css('video')['src']) - .to eq "/#{project_path}/raw/video/files/videos/intro.mp4" + expect(doc.at_css('video')['src']). + to eq "/#{project_path}/raw/video/files/videos/intro.mp4" end it 'does not modify relative URL with an anchor only' do diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index f2cff6861bc..b38e3b17e64 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -194,8 +194,8 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'disallows invalid URIs' do - expect(Addressable::URI).to receive(:parse).with('foo://example.com') - .and_raise(Addressable::URI::InvalidURIError) + expect(Addressable::URI).to receive(:parse).with('foo://example.com'). + and_raise(Addressable::URI::InvalidURIError) input = '<a href="foo://example.com">Foo</a>' output = filter(input) diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index e851120bc3a..e036514d283 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -22,8 +22,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_snippet_url(project.namespace, project, snippet) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_snippet_url(project.namespace, project, snippet) end it 'links with adjacent text' do @@ -88,8 +88,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -121,8 +121,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -154,8 +154,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -186,8 +186,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/upload_link_filter_spec.rb b/spec/lib/banzai/filter/upload_link_filter_spec.rb index 6327ca8bbfd..639cac6406a 100644 --- a/spec/lib/banzai/filter/upload_link_filter_spec.rb +++ b/spec/lib/banzai/filter/upload_link_filter_spec.rb @@ -51,22 +51,22 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do context 'with a valid repository' do it 'rebuilds relative URL for a link' do doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'rebuilds relative URL for an image' do doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'does not modify absolute URL' do @@ -79,10 +79,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do escaped = Addressable::URI.escape(path) # Stub these methods so the file doesn't actually need to be in the repo - allow_any_instance_of(described_class) - .to receive(:file_exists?).and_return(true) - allow_any_instance_of(described_class) - .to receive(:image?).with(path).and_return(true) + allow_any_instance_of(described_class). + to receive(:file_exists?).and_return(true) + allow_any_instance_of(described_class). + to receive(:image?).with(path).and_return(true) doc = filter(image(escaped)) expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/%ED%95%9C%EA%B8%80.png" diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index d5d128c1907..e9b7b566806 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -37,8 +37,8 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do doc = reference_filter("Hey #{reference}", author: user) expect(doc.css('a').length).to eq 1 - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_url(project.namespace, project) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_url(project.namespace, project) end it 'includes a data-author attribute when there is an author' do |