From 7f9764a68170d05e2bb247f9e7b271dc6fbb2956 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 24 Jul 2022 10:58:39 +0200 Subject: [PATCH] Remove Mute Rule update endpoint This endpoint was never used --- app/controllers/ajax/mute_rule_controller.rb | 26 ------------------ config/routes.rb | 1 - .../ajax/mute_rule_controller_spec.rb | 27 ------------------- 3 files changed, 54 deletions(-) diff --git a/app/controllers/ajax/mute_rule_controller.rb b/app/controllers/ajax/mute_rule_controller.rb index 0f52695d..0d5cfb80 100644 --- a/app/controllers/ajax/mute_rule_controller.rb +++ b/app/controllers/ajax/mute_rule_controller.rb @@ -15,32 +15,6 @@ class Ajax::MuteRuleController < AjaxController @response[:id] = rule.id end - def update - params.require :id - params.require :muted_phrase - - unless user_signed_in? - @response[:status] = :noauth - @response[:message] = t(".noauth") - return - end - - rule = MuteRule.find(params[:id]) - - if rule.user_id != current_user.id - @response[:status] = :nopriv - @response[:message] = t(".nopriv") - return - end - - rule.muted_phrase = params[:muted_phrase] - rule.save! - - @response[:status] = :okay - @response[:message] = t(".success") - @response[:success] = true - end - def destroy params.require :id diff --git a/config/routes.rb b/config/routes.rb index e484097a..0caba133 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -129,7 +129,6 @@ Rails.application.routes.draw do post "/subscribe", to: "subscription#subscribe", as: :subscribe_answer post "/unsubscribe", to: "subscription#unsubscribe", as: :unsubscribe_answer post "/mute", to: "mute_rule#create", as: :create_mute_rule - post "/mute/:id", to: "mute_rule#update", as: :update_mute_rule delete "/mute/:id", to: "mute_rule#destroy", as: :delete_mute_rule post "/block_anon", to: "anonymous_block#create", as: :block_anon delete "/block_anon/:id", to: "anonymous_block#destroy", as: :unblock_anon diff --git a/spec/controllers/ajax/mute_rule_controller_spec.rb b/spec/controllers/ajax/mute_rule_controller_spec.rb index 603a6f97..e41189dc 100644 --- a/spec/controllers/ajax/mute_rule_controller_spec.rb +++ b/spec/controllers/ajax/mute_rule_controller_spec.rb @@ -31,33 +31,6 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do end end - describe "#update" do - subject { post(:update, params: params) } - - context "when user is signed in" do - before(:each) { sign_in(user) } - - let(:rule) { MuteRule.create(user: user, muted_phrase: 'test') } - let(:params) { { id: rule.id, muted_phrase: 'dogs' } } - let(:expected_response) do - { - "success" => true, - "status" => "okay", - "message" => "Rule updated successfully." - } - end - - it "updates a mute rule" do - subject - expect(response).to have_http_status(:success) - - expect(rule.reload.muted_phrase).to eq('dogs') - end - - include_examples "returns the expected response" - end - end - describe "#destroy" do subject { delete(:destroy, params: params) }