Drop the toggles scope for taggings as well

This commit is contained in:
David Heinemeier Hansson
2025-04-05 14:20:06 +02:00
parent 384de24132
commit 7494dad91e
5 changed files with 9 additions and 13 deletions
@@ -1,4 +1,4 @@
class Taggings::TogglesController < ApplicationController
class TaggingsController < ApplicationController
include BubbleScoped, BucketScoped
def new
+2 -2
View File
@@ -3,7 +3,7 @@
<dialog class="popup panel flex-column align-start justify-start fill-white shadow" data-dialog-target="dialog">
<strong class="popup__title margin-block-half pad-inline-half">Tag this…</strong>
<%= form_with url: bucket_bubble_tagging_toggles_path(bubble.bucket, bubble), class: "flex gap-half align-center full-width pad-inline-half margin-block-end" do |form| %>
<%= form_with url: bucket_bubble_taggings_path(bubble.bucket, bubble), class: "flex gap-half align-center full-width pad-inline-half margin-block-end" do |form| %>
<%= form.text_field :tag_title, placeholder: "New tag name...", class: "input txt-small full-width" %>
<%= form.button "Add a tag…", type: "submit", class: "btn txt-small" do %>
<%= icon_tag "add" %>
@@ -11,7 +11,7 @@
<% end %>
<% end %>
<%= form_with url: bucket_bubble_tagging_toggles_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
<%= form_with url: bucket_bubble_taggings_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
<% tags.sort_by { |tag| tag.hashtag.downcase }.each do |tag| %>
<div class="btn popup__item">
<%= form.check_box "tag_id[]", {
+1 -1
View File
@@ -18,7 +18,7 @@
<span class="for-screen-reader">Add a tag</span>
</button>
<%= turbo_frame_tag bubble, :tagging, src: new_bucket_bubble_tagging_toggle_path(bubble.bucket, bubble) %>
<%= turbo_frame_tag bubble, :tagging, src: new_bucket_bubble_tagging_path(bubble.bucket, bubble) %>
</div>
</div>
<% end %>
+1 -4
View File
@@ -58,10 +58,7 @@ Rails.application.routes.draw do
end
resources :assignments
namespace :taggings, as: :tagging do
resources :toggles
end
resources :taggings
end
end
@@ -1,25 +1,24 @@
require "test_helper"
class Taggings::TogglesControllerTest < ActionDispatch::IntegrationTest
class TaggingsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "new" do
get new_bucket_bubble_tagging_toggle_url(buckets(:writebook), bubbles(:logo))
get new_bucket_bubble_tagging_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 }, as: :turbo_stream
post bucket_bubble_taggings_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:mobile).id }, as: :turbo_stream
end
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 }, as: :turbo_stream
post bucket_bubble_taggings_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:web).id }, as: :turbo_stream
end
end
assert_response :success