From ef22b76b732c2bf4ce52b8a73570ac2921f9caa4 Mon Sep 17 00:00:00 2001
From: Douglas Barbosa Alexandre <dbalexandre@gmail.com>
Date: Mon, 11 Apr 2016 19:33:26 -0300
Subject: [PATCH] Simplify Projects::NotificationSettingsController

---
 .../projects/notification_settings_controller.rb           | 7 -------
 app/views/projects/buttons/_notifications.html.haml        | 2 +-
 config/routes.rb                                           | 2 +-
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/app/controllers/projects/notification_settings_controller.rb b/app/controllers/projects/notification_settings_controller.rb
index e536725c5b1..7d81cc03c73 100644
--- a/app/controllers/projects/notification_settings_controller.rb
+++ b/app/controllers/projects/notification_settings_controller.rb
@@ -1,13 +1,6 @@
 class Projects::NotificationSettingsController < Projects::ApplicationController
   before_action :authenticate_user!
 
-  def create
-    notification_setting = current_user.notification_settings_for(project)
-    saved = notification_setting.update_attributes(notification_setting_params)
-
-    render json: { saved: saved }
-  end
-
   def update
     notification_setting = current_user.notification_settings_for(project)
     saved = notification_setting.update_attributes(notification_setting_params)
diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml
index 49f541399f2..c1e3e5b73a2 100644
--- a/app/views/projects/buttons/_notifications.html.haml
+++ b/app/views/projects/buttons/_notifications.html.haml
@@ -1,5 +1,5 @@
 - if @notification_setting
-  = form_for @notification_setting, url: namespace_project_notification_setting_path(@project.namespace.becomes(Namespace), @project), remote: true, html: { class: 'inline', id: 'notification-form' } do |f|
+  = form_for @notification_setting, url: namespace_project_notification_setting_path(@project.namespace.becomes(Namespace), @project), method: :patch, remote: true, html: { class: 'inline', id: 'notification-form' } do |f|
     = f.hidden_field :level
     %span.dropdown
       %a.dropdown-new.btn.notifications-btn#notifications-button{href: '#', "data-toggle" => "dropdown"}
diff --git a/config/routes.rb b/config/routes.rb
index 552385110dd..48601b7567b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -608,7 +608,7 @@ Rails.application.routes.draw do
 
         resources :forks, only: [:index, :new, :create]
         resource :import, only: [:new, :create, :show]
-        resource :notification_setting, only: [:create, :update]
+        resource :notification_setting, only: [:update]
 
         resources :refs, only: [] do
           collection do
-- 
GitLab