Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
commit 39a29aeaea9636d43f4ceb2c0f6cc596ce795056 2 parents fc5e5ab + 71f793e
@keating authored
View
1  .travis.yml
@@ -5,3 +5,4 @@ rvm:
gemfile:
- Gemfile
- Gemfile.rails3.0
+ - Gemfile.rails3.1
View
6 Gemfile
@@ -1,9 +1,9 @@
source 'http://rubygems.org'
-rails_version = '~> 3.1.1.rc'
+rails_version = '~> 3.2.0'
-gem 'activerecord', rails_version
-gem 'actionpack', rails_version
+gem 'activerecord', rails_version
+gem 'actionpack', rails_version
gem 'rake'
gem 'rspec', '~> 2.6.0'
View
97 Gemfile.lock
@@ -1,70 +1,71 @@
GEM
remote: http://rubygems.org/
specs:
- actionpack (3.1.1.rc1)
- activemodel (= 3.1.1.rc1)
- activesupport (= 3.1.1.rc1)
+ actionpack (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
- i18n (~> 0.6)
- rack (~> 1.3.2)
- rack-cache (~> 1.0.3)
- rack-mount (~> 0.8.2)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
rack-test (~> 0.6.1)
- sprockets (~> 2.0.0)
- activemodel (3.1.1.rc1)
- activesupport (= 3.1.1.rc1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.1)
+ activesupport (= 3.2.1)
builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.1.rc1)
- activemodel (= 3.1.1.rc1)
- activesupport (= 3.1.1.rc1)
- arel (~> 2.2.1)
+ activerecord (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ arel (~> 3.0.0)
tzinfo (~> 0.3.29)
- activesupport (3.1.1.rc1)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.6)
archive-tar-minitar (0.5.2)
- arel (2.2.1)
+ arel (3.0.0)
builder (3.0.0)
- columnize (0.3.4)
- data_objects (0.10.6)
+ columnize (0.3.5)
+ data_objects (0.10.7)
addressable (~> 2.1)
diff-lcs (1.1.3)
- dm-aggregates (1.1.0)
- dm-core (~> 1.1.0)
- dm-core (1.1.0)
- addressable (~> 2.2.4)
- dm-do-adapter (1.1.0)
- data_objects (~> 0.10.2)
- dm-core (~> 1.1.0)
- dm-migrations (1.1.0)
- dm-core (~> 1.1.0)
- dm-sqlite-adapter (1.1.0)
- dm-do-adapter (~> 1.1.0)
- do_sqlite3 (~> 0.10.2)
- do_sqlite3 (0.10.6)
- data_objects (= 0.10.6)
+ dm-aggregates (1.2.0)
+ dm-core (~> 1.2.0)
+ dm-core (1.2.0)
+ addressable (~> 2.2.6)
+ dm-do-adapter (1.2.0)
+ data_objects (~> 0.10.6)
+ dm-core (~> 1.2.0)
+ dm-migrations (1.2.0)
+ dm-core (~> 1.2.0)
+ dm-sqlite-adapter (1.2.0)
+ dm-do-adapter (~> 1.2.0)
+ do_sqlite3 (~> 0.10.6)
+ do_sqlite3 (0.10.7)
+ data_objects (= 0.10.7)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
+ journey (1.0.1)
linecache (0.46)
rbx-require-relative (> 0.0.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mocha (0.9.12)
- multi_json (1.0.3)
+ multi_json (1.0.4)
mysql (2.8.1)
- mysql2 (0.3.7)
- pg (0.11.0)
- rack (1.3.3)
- rack-cache (1.0.3)
+ mysql2 (0.3.11)
+ pg (0.12.0)
+ rake-compiler (~> 0.7)
+ rack (1.4.1)
+ rack-cache (1.1)
rack (>= 0.4)
- rack-mount (0.8.3)
- rack (>= 1.0.0)
rack-test (0.6.1)
rack (>= 1.0)
- rake (0.9.2)
+ rake (0.9.2.2)
+ rake-compiler (0.7.9)
+ rake
rbx-require-relative (0.0.5)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -89,21 +90,21 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
- sequel (3.27.0)
- sprockets (2.0.0)
+ sequel (3.30.0)
+ sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
- tilt (!= 1.3.0, ~> 1.1)
- sqlite3 (1.3.4)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
tilt (1.3.3)
- tzinfo (0.3.29)
+ tzinfo (0.3.31)
PLATFORMS
ruby
DEPENDENCIES
- actionpack (~> 3.1.1.rc)
- activerecord (~> 3.1.1.rc)
+ actionpack (~> 3.2.0)
+ activerecord (~> 3.2.0)
dm-aggregates
dm-core
dm-migrations
View
28 Gemfile.rails3.1
@@ -0,0 +1,28 @@
+source 'http://rubygems.org'
+
+rails_version = '~> 3.1.0'
+
+gem 'activerecord', rails_version
+gem 'actionpack', rails_version
+
+gem 'rake'
+gem 'rspec', '~> 2.6.0'
+gem 'mocha', '~> 0.9.8'
+
+gem 'sequel', '~> 3.8'
+gem 'sqlite3', '~> 1.3.3'
+gem 'dm-core'
+gem 'dm-aggregates'
+gem 'dm-migrations'
+gem 'dm-sqlite-adapter'
+
+group :mysql do
+ gem 'mysql', '~> 2.8.1'
+ gem 'mysql2', '>= 0.3.6'
+end
+gem 'pg', '~> 0.11', :group => :pg
+
+group :debug do
+ gem 'ruby-debug', :platforms => :mri_18
+ gem 'ruby-debug19', :platforms => :mri_19
+end unless ENV['TRAVIS']
View
123 Gemfile.rails3.1.lock
@@ -0,0 +1,123 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ addressable (2.2.6)
+ archive-tar-minitar (0.5.2)
+ arel (2.2.1)
+ builder (3.0.0)
+ columnize (0.3.6)
+ data_objects (0.10.7)
+ addressable (~> 2.1)
+ diff-lcs (1.1.3)
+ dm-aggregates (1.2.0)
+ dm-core (~> 1.2.0)
+ dm-core (1.2.0)
+ addressable (~> 2.2.6)
+ dm-do-adapter (1.2.0)
+ data_objects (~> 0.10.6)
+ dm-core (~> 1.2.0)
+ dm-migrations (1.2.0)
+ dm-core (~> 1.2.0)
+ dm-sqlite-adapter (1.2.0)
+ dm-do-adapter (~> 1.2.0)
+ do_sqlite3 (~> 0.10.6)
+ do_sqlite3 (0.10.7)
+ data_objects (= 0.10.7)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mocha (0.9.12)
+ multi_json (1.0.4)
+ mysql (2.8.1)
+ mysql2 (0.3.11)
+ pg (0.12.0)
+ rake-compiler (~> 0.7)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rake (0.9.2.2)
+ rake-compiler (0.7.9)
+ rake
+ rbx-require-relative (0.0.5)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ sequel (3.30.0)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ tilt (1.3.3)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ actionpack (~> 3.1.0)
+ activerecord (~> 3.1.0)
+ dm-aggregates
+ dm-core
+ dm-migrations
+ dm-sqlite-adapter
+ mocha (~> 0.9.8)
+ mysql (~> 2.8.1)
+ mysql2 (>= 0.3.6)
+ pg (~> 0.11)
+ rake
+ rspec (~> 2.6.0)
+ ruby-debug
+ ruby-debug19
+ sequel (~> 3.8)
+ sqlite3 (~> 1.3.3)
View
14 lib/will_paginate/data_mapper.rb
@@ -51,7 +51,9 @@ def total_entries
if loaded? and @array.size < per_page and (current_page == 1 or @array.size > 0)
offset + @array.size
else
- clean_query = query.merge(:order => [])
+ # :reload prevents Collection.filter from being run, which
+ # would cause a stack overflow
+ clean_query = query.merge(:reload => true)
# seems like the only way
clean_query.instance_variable_set('@limit', nil)
clean_query.instance_variable_set('@offset', 0)
@@ -61,9 +63,13 @@ def total_entries
end
def to_a
- ::WillPaginate::Collection.create(current_page, per_page) do |col|
- col.replace super
- col.total_entries ||= total_entries
+ if paginated?
+ ::WillPaginate::Collection.create(current_page, per_page) do |col|
+ col.replace super
+ col.total_entries ||= total_entries
+ end
+ else
+ super
end
end
View
13 lib/will_paginate/railtie.rb
@@ -25,7 +25,9 @@ class Railtie < Rails::Railtie
end
def self.setup_actioncontroller
- ActionDispatch::ShowExceptions.send :include, ShowExceptionsPatch
+ ( defined?(ActionDispatch::ExceptionWrapper) ?
+ ActionDispatch::ExceptionWrapper : ActionDispatch::ShowExceptions
+ ).send :include, ShowExceptionsPatch
ActionController::Base.extend ControllerRescuePatch
end
@@ -39,13 +41,18 @@ module ShowExceptionsPatch
extend ActiveSupport::Concern
included { alias_method_chain :status_code, :paginate }
private
- def status_code_with_paginate(exception)
+ def status_code_with_paginate(exception = @exception)
if exception.is_a?(WillPaginate::InvalidPage) or
(exception.respond_to?(:original_exception) &&
exception.original_exception.is_a?(WillPaginate::InvalidPage))
Rack::Utils.status_code(:not_found)
else
- status_code_without_paginate(exception)
+ original_method = method(:status_code_without_paginate)
+ if original_method.arity != 0
+ original_method.call(exception)
+ else
+ original_method.call()
+ end
end
end
end
View
2  lib/will_paginate/version.rb
@@ -2,7 +2,7 @@ module WillPaginate #:nodoc:
module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
- TINY = 2
+ TINY = 3
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
3  spec/finders/active_record_spec.rb
@@ -279,7 +279,8 @@
end
it "should paginate with :conditions" do
- result = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago]
+ result = Topic.paginate :page => 1, :order => 'id ASC',
+ :conditions => ["created_at > ?", 30.minutes.ago]
result.should == topics(:rails, :ar)
result.total_pages.should == 1
end
View
20 spec/finders/data_mapper_spec.rb
@@ -80,4 +80,24 @@
Animal.all(:conditions => ['1=2']).page(1).total_pages.should == 1
end
+ it "can iterate and then call WP methods" do
+ animals = Animal.all(:limit => 2).page(1)
+ animals.each { |a| }
+ animals.total_entries.should == 3
+ end
+
+ it "augments to_a to return a WP::Collection" do
+ animals = Animal.all(:limit => 2).page(1)
+ array = animals.to_a
+ array.size.should == 2
+ array.is_a? WillPaginate::Collection
+ array.current_page.should == 1
+ array.per_page.should == 2
+ end
+
+ it "doesn't have a problem assigning has-one-through relationship" do
+ human = Human.create :name => "Mislav"
+ human.pet = Animal.first
+ end
+
end if datamapper_loaded
View
29 spec/finders/data_mapper_test_connector.rb
@@ -19,9 +19,34 @@ def self.setup
end
end
+class Ownership
+ include DataMapper::Resource
+
+ belongs_to :animal, :key => true
+ belongs_to :human, :key => true
+
+ def self.setup
+ end
+end
+
+class Human
+ include DataMapper::Resource
+
+ property :id, Serial
+ property :name, String
+
+ has n, :ownerships
+ has 1, :pet, :model => 'Animal', :through => :ownerships, :via => :animal
+
+ def self.setup
+ end
+end
+
# Load fixtures
-Animal.auto_migrate!
-Animal.setup
+[Animal, Ownership, Human].each do |klass|
+ klass.auto_migrate!
+ klass.setup
+end
if 'irb' == $0
DataMapper.logger.set_log($stdout, :debug)
Please sign in to comment.
Something went wrong with that request. Please try again.