diff --git a/spec/controllers/anonymous_block_controller_spec.rb b/spec/controllers/anonymous_block_controller_spec.rb index 15dfef01..a1619a51 100644 --- a/spec/controllers/anonymous_block_controller_spec.rb +++ b/spec/controllers/anonymous_block_controller_spec.rb @@ -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 diff --git a/spec/controllers/settings/mutes_controller_spec.rb b/spec/controllers/settings/mutes_controller_spec.rb index 95a25b78..3b7579c5 100644 --- a/spec/controllers/settings/mutes_controller_spec.rb +++ b/spec/controllers/settings/mutes_controller_spec.rb @@ -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