Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: code quality issues #1051

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion kaminari-actionview/lib/kaminari/actionview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ActiveSupport.on_load :action_view do
require 'kaminari/helpers/helper_methods'
::ActionView::Base.send :include, Kaminari::Helpers::HelperMethods
::ActionView::Base.include Kaminari::Helpers::HelperMethods

require 'kaminari/actionview/action_view_extension'
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def render_partial(*)
end

# so that this instance can actually "render"
::Kaminari::Helpers::Paginator.send :include, ::ActionView::Context
::Kaminari::Helpers::Paginator.include ::ActionView::Context

ActionView::LogSubscriber.send :prepend, Kaminari::ActionViewExtension::LogSubscriberSilencer
ActionView::LogSubscriber.prepend Kaminari::ActionViewExtension::LogSubscriberSilencer
2 changes: 1 addition & 1 deletion kaminari-activerecord/lib/kaminari/activerecord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
ActiveSupport.on_load :active_record do
require 'kaminari/core'
require 'kaminari/activerecord/active_record_extension'
::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
::ActiveRecord::Base.include Kaminari::ActiveRecordExtension
end
2 changes: 1 addition & 1 deletion kaminari-core/lib/generators/kaminari/views_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Kaminari
module Generators
# rails g kaminari:views THEME
class ViewsGenerator < Rails::Generators::NamedBase # :nodoc:
source_root File.expand_path('../../../../app/views/kaminari', __FILE__)
source_root File.expand_path('../../../app/views/kaminari', __dir__)

class_option :template_engine, type: :string, aliases: '-e', desc: 'Template engine for the views. Available options are "erb", "haml", and "slim".'
class_option :views_prefix, type: :string, desc: 'Prefix for path to put views in.'
Expand Down
4 changes: 2 additions & 2 deletions kaminari-core/lib/kaminari/helpers/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def rel_next_prev_link_tags(scope, options = {})
prev_page = path_to_prev_page(scope, options)

output = String.new
output << %Q|<link rel="next" href="#{next_page}">| if next_page
output << %Q|<link rel="prev" href="#{prev_page}">| if prev_page
output << %|<link rel="next" href="#{next_page}">| if next_page
output << %|<link rel="prev" href="#{prev_page}">| if prev_page
output.html_safe
end
end
Expand Down
2 changes: 1 addition & 1 deletion kaminari-core/test/fake_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def kls.fake_gem_defined_method; end
end

ActiveSupport.on_load :active_record do
ActiveRecord::Base.send :include, Kaminari::FakeGem
ActiveRecord::Base.include Kaminari::FakeGem

# Simulate a gem providing a subclass of ActiveRecord::Base before the Railtie is loaded.
class GemDefinedModel < ActiveRecord::Base
Expand Down
4 changes: 2 additions & 2 deletions kaminari-core/test/helpers/action_view_extension_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ def to_s
users = User.page(1)

assert_nil view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'})
assert_equal 'At the Beginning', (view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'}) do 'At the Beginning' end)
assert_equal 'At the Beginning', (view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'}) { 'At the Beginning' })
end

test 'out of range' do
users = User.page(5)

assert_nil view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'})
assert_equal 'At the Beginning', (view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'}) do 'At the Beginning' end)
assert_equal 'At the Beginning', (view.link_to_previous_page(users, 'Previous', params: {controller: 'users', action: 'index'}) { 'At the Beginning' })
end

test '#link_to_previous_page accepts ActionController::Parameters' do
Expand Down