From c2cd9f5786bd9d6590c2ed5c98b32b056bffe8ef Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 31 Aug 2018 10:00:32 +0200 Subject: [PATCH] Removed obsolete CheckNotifications controller --- .../check_notifications_controller.rb | 47 ------------------- app/views/check_notifications/destroy.js.erb | 3 -- config/routes.rb | 2 - .../check_notifications_controller_test.rb | 10 ---- 4 files changed, 62 deletions(-) delete mode 100644 app/controllers/check_notifications_controller.rb delete mode 100644 app/views/check_notifications/destroy.js.erb delete mode 100644 test/controllers/check_notifications_controller_test.rb diff --git a/app/controllers/check_notifications_controller.rb b/app/controllers/check_notifications_controller.rb deleted file mode 100644 index b1e47b1..0000000 --- a/app/controllers/check_notifications_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2018 Colin Darie , 2018 Evolix -# License: GNU AGPL-3+ (see full text in LICENSE file) - -class CheckNotificationsController < ApplicationController - before_action :authenticate_user! - before_action :set_notification, except: [:create] - - def create - check = Check.find(params[:check_id]) - @notification = check.notifications.build(notification_params) - authorize @notification - - if @notification.save - flash[:notice] = "Your notification has been saved." - redirect_to check_path - else - flash.now[:alert] = "An error occured." - render "checks/edit" - end - end - - def destroy - @notification.destroy! - - respond_to do |format| - format.js - end - end - - private - - def set_notification - # joins the check because policy use the check relation - @notification = Notification - .joins(:check) - .find_by!(id: params[:id], check_id: params[:check_id]) - authorize @notification - end - - def notification_params - params.require(:notification).permit(:channel, :recipient, :interval) - end - - def check_path - edit_check_path(check_id: params[:check_id]) - end -end diff --git a/app/views/check_notifications/destroy.js.erb b/app/views/check_notifications/destroy.js.erb deleted file mode 100644 index e05a19b..0000000 --- a/app/views/check_notifications/destroy.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% # Copyright (C) 2018 Colin Darie , 2018 Evolix %> -<% # License: GNU AGPL-3+ (see full text in LICENSE file) %> -document.querySelector("[data-notification-id='<%= @notification.id %>']").remove(); diff --git a/config/routes.rb b/config/routes.rb index 28fb640..8baaa3a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,6 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :checks, except: [:show] do - resources :check_notifications, only: [:destroy] collection do post :supports, format: :json end @@ -24,7 +23,6 @@ end # == Route Map # # Prefix Verb URI Pattern Controller#Action -# check_check_notification DELETE /checks/:check_id/check_notifications/:id(.:format) check_notifications#destroy # supports_checks POST /checks/supports(.:format) checks#supports # checks GET /checks(.:format) checks#index # POST /checks(.:format) checks#create diff --git a/test/controllers/check_notifications_controller_test.rb b/test/controllers/check_notifications_controller_test.rb deleted file mode 100644 index 57b93cf..0000000 --- a/test/controllers/check_notifications_controller_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2018 Colin Darie , 2018 Evolix -# License: GNU AGPL-3+ (see full text in LICENSE file) - -require "test_helper" - -class CheckNotificationsControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end