Move notifications to tray controller
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
class NotificationsController < ApplicationController
|
||||
def index
|
||||
class Notifications::TraysController < ApplicationController
|
||||
def show
|
||||
@notifications = Current.user.notifications.unread.ordered.limit(20)
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= turbo_stream_from Current.user, :notifications %>
|
||||
|
||||
<%= tag.div id: "notification-tray", class: "notification-tray flex flex-column gap", data: { turbo_permanent: true } do %>
|
||||
<%= turbo_frame_tag("notifications", src: notifications_path) %>
|
||||
<%= turbo_frame_tag("notifications", src: notifications_tray_path) %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<%= turbo_frame_tag "notifications" do %>
|
||||
<%= render @notifications %>
|
||||
<% end %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%= turbo_frame_tag "notifications" do %>
|
||||
<%= render collection: @notifications, partial: "notifications/notification" %>
|
||||
<% end %>
|
||||
+3
-1
@@ -18,7 +18,9 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
resources :bubbles
|
||||
resources :notifications
|
||||
namespace :notifications do
|
||||
resource :tray
|
||||
end
|
||||
|
||||
resources :buckets do
|
||||
resources :bubbles do
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
require "test_helper"
|
||||
|
||||
class NotificationsControllerTest < ActionDispatch::IntegrationTest
|
||||
class Notifications::TraysControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "index" do
|
||||
get notifications_url
|
||||
test "show" do
|
||||
get notifications_tray_url
|
||||
|
||||
assert_response :success
|
||||
assert_select "div", text: /Layout is broken/
|
||||
Reference in New Issue
Block a user