Skip to content

Add protocol parameter to with_request_url test helper#2550

Merged
joelhawksley merged 6 commits intomainfrom
copilot/add-set-protocol-for-url
Feb 11, 2026
Merged

Add protocol parameter to with_request_url test helper#2550
joelhawksley merged 6 commits intomainfrom
copilot/add-set-protocol-for-url

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Testing *_url route helpers with HTTPS currently requires manually setting vc_test_controller.request.env['HTTPS'] = 'on'. This adds a protocol: parameter to with_request_url for cleaner protocol specification.

Changes

  • with_request_url method: Added protocol: keyword argument as a symbol (defaults to nil for backward compatibility)
  • State management: Saves and restores request.scheme via Rack::RACK_URL_SCHEME
  • Tests: Added protocol verification tests in test_helper_test.rb and URL generation test in rendering_test.rb
  • Documentation: Added usage example to method docs
  • CHANGELOG: Added entry under the "main" section

Usage

# Before
vc_test_controller.request.env['HTTPS'] = 'on'
render_inline(MyComponent.new)

# After
with_request_url "/products", protocol: :https do
  render_inline(MyComponent.new)
end

# Combined with host parameter
with_request_url "/api/users", protocol: :https, host: "api.example.com" do
  # Generates URLs like: https://api.example.com/api/users
end

Follows existing patterns for host: and method: parameters. The protocol parameter accepts symbols (:http or :https) for a cleaner API.

Original prompt

This section details on the original issue you should resolve

<issue_title>There should be a way to set protocol (e.g. https) when using with_request_url</issue_title>
<issue_description>## Feature request
Currently we get "http"

Motivation

Testing of *_url route helpers

Currently we have to do vc_test_controller.request.env['HTTPS'] = 'on'</issue_description>

Comments on the Issue (you are @copilot in this section)

@joelhawksley @jcoyne I'm on board, want to take a crack at a PR? @BlakeWilliams @sncalvo This has been opened for long enough without much activity, feel free to open a PR for this.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add ability to set protocol for with_request_url Add protocol parameter to with_request_url test helper Feb 11, 2026
Copilot AI requested a review from joelhawksley February 11, 2026 21:15
Copy link
Member

@joelhawksley joelhawksley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a changelog entry too.

@joelhawksley joelhawksley marked this pull request as ready for review February 11, 2026 21:18
@joelhawksley
Copy link
Member

@copilot I left a review, fix the issues.

Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

Add a changelog entry too.

Added CHANGELOG entry under the "main" section in docs/CHANGELOG.md in commit 94e2dc0.

@copilot I left a review, fix the issues.

All review issues have been addressed in commit 94e2dc0:

  • Changed protocol parameter to use symbols (:http, :https)
  • Fixed test assertion to remove "www." prefix
  • Added CHANGELOG entry


* Add `protocol` parameter to `with_request_url` test helper to enable testing with HTTPS protocol.

*Joel Hawksley*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 if only Copilot would be vain enough to credit itself!

@joelhawksley joelhawksley merged commit 70c6a79 into main Feb 11, 2026
18 checks passed
@joelhawksley joelhawksley deleted the copilot/add-set-protocol-for-url branch February 11, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There should be a way to set protocol (e.g. https) when using with_request_url

2 participants