Add specs for Turbo Stream responses
This commit is contained in:
parent
4dc88fe1ef
commit
bc52eb8cb5
|
@ -4,7 +4,7 @@ require "rails_helper"
|
|||
|
||||
describe AnonymousBlockController, type: :controller do
|
||||
describe "#create" do
|
||||
subject { post(:create, params:) }
|
||||
subject { post(:create, params:, format: :turbo_stream) }
|
||||
|
||||
context "user signed in" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
@ -23,6 +23,29 @@ describe AnonymousBlockController, type: :controller do
|
|||
it "creates an anonymous block" do
|
||||
expect { subject }.to(change { AnonymousBlock.count }.by(1))
|
||||
end
|
||||
|
||||
it "contains the inbox entry removal turbo stream action" do
|
||||
subject
|
||||
|
||||
expect(response.body).to include "turbo-stream action=\"remove\" target=\"inbox_#{inbox.id}"
|
||||
end
|
||||
end
|
||||
|
||||
context "when all required parameters are given, but no inbox entry exists" do
|
||||
let(:question) { FactoryBot.create(:question, author_identifier: "someidentifier") }
|
||||
let(:params) do
|
||||
{ question: question.id }
|
||||
end
|
||||
|
||||
it "creates an anonymous block" do
|
||||
expect { subject }.to(change { AnonymousBlock.count }.by(1))
|
||||
end
|
||||
|
||||
it "doesn't contain the inbox entry removal turbo stream action" do
|
||||
subject
|
||||
|
||||
expect(response.body).not_to include "turbo-stream action=\"remove\" target=\"inbox_"
|
||||
end
|
||||
end
|
||||
|
||||
context "when blocking a user globally" do
|
||||
|
|
|
@ -19,7 +19,7 @@ describe Settings::MutesController, type: :controller do
|
|||
end
|
||||
|
||||
describe "#create" do
|
||||
subject { post :create, params: { muted_phrase: "foo" } }
|
||||
subject { post :create, params: { muted_phrase: "foo" }, format: :turbo_stream }
|
||||
|
||||
context "user signed in" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
@ -29,11 +29,17 @@ describe Settings::MutesController, type: :controller do
|
|||
it "creates a mute rule" do
|
||||
expect { subject }.to(change { MuteRule.count }.by(1))
|
||||
end
|
||||
|
||||
it "contains a turbo stream append tag" do
|
||||
subject
|
||||
|
||||
expect(response.body).to include "turbo-stream action=\"append\" target=\"rules\""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#destroy" do
|
||||
subject { delete :destroy, params: }
|
||||
subject { delete :destroy, params:, format: :turbo_stream }
|
||||
|
||||
context "user signed in" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
@ -47,6 +53,12 @@ describe Settings::MutesController, type: :controller do
|
|||
|
||||
expect(MuteRule.exists?(rule.id)).to eq(false)
|
||||
end
|
||||
|
||||
it "contains a turbo stream remove tag" do
|
||||
subject
|
||||
|
||||
expect(response.body).to include "turbo-stream action=\"remove\" target=\"rule_#{rule.id}\""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue