diff --git a/app/controllers/taggings/toggles_controller.rb b/app/controllers/taggings/toggles_controller.rb index 3a8055098..786271c41 100644 --- a/app/controllers/taggings/toggles_controller.rb +++ b/app/controllers/taggings/toggles_controller.rb @@ -1,6 +1,10 @@ class Taggings::TogglesController < ApplicationController include BubbleScoped, BucketScoped + def new + render partial: "bubbles/sidebar/tag", locals: { bubble: @bubble, tags: Current.account.tags } + end + def create if params[:tag_title].present? sanitized_title = params[:tag_title].strip.gsub(/\A#/, "") @@ -20,6 +24,14 @@ class Taggings::TogglesController < ApplicationController end end - redirect_to @bubble + @bubble.tags.reload + + respond_to do |format| + format.turbo_stream do + render turbo_stream: turbo_stream.replace([ @bubble, :tags ], + partial: "bubbles/tags", + locals: { bubble: @bubble }) + end + end end end diff --git a/app/views/bubbles/_tags.html.erb b/app/views/bubbles/_tags.html.erb index ba774fbaf..4c3072285 100644 --- a/app/views/bubbles/_tags.html.erb +++ b/app/views/bubbles/_tags.html.erb @@ -1,13 +1,22 @@ -
+<% end %> diff --git a/app/views/bubbles/sidebar/_assignment.html.erb b/app/views/bubbles/sidebar/_assignment.html.erb index 1c6f223b4..489d92a60 100644 --- a/app/views/bubbles/sidebar/_assignment.html.erb +++ b/app/views/bubbles/sidebar/_assignment.html.erb @@ -1,4 +1,4 @@ -<% cache [bubble, bubble.bucket] do %> +<% cache [ bubble, bubble.bucket ] do %> <%= turbo_frame_tag bubble, :assignment do %> + <% end %> +<% end %> diff --git a/test/controllers/taggings/toggles_controller_test.rb b/test/controllers/taggings/toggles_controller_test.rb index 1fe593c38..4d54086ad 100644 --- a/test/controllers/taggings/toggles_controller_test.rb +++ b/test/controllers/taggings/toggles_controller_test.rb @@ -5,17 +5,23 @@ class Taggings::TogglesControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin end + test "new" do + get new_bucket_bubble_tagging_toggle_url(buckets(:writebook), bubbles(:logo)) + + assert_response :success + end + test "create" do assert_changes "bubbles(:logo).tagged_with?(tags(:mobile))", from: false, to: true do - post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:mobile).id } + post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:mobile).id }, as: :turbo_stream end - assert_redirected_to bubbles(:logo) + assert_response :success assert_changes "bubbles(:logo).tagged_with?(tags(:web))", from: false, to: true do assert_changes "bubbles(:logo).tagged_with?(tags(:mobile))", from: true, to: false do - post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:web).id } + post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:web).id }, as: :turbo_stream end end - assert_redirected_to bubbles(:logo) + assert_response :success end end