mislav-will_paginate 2.3.1 → 2.3.2

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.2, released 2008-05-16
2
+
3
+ * Fixed LinkRenderer#stringified_merge by removing "return" from iterator block
4
+ * Ensure that 'href' values in pagination links are escaped URLs
5
+
1
6
  == 2.3.1, released 2008-05-04
2
7
 
3
8
  * Fixed page numbers not showing with custom routes and implicit first page
data/README.rdoc CHANGED
@@ -22,11 +22,7 @@ Some resources to get you started:
22
22
 
23
23
  The recommended way is that you get the gem:
24
24
 
25
- # add GitHub to your local list of gem sources:
26
- gem sources -a http://gems.github.com/
27
-
28
- # install the gem:
29
- gem install mislav-will_paginate
25
+ gem install mislav-will_paginate --source http://gems.github.com/
30
26
 
31
27
  After that you don't need the will_paginate <i>plugin</i> in your Rails
32
28
  application anymore. Just add a simple require to the end of
@@ -1,8 +1,8 @@
1
- module WillPaginate #:nodoc:
2
- module VERSION #:nodoc:
1
+ module WillPaginate
2
+ module VERSION
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -299,7 +299,7 @@ module WillPaginate
299
299
  def url_for(page)
300
300
  page_one = page == 1
301
301
  unless @url_string and !page_one
302
- @url_params = { :escape => false }
302
+ @url_params = {}
303
303
  # page links should preserve GET parameters
304
304
  stringified_merge @url_params, @template.params if @template.request.get?
305
305
  stringified_merge @url_params, @options[:params] if @options[:params]
@@ -317,7 +317,7 @@ module WillPaginate
317
317
  return url if page_one
318
318
 
319
319
  if complex
320
- @url_string = url.sub(%r!([?&]#{CGI.escape param_name}=)#{page}!, '\1@')
320
+ @url_string = url.sub(%r!((?:\?|&amp;)#{CGI.escape param_name}=)#{page}!, '\1@')
321
321
  return url
322
322
  else
323
323
  @url_string = url
@@ -356,20 +356,17 @@ module WillPaginate
356
356
  @param_name ||= @options[:param_name].to_s
357
357
  end
358
358
 
359
+ # Recursively merge into target hash by using stringified keys from the other one
359
360
  def stringified_merge(target, other)
360
361
  other.each do |key, value|
361
- key = key.to_s
362
+ key = key.to_s # this line is what it's all about!
362
363
  existing = target[key]
363
364
 
364
- if value.is_a?(Hash)
365
- target[key] = existing = {} if existing.nil?
366
- if existing.is_a?(Hash)
367
- stringified_merge(existing, value)
368
- return
369
- end
365
+ if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)
366
+ stringified_merge(existing || (target[key] = {}), value)
367
+ else
368
+ target[key] = value
370
369
  end
371
-
372
- target[key] = value
373
370
  end
374
371
  end
375
372
  end
data/test/tasks.rake ADDED
@@ -0,0 +1,56 @@
1
+ require 'rake/testtask'
2
+
3
+ desc 'Test the will_paginate plugin.'
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.pattern = 'test/**/*_test.rb'
6
+ t.verbose = true
7
+ t.libs << 'test'
8
+ end
9
+
10
+ # I want to specify environment variables at call time
11
+ class EnvTestTask < Rake::TestTask
12
+ attr_accessor :env
13
+
14
+ def ruby(*args)
15
+ env.each { |key, value| ENV[key] = value } if env
16
+ super
17
+ env.keys.each { |key| ENV.delete key } if env
18
+ end
19
+ end
20
+
21
+ for configuration in %w( sqlite3 mysql postgres )
22
+ EnvTestTask.new("test_#{configuration}") do |t|
23
+ t.pattern = 'test/finder_test.rb'
24
+ t.verbose = true
25
+ t.env = { 'DB' => configuration }
26
+ t.libs << 'test'
27
+ end
28
+ end
29
+
30
+ task :test_databases => %w(test_mysql test_sqlite3 test_postgres)
31
+
32
+ desc %{Test everything on SQLite3, MySQL and PostgreSQL}
33
+ task :test_full => %w(test test_mysql test_postgres)
34
+
35
+ desc %{Test everything with Rails 1.2.x and 2.0.x gems}
36
+ task :test_all do
37
+ all = Rake::Task['test_full']
38
+ ENV['RAILS_VERSION'] = '~>1.2.6'
39
+ all.invoke
40
+ # reset the invoked flag
41
+ %w( test_full test test_mysql test_postgres ).each do |name|
42
+ Rake::Task[name].instance_variable_set '@already_invoked', false
43
+ end
44
+ # do it again
45
+ ENV['RAILS_VERSION'] = '~>2.0.2'
46
+ all.invoke
47
+ end
48
+
49
+ task :rcov do
50
+ excludes = %w( lib/will_paginate/named_scope*
51
+ lib/will_paginate/core_ext.rb
52
+ lib/will_paginate.rb
53
+ rails* )
54
+
55
+ system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}]
56
+ end
data/test/view_test.rb CHANGED
@@ -95,6 +95,16 @@ class ViewTest < WillPaginate::ViewTestCase
95
95
  assert_dom_equal expected, @html_result
96
96
  end
97
97
 
98
+ def test_escaping_of_urls
99
+ paginate({:page => 1, :per_page => 1, :total_entries => 2},
100
+ :page_links => false, :params => { :tag => '<br>' })
101
+
102
+ assert_select 'a[href]', 1 do |links|
103
+ query = links.first['href'].split('?', 2)[1]
104
+ assert_equal %w(page=2 tag=%3Cbr%3E), query.split('&amp;').sort
105
+ end
106
+ end
107
+
98
108
  ## advanced options for pagination ##
99
109
 
100
110
  def test_will_paginate_without_container
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.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Mislav Marohni\xC4\x87"
@@ -10,10 +10,18 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-05-04 00:00:00 -07:00
13
+ date: 2008-05-16 00:00:00 -07:00
14
14
  default_executable:
15
- dependencies: []
16
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.4
24
+ version:
17
25
  description: The will_paginate library provides a simple, yet powerful and extensible API for ActiveRecord pagination and rendering of pagination links in ActionView templates.
18
26
  email: mislav.marohnic@gmail.com
19
27
  executables: []
@@ -72,6 +80,7 @@ files:
72
80
  - test/lib/activerecord_test_connector.rb
73
81
  - test/lib/load_fixtures.rb
74
82
  - test/lib/view_test_process.rb
83
+ - test/tasks.rake
75
84
  - test/view_test.rb
76
85
  has_rdoc: true
77
86
  homepage: http://github.com/mislav/will_paginate/wikis
@@ -127,4 +136,5 @@ test_files:
127
136
  - test/lib/activerecord_test_connector.rb
128
137
  - test/lib/load_fixtures.rb
129
138
  - test/lib/view_test_process.rb
139
+ - test/tasks.rake
130
140
  - test/view_test.rb