mislav-will_paginate 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 2.3.1, released 2008-05-04
2
+
3
+ * Fixed page numbers not showing with custom routes and implicit first page
4
+ * Try to use Hanna for documentation (falls back to default RDoc template if not)
5
+
1
6
  == 2.3.0, released 2008-04-29
2
7
 
3
8
  * Changed LinkRenderer to receive collection, options and reference to view template NOT in
data/Rakefile CHANGED
@@ -1,74 +1,30 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
1
+ require 'rubygems'
2
+ begin
3
+ hanna_dir = '/home/mislav/projects/hanna/lib'
4
+ $:.unshift hanna_dir if File.exists? hanna_dir
5
+ require 'hanna/rdoctask'
6
+ rescue LoadError
7
+ require 'rake'
8
+ require 'rake/rdoctask'
9
+ end
10
+ load 'test/tasks.rake'
4
11
 
5
12
  desc 'Default: run unit tests.'
6
13
  task :default => :test
7
14
 
8
- desc 'Test the will_paginate plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.pattern = 'test/**/*_test.rb'
11
- t.verbose = true
12
- t.libs << 'test'
13
- end
14
-
15
- # I want to specify environment variables at call time
16
- class EnvTestTask < Rake::TestTask
17
- attr_accessor :env
18
-
19
- def ruby(*args)
20
- env.each { |key, value| ENV[key] = value } if env
21
- super
22
- env.keys.each { |key| ENV.delete key } if env
23
- end
24
- end
25
-
26
- for configuration in %w( sqlite3 mysql postgres )
27
- EnvTestTask.new("test_#{configuration}") do |t|
28
- t.pattern = 'test/finder_test.rb'
29
- t.verbose = true
30
- t.env = { 'DB' => configuration }
31
- t.libs << 'test'
32
- end
33
- end
34
-
35
- task :test_databases => %w(test_mysql test_sqlite3 test_postgres)
36
-
37
- desc %{Test everything on SQLite3, MySQL and PostgreSQL}
38
- task :test_full => %w(test test_mysql test_postgres)
39
-
40
- desc %{Test everything with Rails 1.2.x and 2.0.x gems}
41
- task :test_all do
42
- all = Rake::Task['test_full']
43
- ENV['RAILS_VERSION'] = '~>1.2.6'
44
- all.invoke
45
- # reset the invoked flag
46
- %w( test_full test test_mysql test_postgres ).each do |name|
47
- Rake::Task[name].instance_variable_set '@already_invoked', false
48
- end
49
- # do it again
50
- ENV['RAILS_VERSION'] = '~>2.0.2'
51
- all.invoke
52
- end
53
-
54
15
  desc 'Generate RDoc documentation for the will_paginate plugin.'
55
16
  Rake::RDocTask.new(:rdoc) do |rdoc|
56
- files = ['README.rdoc', 'LICENSE', 'CHANGELOG']
57
- files << FileList.new('lib/**/*.rb').
17
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG').
18
+ include('lib/**/*.rb').
58
19
  exclude('lib/will_paginate/named_scope*').
59
20
  exclude('lib/will_paginate/array.rb').
60
21
  exclude('lib/will_paginate/version.rb')
61
-
62
- rdoc.rdoc_files.add(files)
22
+
63
23
  rdoc.main = "README.rdoc" # page to start on
64
24
  rdoc.title = "will_paginate documentation"
65
25
 
66
- templates = %w[/Users/chris/ruby/projects/err/rock/template.rb /var/www/rock/template.rb]
67
- rdoc.template = templates.find { |t| File.exists? t }
68
-
69
26
  rdoc.rdoc_dir = 'doc' # rdoc output folder
70
- rdoc.options << '--inline-source'
71
- rdoc.options << '--charset=UTF-8'
27
+ rdoc.options << '--inline-source' << '--charset=UTF-8'
72
28
  rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
73
29
  end
74
30
 
@@ -104,12 +60,3 @@ task :examples do
104
60
  %x(haml examples/index.haml examples/index.html)
105
61
  %x(sass examples/pagination.sass examples/pagination.css)
106
62
  end
107
-
108
- task :rcov do
109
- excludes = %w( lib/will_paginate/named_scope*
110
- lib/will_paginate/core_ext.rb
111
- lib/will_paginate.rb
112
- rails* )
113
-
114
- system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}]
115
- end
@@ -2,7 +2,7 @@ module WillPaginate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -297,7 +297,8 @@ module WillPaginate
297
297
  # Returns URL params for +page_link_or_span+, taking the current GET params
298
298
  # and <tt>:params</tt> option into account.
299
299
  def url_for(page)
300
- unless @url_string
300
+ page_one = page == 1
301
+ unless @url_string and !page_one
301
302
  @url_params = { :escape => false }
302
303
  # page links should preserve GET parameters
303
304
  stringified_merge @url_params, @template.params if @template.request.get?
@@ -309,19 +310,20 @@ module WillPaginate
309
310
 
310
311
  stringified_merge @url_params, page_param
311
312
  else
312
- @url_params[param_name] = 1
313
+ @url_params[param_name] = page_one ? 1 : 2
313
314
  end
314
315
 
315
316
  url = @template.url_for(@url_params)
317
+ return url if page_one
316
318
 
317
319
  if complex
318
320
  @url_string = url.sub(%r!([?&]#{CGI.escape param_name}=)#{page}!, '\1@')
319
321
  return url
320
322
  else
321
323
  @url_string = url
322
- @url_params[param_name] = 2
324
+ @url_params[param_name] = 3
323
325
  @template.url_for(@url_params).split(//).each_with_index do |char, i|
324
- if char == '2' and url[i, 1] == '1'
326
+ if char == '3' and url[i, 1] == '2'
325
327
  @url_string[i] = '@'
326
328
  break
327
329
  end
@@ -7,6 +7,10 @@ WillPaginate.enable_actionpack
7
7
  ActionController::Routing::Routes.draw do |map|
8
8
  map.connect 'dummy/page/:page', :controller => 'dummy'
9
9
  map.connect 'dummy/dots/page.:page', :controller => 'dummy', :action => 'dots'
10
+ map.connect 'ibocorp/:page', :controller => 'ibocorp',
11
+ :requirements => { :page => /\d+/ },
12
+ :defaults => { :page => 1 }
13
+
10
14
  map.connect ':controller/:action/:id'
11
15
  end
12
16
 
@@ -79,7 +83,7 @@ class WillPaginate::ViewTestCase < Test::Unit::TestCase
79
83
  assert_match pattern, el['href']
80
84
  if numbers
81
85
  el['href'] =~ pattern
82
- pages << $1.to_i
86
+ pages << ($1.nil?? nil : $1.to_i)
83
87
  end
84
88
  end
85
89
 
data/test/view_test.rb CHANGED
@@ -287,6 +287,15 @@ class ViewTest < WillPaginate::ViewTestCase
287
287
  end
288
288
  end
289
289
 
290
+ def test_custom_routing_with_first_page_hidden
291
+ @request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil
292
+ paginate :page => 2, :per_page => 2 do
293
+ assert_select 'a[href]', 7 do |links|
294
+ assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3]
295
+ end
296
+ end
297
+ end
298
+
290
299
  ## internal hardcore stuff ##
291
300
 
292
301
  class LegacyCollection < WillPaginate::Collection
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mislav-will_paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Mislav Marohni\xC4\x87"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-04-26 00:00:00 -07:00
13
+ date: 2008-05-04 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16