remove AR dependency from PaginatedCollection gem
fixes: CNVS-12271 test plan: - no test needed, spec changes only Change-Id: I54a814319e17f8ca05c5b8652fc13db70258ff5a Reviewed-on: https://gerrit.instructure.com/33515 Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Simon Williams <simon@instructure.com> QA-Review: Simon Williams <simon@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
a1dde79530
commit
3a8cdd8656
|
@ -21,11 +21,9 @@ Gem::Specification.new do |spec|
|
|||
if CANVAS_RAILS3
|
||||
spec.add_dependency "folio-pagination", "0.0.7"
|
||||
spec.add_dependency "will_paginate", "3.0.4"
|
||||
spec.add_dependency "rails", "~> 3.2"
|
||||
else
|
||||
spec.add_dependency "folio-pagination-legacy", "0.0.3"
|
||||
spec.add_dependency "will_paginate", "2.3.15"
|
||||
spec.add_dependency "rails", "~> 2.3"
|
||||
end
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.5"
|
||||
|
|
|
@ -44,15 +44,12 @@ describe PaginatedCollection do
|
|||
end
|
||||
|
||||
it 'uses the pager returned' do
|
||||
example_klass = Class.new(ActiveRecord::Base) do
|
||||
self.table_name = 'examples'
|
||||
end
|
||||
|
||||
3.times { example_klass.create! }
|
||||
# using WillPaginate Array to get WillPaginate style object
|
||||
@simple = ('a' .. 'c').to_a
|
||||
|
||||
proxy = PaginatedCollection.build do |pager|
|
||||
result = example_klass.paginate(page: pager.current_page, per_page: pager.per_page)
|
||||
result.map! { |example| example.id }
|
||||
result = @simple.paginate(page: pager.current_page, per_page: pager.per_page)
|
||||
result.map! { |example| example }
|
||||
result
|
||||
end
|
||||
|
||||
|
@ -66,8 +63,8 @@ describe PaginatedCollection do
|
|||
expect(p2.next_page).to be_nil
|
||||
expect(p2.previous_page).to eq 1
|
||||
|
||||
expect(p1).to eq example_klass.all.map(&:id)[0, 2]
|
||||
expect(p2).to eq example_klass.all.map(&:id)[2, 1]
|
||||
expect(p1).to eq @simple[0, 2]
|
||||
expect(p2).to eq @simple[2, 1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
require 'folio/rails'
|
||||
require 'folio/will_paginate/active_record' if defined?(CANVAS_RAILS3) && CANVAS_RAILS3
|
||||
|
||||
require 'paginated_collection'
|
||||
|
||||
require 'support/active_record'
|
||||
require 'will_paginate/array'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.treat_symbols_as_metadata_keys_with_true_values = true
|
||||
|
|
Loading…
Reference in New Issue