aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
Diffstat (limited to 'actionview')
-rw-r--r--actionview/CHANGELOG.md6
-rw-r--r--actionview/actionview.gemspec5
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb5
-rw-r--r--actionview/test/template/url_helper_test.rb16
4 files changed, 28 insertions, 4 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index ceaea40d18..e618183129 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Fix issues with scopes and engine on `current_page?` method.
+
+ Fixes #29401.
+
+ *Nikita Savrov*
+
* Generate field ids in `collection_check_boxes` and `collection_radio_buttons`.
This makes sure that the labels are linked up with the fields.
diff --git a/actionview/actionview.gemspec b/actionview/actionview.gemspec
index 41221dd04e..48e79c53ca 100644
--- a/actionview/actionview.gemspec
+++ b/actionview/actionview.gemspec
@@ -19,6 +19,11 @@ Gem::Specification.new do |s|
s.require_path = "lib"
s.requirements << "none"
+ s.metadata = {
+ "source_code_uri" => "https://github.com/rails/rails/tree/v#{version}/actionview",
+ "changelog_uri" => "https://github.com/rails/rails/blob/v#{version}/actionview/CHANGELOG.md"
+ }
+
s.add_dependency "activesupport", version
s.add_dependency "builder", "~> 3.1"
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index a6857101b9..b78c367921 100644
--- a/actionview/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
@@ -552,7 +552,10 @@ module ActionView
request_uri = url_string.index("?") || check_parameters ? request.fullpath : request.path
request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY)
- url_string.chomp!("/") if url_string.start_with?("/") && url_string != "/"
+ if url_string.start_with?("/") && url_string != "/"
+ url_string.chomp!("/")
+ request_uri.chomp!("/")
+ end
if %r{^\w+://}.match?(url_string)
url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index 30dc719ce6..bdedbeba92 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -15,6 +15,10 @@ class UrlHelperTest < ActiveSupport::TestCase
get "/other" => "foo#other"
get "/article/:id" => "foo#article", :as => :article
get "/category/:category" => "foo#category"
+
+ scope :engine do
+ get "/" => "foo#bar"
+ end
end
include ActionView::Helpers::UrlHelper
@@ -521,10 +525,10 @@ class UrlHelperTest < ActiveSupport::TestCase
assert current_page?("http://www.example.com/?order=desc&page=1")
end
- def test_current_page_with_not_get_verb
- @request = request_for_url("/events", method: :post)
+ def test_current_page_with_scope_that_match
+ @request = request_for_url("/engine/")
- assert !current_page?("/events")
+ assert current_page?("/engine")
end
def test_current_page_with_escaped_params
@@ -553,6 +557,12 @@ class UrlHelperTest < ActiveSupport::TestCase
assert current_page?("/posts/")
end
+ def test_current_page_with_not_get_verb
+ @request = request_for_url("/events", method: :post)
+
+ assert !current_page?("/events")
+ end
+
def test_link_unless_current
@request = request_for_url("/")