Permalink
Browse files

urls should be unique

  • Loading branch information...
1 parent f0aaa97 commit 3ebc5b78abf7a040cc1a607000796627943b9ff3 @lis2 lis2 committed Jun 6, 2012
Showing with 18 additions and 9 deletions.
  1. +1 −0 lib/big_sitemap.rb
  2. +17 −9 test/big_sitemap_test.rb
View
@@ -178,6 +178,7 @@ def add_urls
return self if Array(@paths).empty?
with_sitemap do |builder|
+ @paths.uniq!
@paths.each do |path, options|
url = URI.join(@options[:base_url], path)
builder.add_url! url, options
View
@@ -75,15 +75,15 @@ def teardown
should 'contain two loc elements' do
generate_sitemap(:max_per_sitemap => 2) do
- 4.times { add '/' }
+ 4.times { |i| add "/#{i}" }
end
assert_equal 2, num_elements(sitemaps_index_file, 'loc')
end
should 'contain two lastmod elements' do
generate_sitemap(:max_per_sitemap => 2) do
- 4.times { add '/' }
+ 4.times { |i| add "/#{i}" }
end
assert_equal 2, num_elements(sitemaps_index_file, 'lastmod')
@@ -103,31 +103,31 @@ def teardown
should 'contain several loc elements' do
generate_sitemap do
- 3.times { add '/' }
+ 3.times { |i| add "/#{i}" }
end
assert_equal 3, num_elements(first_sitemap_file, 'loc')
end
should 'contain several lastmod elements' do
generate_sitemap do
- 3.times { add '/', :last_modified => Time.now }
+ 3.times { |i| add "/#{i}", :last_modified => Time.now }
end
assert_equal 3, num_elements(first_sitemap_file, 'lastmod')
end
should 'contain several changefreq elements' do
generate_sitemap do
- 3.times { add '/' }
+ 3.times { |i| add "/#{i}" }
end
assert_equal 3, num_elements(first_sitemap_file, 'changefreq')
end
should 'contain several priority elements' do
generate_sitemap do
- 3.times { add '/', :priority => 0.2 }
+ 3.times { |i| add "/#{i}", :priority => 0.2 }
end
assert_equal 3, num_elements(first_sitemap_file, 'priority')
@@ -153,7 +153,7 @@ def teardown
should 'contain two loc element' do
generate_sitemap(:max_per_sitemap => 2) do
- 4.times { add '/' }
+ 4.times { |i| add "/#{i}" }
end
assert_equal 2, num_elements(first_sitemap_file, 'loc')
@@ -162,7 +162,7 @@ def teardown
should 'contain two changefreq elements' do
generate_sitemap(:max_per_sitemap => 2) do
- 4.times { add '/' }
+ 4.times { |i| add "/#{i}" }
end
assert_equal 2, num_elements(first_sitemap_file, 'changefreq')
@@ -171,7 +171,7 @@ def teardown
should 'contain two priority element' do
generate_sitemap(:max_per_sitemap => 2) do
- 4.times { add '/', :priority => 0.2 }
+ 4.times { |i| add "/#{i}", :priority => 0.2 }
end
assert_equal 2, num_elements(first_sitemap_file, 'priority')
@@ -182,6 +182,14 @@ def teardown
generate_sitemap(:gzip => false) { add '/' }
assert File.exists?(unzipped_first_sitemap_file)
end
+
+ should 'contain unique elements' do
+ generate_sitemap do
+ 2.times { add '/' }
+ end
+
+ assert_equal 1, num_elements(first_sitemap_file, 'url')
+ end
end
context 'sanatize XML chars' do

0 comments on commit 3ebc5b7

Please sign in to comment.