summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-05-09 16:04:05 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-05-12 07:17:07 +0530
commita4ee7d25e398f9d2e2311703fbbcf5f6b9bdf728 (patch)
tree917b3cb2864fe4597a0bbe630f7d92750b1a6385
parenta59ad3936a0bdbfd64d9c54af631a272317fe680 (diff)
downloadgitlab-ce-a4ee7d25e398f9d2e2311703fbbcf5f6b9bdf728.tar.gz
Implement @rymai's feedback after review.
- Separate 'exercise' and 'verify' steps of tests. - Use `build_stubbed` instead of `build`
-rw-r--r--spec/lib/banzai/filter/wiki_link_filter_spec.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/lib/banzai/filter/wiki_link_filter_spec.rb b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
index 56b1a267390..185abbb2108 100644
--- a/spec/lib/banzai/filter/wiki_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
@@ -3,8 +3,8 @@ require 'spec_helper'
describe Banzai::Filter::WikiLinkFilter, lib: true do
include FilterSpecHelper
- let(:namespace) { build(:namespace, name: "wiki_link_ns") }
- let(:project) { build(:empty_project, :public, name: "wiki_link_project", namespace: namespace) }
+ let(:namespace) { build_stubbed(:namespace, name: "wiki_link_ns") }
+ let(:project) { build_stubbed(:empty_project, :public, name: "wiki_link_project", namespace: namespace) }
let(:user) { double }
let(:project_wiki) { ProjectWiki.new(project, user) }
@@ -13,12 +13,14 @@ describe Banzai::Filter::WikiLinkFilter, lib: true do
it "doesn't rewrite non-file links" do
link = "<a href='./page'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('./page')
end
it "doesn't rewrite file links" do
link = "<a href='./page.md'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('./page.md')
end
end
@@ -27,12 +29,14 @@ describe Banzai::Filter::WikiLinkFilter, lib: true do
it "doesn't rewrite non-file links" do
link = "<a href='../page'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('../page')
end
it "doesn't rewrite file links" do
link = "<a href='../page.md'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('../page.md')
end
end
@@ -41,12 +45,14 @@ describe Banzai::Filter::WikiLinkFilter, lib: true do
it "doesn't rewrite non-file links" do
link = "<a href='./subdirectory/page'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('./subdirectory/page')
end
it "doesn't rewrite file links" do
link = "<a href='./subdirectory/page.md'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('./subdirectory/page.md')
end
end
@@ -62,6 +68,7 @@ describe Banzai::Filter::WikiLinkFilter, lib: true do
it "doesn't rewrite file links" do
link = "<a href='page.md'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('page.md')
end
end
@@ -71,6 +78,7 @@ describe Banzai::Filter::WikiLinkFilter, lib: true do
it "doesn't rewrite links" do
link = "<a href='http://example.com/page'>Link to Page</a>"
filtered_link = filter(link, project_wiki: project_wiki).children[0]
+
expect(filtered_link.attribute('href').value).to eq('http://example.com/page')
end
end