strikeroff-routing-filter 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe 'RoutingFilter::Pagination' do
4
- include RoutingFilterHelpers
5
-
6
- before :each do
7
- setup_environment(:pagination)
8
- end
9
-
10
- describe 'url generation' do
11
- it 'appends the segments /pages/:page to the generated path' do
12
- section_path(1, :page => 2).should == '/sections/1/pages/2'
13
- end
14
-
15
- it 'appends the segments /pages/:page to the generated path excluding http get params' do
16
- section_path(1, :page => 2, :foo => 'bar').should == '/sections/1/pages/2?foo=bar'
17
- end
18
- end
19
- end
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe 'RoutingFilter::Pagination' do
4
+ include RoutingFilterHelpers
5
+
6
+ before :each do
7
+ setup_environment(:pagination)
8
+ end
9
+
10
+ describe 'url generation' do
11
+ it 'appends the segments /pages/:page to the generated path' do
12
+ section_path(1, :page => 2).should == '/sections/1/pages/2'
13
+ end
14
+
15
+ it 'appends the segments /pages/:page to the generated path excluding http get params' do
16
+ section_path(1, :page => 2, :foo => 'bar').should == '/sections/1/pages/2?foo=bar'
17
+ end
18
+ end
19
+ end
@@ -1,76 +1,76 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe 'RoutingFilter', 'url recognition' do
4
- include RoutingFilterHelpers
5
-
6
- before :each do
7
- setup_environment :locale, :pagination
8
- end
9
-
10
- it 'recognizes the path /de/sections/1 and sets the :locale param' do
11
- should_recognize_path '/de/sections/1', @section_params.update(:locale => 'de')
12
- end
13
-
14
- it 'recognizes the path /sections/1/pages/1 and sets the :page param' do
15
- should_recognize_path '/sections/1/pages/1', @section_params.update(:page => 1)
16
- end
17
-
18
- it 'recognizes the path /de/sections/1/pages/1 and sets the :locale param' do
19
- should_recognize_path '/de/sections/1/pages/1', @section_params.update(:locale => 'de', :page => 1)
20
- end
21
-
22
- it 'recognizes the path /sections/1/articles/1 and sets the :locale param' do
23
- should_recognize_path '/sections/1/articles/1', @article_params
24
- end
25
-
26
- it 'recognizes the path /de/sections/1/articles/1 and sets the :locale param' do
27
- should_recognize_path '/de/sections/1/articles/1', @article_params.update(:locale => 'de')
28
- end
29
-
30
- it 'recognizes the path /de/sections/1/articles/1/pages/1 and sets the :locale param' do
31
- should_recognize_path '/de/sections/1/articles/1/pages/1', @article_params.update(:locale => 'de', :page => 1)
32
- end
33
-
34
- it 'recognizes the path /sections/1 and does not set a :locale param' do
35
- should_recognize_path '/sections/1', @section_params
36
- end
37
-
38
- it 'recognizes the path /sections/1 and does not set a :page param' do
39
- should_recognize_path '/sections/1', @section_params
40
- end
41
-
42
- # Test that routing errors are thrown for invalid locales
43
- it 'does not recognizes the path /aa/sections/1 and does not set a :locale param' do
44
- begin
45
- should_recognize_path '/aa/sections/1', @section_params.update(:locale => 'aa')
46
- false
47
- rescue ActionController::RoutingError
48
- true
49
- end
50
- end
51
-
52
- it 'recognizes the path /en-US/sections/1 and sets a :locale param' do
53
- should_recognize_path '/en-US/sections/1', @section_params.update(:locale => 'en-US')
54
- end
55
-
56
- it 'recognizes the path /sections/1/articles/1 and does not set a :locale param' do
57
- should_recognize_path '/sections/1/articles/1', @article_params
58
- end
59
-
60
- it 'recognizes the path /sections/1/articles/1 and does not set a :page param' do
61
- should_recognize_path '/sections/1/articles/1', @article_params
62
- end
63
-
64
- it 'invalid locale: does not recognize the path /aa/sections/1/articles/1 and does not set a :locale param' do
65
- lambda { @set.recognize_path('/aa/sections/1/articles/1', {}) }.should raise_error(ActionController::RoutingError)
66
- end
67
-
68
- it 'recognizes the path /en-US/sections/1/articles/1 and sets a :locale param' do
69
- should_recognize_path '/en-US/sections/1/articles/1', @article_params.update(:locale => 'en-US')
70
- end
71
-
72
- it 'unescapes the path for the filters' do
73
- @set.should_receive(:recognize_path_without_filtering).with('/sections/motörhead', 'test')
74
- @set.recognize_path('/sections/mot%C3%B6rhead', 'test')
75
- end
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe 'RoutingFilter', 'url recognition' do
4
+ include RoutingFilterHelpers
5
+
6
+ before :each do
7
+ setup_environment :locale, :pagination
8
+ end
9
+
10
+ it 'recognizes the path /de/sections/1 and sets the :locale param' do
11
+ should_recognize_path '/de/sections/1', @section_params.update(:locale => 'de')
12
+ end
13
+
14
+ it 'recognizes the path /sections/1/pages/1 and sets the :page param' do
15
+ should_recognize_path '/sections/1/pages/1', @section_params.update(:page => 1)
16
+ end
17
+
18
+ it 'recognizes the path /de/sections/1/pages/1 and sets the :locale param' do
19
+ should_recognize_path '/de/sections/1/pages/1', @section_params.update(:locale => 'de', :page => 1)
20
+ end
21
+
22
+ it 'recognizes the path /sections/1/articles/1 and sets the :locale param' do
23
+ should_recognize_path '/sections/1/articles/1', @article_params
24
+ end
25
+
26
+ it 'recognizes the path /de/sections/1/articles/1 and sets the :locale param' do
27
+ should_recognize_path '/de/sections/1/articles/1', @article_params.update(:locale => 'de')
28
+ end
29
+
30
+ it 'recognizes the path /de/sections/1/articles/1/pages/1 and sets the :locale param' do
31
+ should_recognize_path '/de/sections/1/articles/1/pages/1', @article_params.update(:locale => 'de', :page => 1)
32
+ end
33
+
34
+ it 'recognizes the path /sections/1 and does not set a :locale param' do
35
+ should_recognize_path '/sections/1', @section_params
36
+ end
37
+
38
+ it 'recognizes the path /sections/1 and does not set a :page param' do
39
+ should_recognize_path '/sections/1', @section_params
40
+ end
41
+
42
+ # Test that routing errors are thrown for invalid locales
43
+ it 'does not recognizes the path /aa/sections/1 and does not set a :locale param' do
44
+ begin
45
+ should_recognize_path '/aa/sections/1', @section_params.update(:locale => 'aa')
46
+ false
47
+ rescue ActionController::RoutingError
48
+ true
49
+ end
50
+ end
51
+
52
+ it 'recognizes the path /en-US/sections/1 and sets a :locale param' do
53
+ should_recognize_path '/en-US/sections/1', @section_params.update(:locale => 'en-US')
54
+ end
55
+
56
+ it 'recognizes the path /sections/1/articles/1 and does not set a :locale param' do
57
+ should_recognize_path '/sections/1/articles/1', @article_params
58
+ end
59
+
60
+ it 'recognizes the path /sections/1/articles/1 and does not set a :page param' do
61
+ should_recognize_path '/sections/1/articles/1', @article_params
62
+ end
63
+
64
+ it 'invalid locale: does not recognize the path /aa/sections/1/articles/1 and does not set a :locale param' do
65
+ lambda { @set.recognize_path('/aa/sections/1/articles/1', {}) }.should raise_error(ActionController::RoutingError)
66
+ end
67
+
68
+ it 'recognizes the path /en-US/sections/1/articles/1 and sets a :locale param' do
69
+ should_recognize_path '/en-US/sections/1/articles/1', @article_params.update(:locale => 'en-US')
70
+ end
71
+
72
+ it 'unescapes the path for the filters' do
73
+ @set.should_receive(:recognize_path_without_filtering).with('/sections/motörhead', 'test')
74
+ @set.recognize_path('/sections/mot%C3%B6rhead', 'test')
75
+ end
76
76
  end
