diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications/trays_controller.rb similarity index 53% rename from app/controllers/notifications_controller.rb rename to app/controllers/notifications/trays_controller.rb index 22e40167e..4a01a1ee9 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications/trays_controller.rb @@ -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 diff --git a/app/views/notifications/_tray.html.erb b/app/views/notifications/_tray.html.erb index 71ada65cb..af4385822 100644 --- a/app/views/notifications/_tray.html.erb +++ b/app/views/notifications/_tray.html.erb @@ -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 %> diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb deleted file mode 100644 index ee91b07e4..000000000 --- a/app/views/notifications/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= turbo_frame_tag "notifications" do %> - <%= render @notifications %> -<% end %> diff --git a/app/views/notifications/trays/show.html.erb b/app/views/notifications/trays/show.html.erb new file mode 100644 index 000000000..051055670 --- /dev/null +++ b/app/views/notifications/trays/show.html.erb @@ -0,0 +1,3 @@ +<%= turbo_frame_tag "notifications" do %> + <%= render collection: @notifications, partial: "notifications/notification" %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index f122bb209..92fcc6806 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/test/controllers/notifications_controller_test.rb b/test/controllers/notifications/trays_controller_test.rb similarity index 55% rename from test/controllers/notifications_controller_test.rb rename to test/controllers/notifications/trays_controller_test.rb index fc4c2bfee..7d44a3e00 100644 --- a/test/controllers/notifications_controller_test.rb +++ b/test/controllers/notifications/trays_controller_test.rb @@ -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/