Skip to content

Commit

Permalink
Remove dependency on Pagy
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify committed Mar 10, 2021
1 parent e046c03 commit b1cfac3
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 34 deletions.
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ PATH
activejob (>= 6.0)
activerecord (>= 6.0)
job-iteration (~> 1.1)
pagy (~> 3.9)
railties (>= 6.0)

GEM
Expand Down Expand Up @@ -112,7 +111,6 @@ GEM
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
pagy (3.11.0)
parallel (1.20.1)
parser (2.7.2.0)
ast (~> 2.4.1)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/maintenance_tasks/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module MaintenanceTasks
#
# Can be extended to add different authentication and authorization code.
class ApplicationController < ActionController::Base
include Pagy::Backend

BULMA_CDN = 'https://cdn.jsdelivr.net'

content_security_policy do |policy|
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/maintenance_tasks/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def index
def show
@task = TaskData.find(params.fetch(:id))
set_refresh if @task.last_run&.active?

@runs_page = RunsPage.new(@task.previous_runs, params[:cursor])
# @pagy, @previous_runs = pagy(@task.previous_runs)
end

# Runs a given Task and redirects to the Task page.
Expand Down
11 changes: 0 additions & 11 deletions app/helpers/maintenance_tasks/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ module MaintenanceTasks
#
# @api private
module ApplicationHelper
include Pagy::Frontend

# Renders pagination for the page, if there is more than one page present.
#
# @param pagy [Pagy] the pagy instance containing pagination details,
# including the number of pages the results are spread across.
# @return [String] the HTML to render for pagination.
def pagination(pagy)
raw(pagy_bulma_nav(pagy)) if pagy.pages > 1
end

# Renders a time element with the given datetime, worded as relative to the
# current time.
#
Expand Down
2 changes: 0 additions & 2 deletions lib/maintenance_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

require 'job-iteration'
require 'maintenance_tasks/engine'
require 'pagy'
require 'pagy/extras/bulma'

# Force the TaskJob class to load so we can verify upstream compatibility with
# the JobIteration gem
Expand Down
1 change: 0 additions & 1 deletion maintenance_tasks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ Gem::Specification.new do |spec|
spec.add_dependency('activejob', '>= 6.0')
spec.add_dependency('activerecord', '>= 6.0')
spec.add_dependency('job-iteration', '~> 1.1')
spec.add_dependency('pagy', '~> 3.9')
spec.add_dependency('railties', '>= 6.0')
end
14 changes: 0 additions & 14 deletions test/helpers/maintenance_tasks/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@

module MaintenanceTasks
class ApplicationHelperTest < ActionView::TestCase
setup { @pagy = mock }

test '#pagination returns nil if pages is less than or equal to 1' do
@pagy.expects(pages: 1)
expects(:pagy_bulma_nav).never
assert_nil pagination(@pagy)
end

test '#pagination returns pagination element if pages is greater than 1' do
@pagy.expects(pages: 2)
expects(:pagy_bulma_nav).with(@pagy).returns('pagination')
assert_equal 'pagination', pagination(@pagy)
end

test '#time_ago returns a time element with the given datetime worded as relative to now and ISO 8601 UTC time in title attribute' do
travel_to Time.zone.local(2020, 1, 9, 9, 41, 44)
time = Time.zone.local(2020, 01, 01, 01, 00, 00)
Expand Down

0 comments on commit b1cfac3

Please sign in to comment.