Removed obsolete CheckNotifications controller

This commit is contained in:
Colin Darie 2018-08-31 10:00:32 +02:00
parent cb57fee73c
commit c2cd9f5786
No known key found for this signature in database
GPG Key ID: 4FB865FDBCA4BCC4
4 changed files with 0 additions and 62 deletions

View File

@ -1,47 +0,0 @@
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# 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

View File

@ -1,3 +0,0 @@
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
document.querySelector("[data-notification-id='<%= @notification.id %>']").remove();

View File

@ -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

View File

@ -1,10 +0,0 @@
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# 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