mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Refactor turbo stream assertions.
This commit is contained in:
@@ -64,8 +64,7 @@ RSpec.describe Backlogs::WorkPackagesController do
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}"
|
||||
assert_select %(turbo-stream[action="replace"][target="backlogs-sprint-component-#{sprint.id}"][method="morph"])
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}", method: "morph"
|
||||
expect(assigns(:project)).to eq(project)
|
||||
expect(assigns(:story)).to eq(story)
|
||||
end
|
||||
@@ -164,10 +163,9 @@ RSpec.describe Backlogs::WorkPackagesController do
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}"
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{other_sprint.id}"
|
||||
assert_select %(turbo-stream[action="replace"][target="backlogs-sprint-component-#{sprint.id}"])
|
||||
assert_select %(turbo-stream[action="replace"][target="backlogs-sprint-component-#{other_sprint.id}"])
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}", method: "morph"
|
||||
expect(response)
|
||||
.to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{other_sprint.id}", method: "morph"
|
||||
expect(response).to have_turbo_stream action: "flash", target: "op-primer-flash-component"
|
||||
expect(assigns(:project)).to eq(project)
|
||||
expect(assigns(:story)).to eq(story_in_sprint)
|
||||
@@ -188,10 +186,9 @@ RSpec.describe Backlogs::WorkPackagesController do
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}"
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-backlog-component-#{project.id}"
|
||||
assert_select %(turbo-stream[action="replace"][target="backlogs-sprint-component-#{sprint.id}"])
|
||||
assert_select %(turbo-stream[action="replace"][target="backlogs-backlog-component-#{project.id}"][method="morph"])
|
||||
expect(response).to have_turbo_stream action: "replace", target: "backlogs-sprint-component-#{sprint.id}", method: "morph"
|
||||
expect(response)
|
||||
.to have_turbo_stream action: "replace", target: "backlogs-backlog-component-#{project.id}", method: "morph"
|
||||
expect(response).to have_turbo_stream action: "flash", target: "op-primer-flash-component"
|
||||
expect(assigns(:project)).to eq(project)
|
||||
expect(assigns(:story)).to eq(story_in_sprint)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
# Adapted for RSpec from turbo-rails
|
||||
# See: https://github.com/hotwired/turbo-rails/blob/main/lib/turbo/test_assertions.rb
|
||||
#
|
||||
RSpec::Matchers.define :have_turbo_stream do |action:, target: nil, targets: nil, url: nil, count: 1|
|
||||
RSpec::Matchers.define :have_turbo_stream do |action:, target: nil, targets: nil, url: nil, method: nil, count: 1|
|
||||
description { "contain a `<turbo-stream>` element" }
|
||||
failure_message { rescued_exception.message }
|
||||
failure_message_when_negated do
|
||||
@@ -47,6 +47,7 @@ RSpec::Matchers.define :have_turbo_stream do |action:, target: nil, targets: nil
|
||||
@selector << %([target="#{target.respond_to?(:to_key) ? dom_id(target) : target}"]) if target
|
||||
@selector << %([targets="#{targets}"]) if targets
|
||||
@selector << %([url="#{url}"]) if url
|
||||
@selector << %([method="#{method}"]) if method
|
||||
|
||||
assert_select(@selector, count:, &block_arg)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user