@@ -1,114 +1,114 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe 'RoutingFilter' do
4
- include RoutingFilterHelpers
5
-
6
- before :each do
7
- setup_environment :locale, :pagination
8
- end
9
-
10
- def recognize_path(path = '/de/sections/1', options = {})
11
- @set.recognize_path(path, options)
12
- end
13
-
14
- it 'installs filters to the route set' do
15
- @locale_filter.should be_instance_of(RoutingFilter::Locale)
16
- @pagination_filter.should be_instance_of(RoutingFilter::Pagination)
17
- end
18
-
19
- it 'calls the first filter for route recognition' do
20
- @locale_filter.should_receive(:around_recognize).and_return :foo => :bar
21
- recognize_path.should == { :foo => :bar }
22
- end
23
-
24
- it 'calls the second filter for route recognition' do
25
- @pagination_filter.should_receive(:around_recognize).and_return :foo => :bar
26
- recognize_path.should == { :foo => :bar, :locale => 'de' }
27
- end
28
-
29
- it 'calls the first filter for url generation' do
30
- @locale_filter.should_receive(:around_generate).and_return '/en/sections/1?page=2'
31
- url_for(:controller => 'sections', :action => 'show', :section_id => 1)
32
- end
33
-
34
- it 'calls the second filter for url generation' do
35
- @pagination_filter.should_receive(:around_generate).and_return '/sections/1?page=2'
36
- url_for(:controller => 'sections', :action => 'show', :section_id => 1)
37
- end
38
-
39
- it 'calls the first filter for named route url_helper' do
40
- @locale_filter.should_receive(:around_generate).and_return '/en/sections/1'
41
- section_path(:section_id => 1)
42
- end
43
-
44
- it 'calls the filter for named route url_helper with "optimized" generation blocks' do
45
- # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806)
46
- @locale_filter.should_receive(:around_generate).at_least(1).and_return '/en/sections/1'
47
- section_path(1)
48
- end
49
-
50
- it 'calls the filter for named route polymorphic_path' do
51
- # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806)
52
- @locale_filter.should_receive(:around_generate).at_least(1).and_return '/en/sections/1'
53
- section_path(Section.new)
54
- end
55
-
56
- # When filters are set up in the order:
57
- #
58
- # map.filter :locale
59
- # map.filter :pagination
60
- #
61
- # Then #around_recognize should be first called on the locale filter and then
62
- # on the pagination filter. Whereas #around_generate should be first called
63
- # on the pagination filter and then on the locale filter. Right?
64
-
65
- it 'calls #around_recognize in the expected order' do
66
- params = { :id => "1", :page => 2, :controller => "sections", :action => "show" }
67
- @pagination_filter.stub!(:around_recognize).and_return({ :page => 2, :controller => "sections", :action => "show" })
68
-
69
- recognize_path('/de/sections/1/pages/2')[:locale].should == "de"
70
- recognize_path('/de/sections/1/pages/2')[:page].should == 2
71
- end
72
-
73
- it 'calls #around_generate in the expected order' do
74
- @locale_filter.stub!(:around_generate).and_return('de/sections/1')
75
- section_path(1, :page => 2).should == "de/sections/1/pages/2"
76
- end
77
-
78
- it 'does not call deactivated filters' do
79
- with_deactivated_filters(RoutingFilter::Locale) do
80
- @locale_filter.should_not_receive(:around_generate)
81
- section_path(Section.new)
82
- end
83
- end
84
-
85
- it 'still calls successors of deactivated filters' do
86
- with_deactivated_filters(RoutingFilter::Locale) do
87
- @pagination_filter.should_receive(:around_recognize).and_return :foo => :bar
88
- recognize_path('/sections/1').should == { :foo => :bar }
89
- end
90
- end
91
-
92
- # chain
93
-
94
- it 'adds filters in the order they are registered' do
95
- @set.filters[0].should == @locale_filter
96
- @set.filters[1].should == @pagination_filter
97
- end
98
-
99
- it 'returns the previous filter as a predecessor of a filter' do
100
- @set.filters.predecessor(@pagination_filter).should == @locale_filter
101
- end
102
-
103
- it 'returns the nil as a predecessor of the first filter' do
104
- @set.filters.successor(@pagination_filter).should be_nil
105
- end
106
-
107
- it 'returns the next filter as a successor of a filter' do
108
- @set.filters.successor(@locale_filter).should == @pagination_filter
109
- end
110
-
111
- it 'returns the nil as a successor of the last filter' do
112
- @set.filters.successor(@pagination_filter).should be_nil
113
- end
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe 'RoutingFilter' do
4
+ include RoutingFilterHelpers
5
+
6
+ before :each do
7
+ setup_environment :locale, :pagination
8
+ end
9
+
10
+ def recognize_path(path = '/de/sections/1', options = {})
11
+ @set.recognize_path(path, options)
12
+ end
13
+
14
+ it 'installs filters to the route set' do
15
+ @locale_filter.should be_instance_of(RoutingFilter::Locale)
16
+ @pagination_filter.should be_instance_of(RoutingFilter::Pagination)
17
+ end
18
+
19
+ it 'calls the first filter for route recognition' do
20
+ @locale_filter.should_receive(:around_recognize).and_return :foo => :bar
21
+ recognize_path.should == { :foo => :bar }
22
+ end
23
+
24
+ it 'calls the second filter for route recognition' do
25
+ @pagination_filter.should_receive(:around_recognize).and_return :foo => :bar
26
+ recognize_path.should == { :foo => :bar, :locale => 'de' }
27
+ end
28
+
29
+ it 'calls the first filter for url generation' do
30
+ @locale_filter.should_receive(:around_generate).and_return '/en/sections/1?page=2'
31
+ url_for(:controller => 'sections', :action => 'show', :section_id => 1)
32
+ end
33
+
34
+ it 'calls the second filter for url generation' do
35
+ @pagination_filter.should_receive(:around_generate).and_return '/sections/1?page=2'
36
+ url_for(:controller => 'sections', :action => 'show', :section_id => 1)
37
+ end
38
+
39
+ it 'calls the first filter for named route url_helper' do
40
+ @locale_filter.should_receive(:around_generate).and_return '/en/sections/1'
41
+ section_path(:section_id => 1)
42
+ end
43
+
44
+ it 'calls the filter for named route url_helper with "optimized" generation blocks' do
45
+ # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806)
46
+ @locale_filter.should_receive(:around_generate).at_least(1).and_return '/en/sections/1'
47
+ section_path(1)
48
+ end
49
+
50
+ it 'calls the filter for named route polymorphic_path' do
51
+ # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806)
52
+ @locale_filter.should_receive(:around_generate).at_least(1).and_return '/en/sections/1'
53
+ section_path(Section.new)
54
+ end
55
+
56
+ # When filters are set up in the order:
57
+ #
58
+ # map.filter :locale
59
+ # map.filter :pagination
60
+ #
61
+ # Then #around_recognize should be first called on the locale filter and then
62
+ # on the pagination filter. Whereas #around_generate should be first called
63
+ # on the pagination filter and then on the locale filter. Right?
64
+
65
+ it 'calls #around_recognize in the expected order' do
66
+ params = { :id => "1", :page => 2, :controller => "sections", :action => "show" }
67
+ @pagination_filter.stub!(:around_recognize).and_return({ :page => 2, :controller => "sections", :action => "show" })
68
+
69
+ recognize_path('/de/sections/1/pages/2')[:locale].should == "de"
70
+ recognize_path('/de/sections/1/pages/2')[:page].should == 2
71
+ end
72
+
73
+ it 'calls #around_generate in the expected order' do
74
+ @locale_filter.stub!(:around_generate).and_return('de/sections/1')
75
+ section_path(1, :page => 2).should == "de/sections/1/pages/2"
76
+ end
77
+
78
+ it 'does not call deactivated filters' do
79
+ with_deactivated_filters(RoutingFilter::Locale) do
80
+ @locale_filter.should_not_receive(:around_generate)
81
+ section_path(Section.new)
82
+ end
83
+ end
84
+
85
+ it 'still calls successors of deactivated filters' do
86
+ with_deactivated_filters(RoutingFilter::Locale) do
87
+ @pagination_filter.should_receive(:around_recognize).and_return :foo => :bar
88
+ recognize_path('/sections/1').should == { :foo => :bar }
89
+ end
90
+ end
91
+
92
+ # chain
93
+
94
+ it 'adds filters in the order they are registered' do
95
+ @set.filters[0].should == @locale_filter
96
+ @set.filters[1].should == @pagination_filter
97
+ end
98
+
99
+ it 'returns the previous filter as a predecessor of a filter' do
100
+ @set.filters.predecessor(@pagination_filter).should == @locale_filter
101
+ end
102
+
103
+ it 'returns the nil as a predecessor of the first filter' do
104
+ @set.filters.successor(@pagination_filter).should be_nil
105
+ end
106
+
107
+ it 'returns the next filter as a successor of a filter' do
108
+ @set.filters.successor(@locale_filter).should == @pagination_filter
109
+ end
110
+
111
+ it 'returns the nil as a successor of the last filter' do
112
+ @set.filters.successor(@pagination_filter).should be_nil
113
+ end
114
114
  end
