New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ensure host ends in a slash #245
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
describe SitemapGenerator::LinkSet do | ||
let(:default_host) { 'http://example.com' } | ||
let(:default_host) { 'http://example.com/' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert all the changes to this file. The hostname must be able to be entered with or without a trailing slash, so having it omit the slash tests the code. And I'd rather not use |
||
let(:ls) { SitemapGenerator::LinkSet.new(:default_host => default_host) } | ||
|
||
describe "initializer options" do | ||
|
@@ -97,8 +97,8 @@ | |
|
||
describe "sitemaps url" do | ||
it "should change when the default_host is changed" do | ||
ls.default_host = 'http://one.com' | ||
ls.default_host.should == 'http://one.com' | ||
ls.default_host = 'http://one.com/' | ||
ls.default_host.should == 'http://one.com/' | ||
ls.default_host.should == ls.sitemap.location.host | ||
ls.default_host.should == ls.sitemap_index.location.host | ||
end | ||
|
@@ -121,7 +121,7 @@ | |
describe "sitemap_index_url" do | ||
it "should return the url to the index file" do | ||
ls.default_host = default_host | ||
ls.sitemap_index.location.url.should == "#{default_host}/sitemap.xml.gz" | ||
ls.sitemap_index.location.url.should == URI.join(default_host, "/sitemap.xml.gz").to_s | ||
ls.sitemap_index_url.should == ls.sitemap_index.location.url | ||
end | ||
end | ||
|
@@ -215,7 +215,7 @@ | |
end | ||
|
||
describe "sitemaps host" do | ||
let(:new_host) { 'http://wowza.com' } | ||
let(:new_host) { 'http://wowza.com/' } | ||
|
||
it "should have a host" do | ||
ls.default_host = default_host | ||
|
@@ -253,7 +253,7 @@ | |
|
||
it "should not modify the index" do | ||
@ls.sitemaps_host = 'http://newhost.com' | ||
@ls.sitemap.location.host.should == 'http://newhost.com' | ||
@ls.sitemap.location.host.should == 'http://newhost.com/' | ||
@ls.sitemap_index.location.host.should == default_host | ||
end | ||
|
||
|
@@ -345,7 +345,7 @@ | |
end | ||
|
||
it "should set the default_host" do | ||
host = 'http://defaulthost.com' | ||
host = 'http://defaulthost.com/' | ||
group = ls.group(:default_host => host) | ||
group.default_host.should == host | ||
group.sitemap.location.host.should == host | ||
|
@@ -354,7 +354,7 @@ | |
|
||
describe "sitemaps_host" do | ||
it "should set the sitemaps host" do | ||
@host = 'http://sitemaphost.com' | ||
@host = 'http://sitemaphost.com/' | ||
@group = ls.group(:sitemaps_host => @host) | ||
@group.sitemaps_host.should == @host | ||
@group.sitemap.location.host.should == @host | ||
|
@@ -403,7 +403,7 @@ | |
it "if only default_host is passed" do | ||
group = ls.group(:default_host => 'http://newhost.com') | ||
group.sitemap.should == ls.sitemap | ||
group.sitemap.location.host.should == 'http://newhost.com' | ||
group.sitemap.location.host.should == 'http://newhost.com/' | ||
end | ||
end | ||
|
||
|
@@ -512,14 +512,14 @@ | |
end | ||
|
||
it "should set the default_host" do | ||
host = 'http://defaulthost.com' | ||
host = 'http://defaulthost.com/' | ||
ls.create(:default_host => host) | ||
ls.default_host.should == host | ||
ls.sitemap.location.host.should == host | ||
end | ||
|
||
it "should set the sitemaps host" do | ||
host = 'http://sitemaphost.com' | ||
host = 'http://sitemaphost.com/' | ||
ls.create(:sitemaps_host => host) | ||
ls.sitemaps_host.should == host | ||
ls.sitemap.location.host.should == host | ||
|
@@ -590,7 +590,7 @@ | |
end | ||
|
||
describe "include_index?" do | ||
let(:sitemaps_host) { 'http://amazon.com' } | ||
let(:sitemaps_host) { 'http://amazon.com/' } | ||
|
||
it "should be true if no sitemaps_host set, or it is the same" do | ||
ls.include_index = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
describe SitemapGenerator::SitemapLocation do | ||
let(:default_host) { 'http://example.com' } | ||
let(:default_host) { 'http://example.com/' } | ||
let(:location) { SitemapGenerator::SitemapLocation.new } | ||
|
||
it "public_path should default to the public directory in the application root" do | ||
|
@@ -35,6 +35,11 @@ | |
}.should raise_error | ||
end | ||
|
||
it "should append slash to host" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please just keep this change and revert the others. |
||
location = SitemapGenerator::SitemapLocation.new(:filename => nil, :namer => nil, :host => "http://www.slash.com") | ||
location.host.should == "http://www.slash.com/" | ||
end | ||
|
||
it "should accept a Namer option" do | ||
@namer = SitemapGenerator::SimpleNamer.new(:xxx) | ||
location = SitemapGenerator::SitemapLocation.new(:namer => @namer) | ||
|
@@ -95,7 +100,7 @@ | |
describe "when duplicated" do | ||
it "should not inherit some objects" do | ||
location = SitemapGenerator::SitemapLocation.new(:filename => 'xxx', :host => default_host, :public_path => 'public/') | ||
location.url.should == default_host+'/xxx' | ||
location.url.should == URI.join(default_host, '/xxx').to_s | ||
location.public_path.to_s.should == 'public/' | ||
dup = location.dup | ||
dup.url.should == location.url | ||
|
@@ -140,7 +145,7 @@ | |
location = SitemapGenerator::SitemapLocation.new( | ||
:public_path => 'public/google', :filename => 'xxx', | ||
:host => default_host, :sitemaps_path => 'sub/dir') | ||
location.url.should == default_host + '/sub/dir/xxx' | ||
location.url.should == URI.join(default_host, '/sub/dir/xxx').to_s | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename
append_slash