Make `turbo does not succeed` example for in `RelationshipsController`

This commit is contained in:
Andreas Nedbal 2023-10-26 22:43:01 +02:00 committed by Karina Kwiatek
parent 54fb4d09fd
commit e802e0197d
3 changed files with 6 additions and 3 deletions

View File

@ -8,6 +8,8 @@ class RelationshipsController < ApplicationController
turbo_stream_actions :create, :destroy turbo_stream_actions :create, :destroy
def create def create
params.require :screen_name
UseCase::Relationship::Create.call( UseCase::Relationship::Create.call(
source_user: current_user, source_user: current_user,
target_user: ::User.find_by!(screen_name: params[:screen_name]), target_user: ::User.find_by!(screen_name: params[:screen_name]),

View File

@ -4,6 +4,8 @@
require "rails_helper" require "rails_helper"
describe RelationshipsController, type: :controller do describe RelationshipsController, type: :controller do
render_views
shared_examples_for "params is empty" do shared_examples_for "params is empty" do
let(:params) { {} } let(:params) { {} }

View File

@ -14,10 +14,9 @@ RSpec.shared_examples_for "ajax does not succeed" do |part_of_error_message|
end end
end end
RSpec.shared_examples_for "turbo does not succeed" do RSpec.shared_examples_for "turbo does not succeed" do |part_of_error_message|
it "turbo does not succeed" do it "turbo does not succeed" do
subject subject
# FIXME: for some reason, partials are not rendered, making the actual error message not accessible expect(response.body).to include(part_of_error_message)
expect(response.body).to include "turbo-stream action=\"append\" target=\"toasts\""
end end
end end