routing-filter 0.0.1 → 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.
- data/lib/routing_filter/adapters/rails_2.rb +69 -0
- data/lib/routing_filter/adapters/rails_3.rb +64 -0
- data/lib/routing_filter/chain.rb +16 -0
- data/lib/routing_filter/filter.rb +19 -0
- data/lib/routing_filter/{force_extension.rb → filters/extension.rb} +35 -16
- data/lib/routing_filter/{locale.rb → filters/locale.rb} +33 -14
- data/lib/routing_filter/filters/pagination.rb +51 -0
- data/lib/routing_filter/filters/uuid.rb +52 -0
- data/lib/routing_filter/version.rb +3 -0
- data/lib/routing_filter.rb +18 -85
- metadata +65 -38
- data/.gitignore +0 -1
- data/MIT-LICENSE +0 -20
- data/README.markdown +0 -123
- data/VERSION +0 -1
- data/init.rb +0 -1
- data/lib/routing_filter/base.rb +0 -31
- data/lib/routing_filter/pagination.rb +0 -33
- data/spec/force_extension_spec.rb +0 -65
- data/spec/generation_spec.rb +0 -367
- data/spec/pagination_extension_spec.rb +0 -19
- data/spec/recognition_spec.rb +0 -76
- data/spec/routing_filter_spec.rb +0 -114
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -108
data/spec/spec_helper.rb
DELETED
@@ -1,108 +0,0 @@
|
|
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
|
-
end
|