Use with_request_url with query params in specs

Support for query params in component specs was added in ViewComponent
2.41.0.
This commit is contained in:
Javi Martín
2022-03-04 12:45:51 +01:00
parent dc0c5c1da0
commit 15d9b88978

View File

@@ -1,8 +1,10 @@
require "rails_helper" require "rails_helper"
describe Users::PublicActivityComponent, controller: UsersController do describe Users::PublicActivityComponent, controller: UsersController do
include Rails.application.routes.url_helpers
around do |example| around do |example|
with_request_url(Rails.application.routes.url_helpers.user_path(user)) { example.run } with_request_url(user_path(user)) { example.run }
end end
describe "follows tab" do describe "follows tab" do
@@ -28,11 +30,12 @@ describe Users::PublicActivityComponent, controller: UsersController do
it "is the active tab when the follows filters is selected" do it "is the active tab when the follows filters is selected" do
create(:proposal, author: user, followers: [user]) create(:proposal, author: user, followers: [user])
controller.params["filter"] = "follows"
render_inline component with_request_url user_path(user, filter: "follows") do
render_inline component
expect(page).to have_selector "li.is-active", text: "1 Following" expect(page).to have_selector "li.is-active", text: "1 Following"
end
end end
end end