diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-29 20:06:35 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-05 19:11:59 +0300 |
commit | fe13f110412d85c05dc68e5ee1db499f681bf722 (patch) | |
tree | 4a2d172bb5a490ac8cadbcf376fbf815393ef22b /spec/lib/banzai/filter | |
parent | dc7939337e0d72d2391c3bbb3082d644a54195af (diff) |
Create and use project path helpers that only need a project, no namespace
Diffstat (limited to 'spec/lib/banzai/filter')
7 files changed, 57 insertions, 80 deletions
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..60c27bc0d3c 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -29,14 +29,14 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true 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) + .to eq urls.project_compare_url(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) + .to eq urls.project_compare_url(project, range.to_param) end it 'links to a valid short ID' do @@ -94,7 +94,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id, only_path: true) + expect(link).to eq urls.project_compare_url(project, from: commit1.id, to: commit2.id, only_path: true) end end @@ -106,7 +106,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true 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) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -141,7 +141,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true 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) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -176,7 +176,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true 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) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -205,7 +205,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do let(:namespace) { create(:namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:range) { CommitRange.new("#{commit1.id}...master", project) } - let(:reference) { urls.namespace_project_compare_url(project2.namespace, project2, from: commit1.id, to: 'master') } + let(:reference) { urls.project_compare_url(project2, from: commit1.id, to: 'master') } before do range.project = project2 diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index c4d8d3b6682..f6893641481 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -27,7 +27,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do 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) + .to eq urls.project_commit_url(project, reference) end end @@ -90,7 +90,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_commit_url(project.namespace, project, reference, only_path: true) + expect(link).to eq urls.project_commit_url(project, reference, only_path: true) end end @@ -175,13 +175,13 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do let(:namespace) { create(:namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:commit) { project2.commit } - let(:reference) { urls.namespace_project_commit_url(project2.namespace, project2, commit.id) } + let(:reference) { urls.project_commit_url(project2, commit.id) } 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) + .to eq urls.project_commit_url(project2, commit.id) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index cb3cf982351..8daef3ca691 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -45,7 +45,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_issues_path(project.namespace, project, label_name: label.name) + expect(link).to eq urls.project_issues_path(project, label_name: label.name) end context 'project that does not exist referenced' do @@ -73,7 +73,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) end it 'links with adjacent text' do @@ -96,7 +96,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See gfm' end @@ -120,7 +120,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See 2fa' end @@ -144,7 +144,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See ?g.fm&' end @@ -169,7 +169,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See gfm references' end @@ -193,7 +193,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See 2 factor authentication' end @@ -217,7 +217,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See g.fm & references?' end @@ -250,9 +250,9 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{references}") expect(doc.css('a').map { |a| a.attr('href') }).to match_array([ - urls.namespace_project_issues_url(project.namespace, project, label_name: bug.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: feature_proposal.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: technical_debt.name) + urls.project_issues_url(project, label_name: bug.name), + urls.project_issues_url(project, label_name: feature_proposal.name), + urls.project_issues_url(project, label_name: technical_debt.name) ]) expect(doc.text).to eq 'See bug, feature proposal, technical debt' end @@ -265,9 +265,9 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{references}") expect(doc.css('a').map { |a| a.attr('href') }).to match_array([ - urls.namespace_project_issues_url(project.namespace, project, label_name: bug.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: feature_proposal.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: technical_debt.name) + urls.project_issues_url(project, label_name: bug.name), + urls.project_issues_url(project, label_name: feature_proposal.name), + urls.project_issues_url(project, label_name: technical_debt.name) ]) expect(doc.text).to eq 'See bug feature proposal technical debt' end @@ -288,7 +288,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: label.name) end it 'links with adjacent text' do @@ -325,7 +325,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: group_label.name) expect(doc.text).to eq 'See gfm references' end @@ -348,7 +348,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true 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) + .project_issues_url(project, label_name: group_label.name) expect(doc.text).to eq "See gfm references" end @@ -373,9 +373,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -407,9 +405,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -441,9 +437,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -477,9 +471,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do 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, - another_project, - label_name: group_label.name) + .to eq urls.project_issues_url(another_project, label_name: group_label.name) end it 'has valid color' do @@ -514,9 +506,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do 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, - another_project, - label_name: group_label.name) + .to eq urls.project_issues_url(another_project, label_name: group_label.name) end it 'has valid color' do @@ -550,9 +540,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, - project, - label_name: group_label.name) + .to eq urls.project_issues_url(project, label_name: group_label.name) end it 'has valid color' do @@ -584,9 +572,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, - project, - label_name: group_label.name) + .to eq urls.project_issues_url(project, label_name: group_label.name) end it 'has valid color' 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 cd91681551e..1ad329b6452 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -37,7 +37,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true 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) + .project_merge_request_url(project, merge) end it 'links with adjacent text' do @@ -95,7 +95,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_merge_request_url(project.namespace, project, merge, only_path: true) + expect(link).to eq urls.project_merge_request_url(project, merge, only_path: true) end end @@ -108,8 +108,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -142,8 +141,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -176,8 +174,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -203,7 +200,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:merge) { create(:merge_request, source_project: project2, target_project: project2) } - let(:reference) { urls.namespace_project_merge_request_url(project2.namespace, project2, merge) + '/diffs#note_123' } + let(:reference) { urls.project_merge_request_url(project2, merge) + '/diffs#note_123' } it 'links to a valid reference' do doc = reference_filter("See #{reference}") diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index fe88b9cb73e..7fab5613afc 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -45,7 +45,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do expect(link).not_to match %r(https?://) expect(link).to eq urls - .namespace_project_milestone_path(project.namespace, project, milestone) + .project_milestone_path(project, milestone) end context 'Integer-based references' do @@ -53,7 +53,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) end it 'links with adjacent text' do @@ -76,7 +76,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) expect(doc.text).to eq 'See gfm' end @@ -100,7 +100,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) expect(doc.text).to eq 'See gfm references' end @@ -123,7 +123,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) end it 'links with adjacent text' do @@ -157,9 +157,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do 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, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do @@ -196,9 +194,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do 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, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do @@ -235,9 +231,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do 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, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index e851120bc3a..9704db0c221 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -23,7 +23,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_snippet_url(project.namespace, project, snippet) + .project_snippet_url(project, snippet) end it 'links with adjacent text' do @@ -75,7 +75,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_snippet_url(project.namespace, project, snippet, only_path: true) + expect(link).to eq urls.project_snippet_url(project, snippet, only_path: true) end end @@ -89,7 +89,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -122,7 +122,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -155,7 +155,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -181,13 +181,13 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:snippet) { create(:project_snippet, project: project2) } - let(:reference) { urls.namespace_project_snippet_url(project2.namespace, project2, snippet) } + let(:reference) { urls.project_snippet_url(project2, snippet) } 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) + .to eq urls.project_snippet_url(project2, snippet) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index edf3846b742..77561e00573 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -43,7 +43,7 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do expect(doc.css('a').length).to eq 1 expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_url(project.namespace, project) + .to eq urls.project_url(project) end it 'includes a data-author attribute when there is an author' do |