@@ -1,4 +1,4 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -1,108 +1,108 @@
1
- $: << File.dirname(__FILE__)
2
- $: << File.dirname(__FILE__) + '/../lib/'
3
-
4
- require 'rubygems'
5
- require 'actionpack'
6
- require 'activesupport'
7
- require 'action_controller'
8
- require 'action_controller/test_process'
9
- require 'active_support/vendor'
10
- require 'spec'
11
-
12
- require 'routing_filter'
13
- require 'routing_filter/locale'
14
- require 'routing_filter/pagination'
15
-
16
- class Site
17
- end
18
-
19
- class Section
20
- def id; 1 end
21
- alias :to_param :id
22
- def type; 'Section' end
23
- def path; 'section' end
24
- end
25
-
26
- class Article
27
- def to_param; 1 end
28
- end
29
-
30
- module RoutingFilterHelpers
31
- def draw_routes(&block)
32
- set = returning ActionController::Routing::RouteSet.new do |set|
33
- class << set; def clear!; end; end
34
- set.draw &block
35
- silence_warnings{ ActionController::Routing.const_set 'Routes', set }
36
- end
37
- set
38
- end
39
-
40
- def instantiate_controller(params)
41
- returning ActionController::Base.new do |controller|
42
- request = ActionController::TestRequest.new
43
- url = ActionController::UrlRewriter.new(request, params)
44
- controller.stub!(:request).and_return request
45
- controller.instance_variable_set :@url, url
46
- controller
47
- end
48
- end
49
-
50
- def should_recognize_path(path, params)
51
- @set.recognize_path(path, {}).should == params
52
- end
53
-
54
- def home_path(*args)
55
- @controller.send :home_path, *args
56
- end
57
-
58
- def home_url(*args)
59
- @controller.send :home_url, *args
60
- end
61
-
62
- def section_path(*args)
63
- @controller.send :section_path, *args
64
- end
65
-
66
- def section_article_path(*args)
67
- @controller.send :section_article_path, *args
68
- end
69
-
70
- def admin_articles_path(*args)
71
- @controller.send :admin_articles_path, *args
72
- end
73
-
74
- def url_for(*args)
75
- @controller.send :url_for, *args
76
- end
77
-
78
- def setup_environment(*filters)
79
- RoutingFilter::Locale.locales = [:en, 'en-US', :de, :fi, 'en-UK']
80
- RoutingFilter::Locale.include_default_locale = true
81
- I18n.default_locale = :en
82
- I18n.locale = :en
83
-
84
- @controller = instantiate_controller :locale => 'de', :id => 1
85
- @set = draw_routes do |map|
86
- yield map if block_given?
87
- filters.each { |filter| map.filter filter }
88
- map.section 'sections/:id.:format', :controller => 'sections', :action => "show"
89
- map.section_article 'sections/:section_id/articles/:id', :controller => 'articles', :action => "show"
90
- map.admin_articles 'admin/articles/:id', :controller => 'admin/articles', :action => "index"
91
- map.home '/', :controller => 'home', :action => 'index'
92
- end
93
-
94
- @section_params = {:controller => 'sections', :action => "show", :id => "1"}
95
- @article_params = {:controller => 'articles', :action => "show", :section_id => "1", :id => "1"}
96
- @locale_filter = @set.filters.first
97
- @pagination_filter = @set.filters.last
98
- end
99
-
100
- def with_deactivated_filters(*filters, &block)
101
- states = filters.inject({}) do |states, filter|
102
- states[filter], filter.active = filter.active, false
103
- states
104
- end
105
- yield
106
- states.each { |filter, state| filter.active = state }
107
- end
1
+ $: << File.dirname(__FILE__)
2
+ $: << File.dirname(__FILE__) + '/../lib/'
3
+
4
+ require 'rubygems'
5
+ require 'actionpack'
6
+ require 'activesupport'
7
+ require 'action_controller'
8
+ require 'action_controller/test_process'
9
+ require 'active_support/vendor'
10
+ require 'spec'
11
+
12
+ require 'routing_filter'
13
+ require 'routing_filter/locale'
14
+ require 'routing_filter/pagination'
15
+
16
+ class Site
17
+ end
18
+
19
+ class Section
20
+ def id; 1 end
21
+ alias :to_param :id
22
+ def type; 'Section' end
23
+ def path; 'section' end
24
+ end
25
+
26
+ class Article
27
+ def to_param; 1 end
28
+ end
29
+
30
+ module RoutingFilterHelpers
31
+ def draw_routes(&block)
32
+ set = returning ActionController::Routing::RouteSet.new do |set|
33
+ class << set; def clear!; end; end
34
+ set.draw &block
35
+ silence_warnings{ ActionController::Routing.const_set 'Routes', set }
36
+ end
37
+ set
38
+ end
39
+
40
+ def instantiate_controller(params)
41
+ returning ActionController::Base.new do |controller|
42
+ request = ActionController::TestRequest.new
43
+ url = ActionController::UrlRewriter.new(request, params)
44
+ controller.stub!(:request).and_return request
45
+ controller.instance_variable_set :@url, url
46
+ controller
47
+ end
48
+ end
49
+
50
+ def should_recognize_path(path, params)
51
+ @set.recognize_path(path, {}).should == params
52
+ end
53
+
54
+ def home_path(*args)
55
+ @controller.send :home_path, *args
56
+ end
57
+
58
+ def home_url(*args)
59
+ @controller.send :home_url, *args
60
+ end
61
+
62
+ def section_path(*args)
63
+ @controller.send :section_path, *args
64
+ end
65
+
66
+ def section_article_path(*args)
67
+ @controller.send :section_article_path, *args
68
+ end
69
+
70
+ def admin_articles_path(*args)
71
+ @controller.send :admin_articles_path, *args
72
+ end
73
+
74
+ def url_for(*args)
75
+ @controller.send :url_for, *args
76
+ end
77
+
78
+ def setup_environment(*filters)
79
+ RoutingFilter::Locale.locales = [:en, 'en-US', :de, :fi, 'en-UK']
80
+ RoutingFilter::Locale.include_default_locale = true
81
+ I18n.default_locale = :en
82
+ I18n.locale = :en
83
+
84
+ @controller = instantiate_controller :locale => 'de', :id => 1
85
+ @set = draw_routes do |map|
86
+ yield map if block_given?
87
+ filters.each { |filter| map.filter filter }
88
+ map.section 'sections/:id.:format', :controller => 'sections', :action => "show"
89
+ map.section_article 'sections/:section_id/articles/:id', :controller => 'articles', :action => "show"
90
+ map.admin_articles 'admin/articles/:id', :controller => 'admin/articles', :action => "index"
91
+ map.home '/', :controller => 'home', :action => 'index'
92
+ end
93
+
94
+ @section_params = {:controller => 'sections', :action => "show", :id => "1"}
95
+ @article_params = {:controller => 'articles', :action => "show", :section_id => "1", :id => "1"}
96
+ @locale_filter = @set.filters.first
97
+ @pagination_filter = @set.filters.last
98
+ end
99
+
100
+ def with_deactivated_filters(*filters, &block)
101
+ states = filters.inject({}) do |states, filter|
102
+ states[filter], filter.active = filter.active, false
103
+ states
104
+ end
105
+ yield
106
+ states.each { |filter, state| filter.active = state }
107
+ end
108
108
  end