Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/active_link_to/active_link_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def active_link_to(*args, &block)
name = block_given? ? capture(&block) : args.shift
options = args.shift || {}
html_options = args.shift || {}

url = url_for(options)

active_options = { }
Expand Down Expand Up @@ -80,6 +80,8 @@ def active_link_to_class(url, options = {})
def is_active_link?(url, condition = nil)
@is_active_link ||= {}
@is_active_link[[url, condition]] ||= begin
return false if request.nil?

original_url = url
url = Addressable::URI::parse(url).path
path = request.original_fullpath
Expand Down
15 changes: 15 additions & 0 deletions test/active_link_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
require_relative 'test_helper'

class ActiveLinkToWithoutRequestTest < MiniTest::Test
def setup
super

def self.request
nil
end
end

def test_nil_request
refute is_active_link?('/')
refute is_active_link?('https://example.com/')
end
end

class ActiveLinkToTest < MiniTest::Test

def test_is_active_link_booleans_test
Expand Down