Skip to content

Commit

Permalink
Accomodate variable escaping output
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis committed Oct 23, 2023
1 parent 3c20517 commit 5b83655
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spec/helpers/canonical_rails/tag_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'uri'

describe CanonicalRails::TagHelper, type: :helper do
before(:each) do
Expand Down Expand Up @@ -204,11 +205,15 @@
end

it 'should escape allowed params properly' do
expect(helper.allowed_query_string).to eq '?page=5&keywords=%22here+be+dragons%22&search%5Bsuper%5D=special'
expect(helper.allowed_query_string).to eq('?page=5&keywords=%22here+be+dragons%22&search%5Bsuper%5D=special').
or(eq('?page=5&keywords=%22here+be+dragons%22&search[super]=special'))
end

it 'should output allowed params using proper syntax (?key=value&key=value)' do
expect(helper.canonical_tag).to eq '<link href="http://www.mywebstore.com/our_resources/?page=5&keywords=%22here+be+dragons%22&search%5Bsuper%5D=special" rel="canonical" />'
# https://github.com/rack/rack/issues/792
# this will produce different results depending on Ruby version
expect(helper.canonical_tag).to eq('<link href="http://www.mywebstore.com/our_resources/?page=5&keywords=%22here+be+dragons%22&search[super]=special" rel="canonical" />').
or(eq('<link href="http://www.mywebstore.com/our_resources/?page=5&keywords=%22here+be+dragons%22&search%5Bsuper%5D=special" rel="canonical" />'))
end

describe 'on a collection action' do
Expand Down

0 comments on commit 5b83655

Please sign in to comment.