Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better layout, require depencies and fix spec issue

  • Loading branch information...
commit 87d8069250cafc6e12246a0136fabaf495a485d1 1 parent 5cc9e58
@flyerhzm authored
View
1  init.rb
@@ -1,4 +1,3 @@
# Include hook code here
require 'sitemap'
require 'sitemap_ping'
-require 'hack/resources'
View
1  lib/sitemap.rb
@@ -1,5 +1,6 @@
require 'active_support'
require 'action_controller'
+require 'sitemap/resources'
require 'zlib'
module Sitemap
View
10 lib/sitemap/resources.rb
@@ -0,0 +1,10 @@
+module ActionController
+ module Resources
+ alias_method :origin_action_options_for, :action_options_for
+
+ def action_options_for(action, resource, method = nil, resource_options = {})
+ options = origin_action_options_for(action, resource, method, resource_options)
+ resource.options.reject {|k, v| !['priority', 'changefreq'].include? k.to_s}.merge(options)
+ end
+ end
+end
View
6 spec/sitemap_spec.rb
@@ -1,3 +1,5 @@
+require 'spec_helper'
+
describe "Sitemap::Routes" do
class Post
attr_accessor :id, :name, :updated_at
@@ -112,7 +114,7 @@ def to_param
map.connect 'posts/:year/:month/:day', :controller => 'posts', :action => 'find_by_date', :substitution => {:model => 'Post', :year => 'year', :month => 'month', :day => 'day'}
end
Sitemap::Routes.parse
- Sitemap::Routes.results.collect {|result| result[:location]}.should == ['/posts/2009/8/9', '/posts/2009/8/10']
+ Sitemap::Routes.results.collect {|result| result[:location]}.should == ['/posts/2009/8/9', '/posts/2009/8/10', '/posts/2009/8/10']
end
it "should parse connect with substitution array" do
@@ -142,7 +144,7 @@ def to_param
end
end
Sitemap::Routes.parse
- Sitemap::Routes.results.collect {|result| result[:location]}.should == ['/categories', '/categories/1', '/categories/1/posts', '/categories/1/posts/1', '/categories/1/posts/2']
+ Sitemap::Routes.results.collect {|result| result[:location]}.should == ['/categories/1/posts', '/categories/1/posts/1', '/categories/1/posts/2', '/categories', '/categories/1']
end
end
View
1  spec/spec_helper.rb
@@ -4,4 +4,3 @@
require 'mocha'
require File.join(File.dirname(__FILE__), '../lib/sitemap.rb')
-require File.join(File.dirname(__FILE__), '../lib/hack/resources.rb')
Please sign in to comment.
Something went wrong with that request. Please try again.