Pull assignments out of the double nesting

This commit is contained in:
David Heinemeier Hansson
2025-04-05 15:59:51 +02:00
parent 3b5f8c2e6a
commit d0953d6f87
4 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<dialog class="popup panel flex-column align-start gap-half fill-white shadow" data-dialog-target="dialog">
<strong class="popup__title margin-block-start-half pad-inline-half txt-nowrap">Assign this to…</strong>
<%= form_with url: bucket_bubble_assignments_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
<%= form_with url: bubble_assignments_path(bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
<% bubble.bucket.users.active.sort_by(&:name).each do |user| %>
<div class="btn popup__item">
<%= form.check_box "assignee_id[]", {
@@ -1,3 +1,3 @@
<%= render "bubbles/cards/common/assignees", bubble: bubble do %>
<%= turbo_frame_tag bubble, :assignment, src: new_bucket_bubble_assignment_path(bubble.bucket, bubble) %>
<%= turbo_frame_tag bubble, :assignment, src: new_bubble_assignment_path(bubble) %>
<% end %>
+1 -1
View File
@@ -20,6 +20,7 @@ Rails.application.routes.draw do
resources :bubbles do
scope module: :bubbles do
resource :pin
resources :assignments
end
end
@@ -59,7 +60,6 @@ Rails.application.routes.draw do
resource :recover
resources :stagings
resource :watch
resources :assignments
end
resources :taggings
@@ -6,19 +6,18 @@ class Bubbles::AssignmentsControllerTest < ActionDispatch::IntegrationTest
end
test "new" do
get new_bucket_bubble_assignment_url(buckets(:writebook), bubbles(:logo))
get new_bubble_assignment_url(bubbles(:logo))
assert_response :success
end
test "create" do
assert_changes "bubbles(:logo).assigned_to?(users(:david))", from: false, to: true do
post bucket_bubble_assignments_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
post bubble_assignments_url(bubbles(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
end
assert_response :success
assert_changes "bubbles(:logo).assigned_to?(users(:david))", from: true, to: false do
post bucket_bubble_assignments_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:kevin).id }, as: :turbo_stream
post bubble_assignments_url(bubbles(:logo)), params: { assignee_id: users(:kevin).id }, as: :turbo_stream
end
assert_response :success
end