Break pins out of the double nesting
Its cumbersome and needless
This commit is contained in:
@@ -8,14 +8,14 @@ class Bubbles::PinsController < ApplicationController
|
||||
pin = @bubble.pin_by Current.user
|
||||
|
||||
broadcast_new pin
|
||||
redirect_to bucket_bubble_pin_path(@bucket, @bubble)
|
||||
redirect_to bubble_pin_path(@bubble)
|
||||
end
|
||||
|
||||
def destroy
|
||||
pin = @bubble.unpin_by Current.user
|
||||
|
||||
broadcast_removed pin
|
||||
redirect_to bucket_bubble_pin_path(@bucket, @bubble)
|
||||
redirect_to bubble_pin_path(@bubble)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<%= turbo_frame_tag dom_id(@bubble, :pin) do %>
|
||||
<% if @bubble.pinned_by? Current.user %>
|
||||
<%= button_to bucket_bubble_pin_path(@bubble.bucket, @bubble), method: :delete, class: "btn btn--reversed" do %>
|
||||
<%= button_to bubble_pin_path(@bubble), method: :delete, class: "btn btn--reversed" do %>
|
||||
<%= icon_tag "pinned" %>
|
||||
<span class="for-screen-reader">Un-pin this card</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= button_to bucket_bubble_pin_path(@bubble.bucket, @bubble), class: "btn" do %>
|
||||
<%= button_to bubble_pin_path(@bubble), class: "btn" do %>
|
||||
<%= icon_tag "unpinned" %>
|
||||
<span class="for-screen-reader">Pin this card</span>
|
||||
<% end %>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<% if @bubble.published? %>
|
||||
<div class="card__actions card__actions--right flex flex-column gap-half">
|
||||
<%= turbo_frame_tag dom_id(@bubble, :watch), src: bucket_bubble_watch_path(@bubble.bucket, @bubble), refresh: :morph %>
|
||||
<%= turbo_frame_tag dom_id(@bubble, :pin), src: bucket_bubble_pin_path(@bubble.bucket, @bubble), refresh: :morph %>
|
||||
<%= turbo_frame_tag dom_id(@bubble, :pin), src: bubble_pin_path(@bubble), refresh: :morph %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
+6
-2
@@ -17,7 +17,12 @@ Rails.application.routes.draw do
|
||||
route_for :bucket_bubble, comment.bubble.bucket, comment.bubble, options
|
||||
end
|
||||
|
||||
resources :bubbles
|
||||
resources :bubbles do
|
||||
scope module: :bubbles do
|
||||
resource :pin
|
||||
end
|
||||
end
|
||||
|
||||
resources :notifications, only: :index
|
||||
namespace :notifications do
|
||||
resource :tray, only: :show
|
||||
@@ -54,7 +59,6 @@ Rails.application.routes.draw do
|
||||
resource :recover
|
||||
resources :stagings
|
||||
resource :watch
|
||||
resource :pin, only: [ :show, :create, :destroy ]
|
||||
end
|
||||
|
||||
resources :assignments
|
||||
|
||||
@@ -9,23 +9,23 @@ class Bubbles::PinsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_changes -> { bubbles(:layout).pinned_by?(users(:kevin)) }, from: false, to: true do
|
||||
perform_enqueued_jobs do
|
||||
assert_turbo_stream_broadcasts([ users(:kevin), :pins ], count: 1) do
|
||||
post bucket_bubble_pin_path(buckets(:writebook), bubbles(:layout))
|
||||
post bubble_pin_path(bubbles(:layout))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assert_redirected_to bucket_bubble_pin_path(buckets(:writebook), bubbles(:layout))
|
||||
assert_redirected_to bubble_pin_path(bubbles(:layout))
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
assert_changes -> { bubbles(:shipping).pinned_by?(users(:kevin)) }, from: true, to: false do
|
||||
perform_enqueued_jobs do
|
||||
assert_turbo_stream_broadcasts([ users(:kevin), :pins ], count: 1) do
|
||||
delete bucket_bubble_pin_path(buckets(:writebook), bubbles(:shipping))
|
||||
delete bubble_pin_path(bubbles(:shipping))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assert_redirected_to bucket_bubble_pin_path(buckets(:writebook), bubbles(:shipping))
|
||||
assert_redirected_to bubble_pin_path(bubbles(:shipping))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user