Loading app/controllers/blocks_controller.rb +2 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ class BlocksController < ApplicationController end def destroy notice = if current_user.blocks.find(params[:id]).delete notice = if current_user.blocks.find_by(id: params[:id])&.delete {notice: t("blocks.destroy.success")} else {error: t("blocks.destroy.failure")} Loading @@ -20,7 +20,7 @@ class BlocksController < ApplicationController respond_to do |format| format.json { head :no_content } format.any { redirect_back notice.merge(fallback_location: privacy_settings_path) } format.any { redirect_back fallback_location: privacy_settings_path, flash: notice } end end Loading spec/controllers/blocks_controller_spec.rb +6 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ describe BlocksController, :type => :controller do it "notifies the user" do delete :destroy, params: {id: @block.id} expect(flash).not_to be_empty expect(flash[:notice]).to eq(I18n.t("blocks.destroy.success")) end it "responds with 204 with json" do Loading @@ -51,6 +51,11 @@ describe BlocksController, :type => :controller do delete :destroy, params: {id: @block.id}, format: :json }.to change { alice.blocks.count }.by(-1) end it "handles when the block to delete doesn't exist" do delete :destroy, params: {id: -1} expect(flash[:error]).to eq(I18n.t("blocks.destroy.failure")) end end describe "#disconnect_if_contact" do Loading Loading
app/controllers/blocks_controller.rb +2 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ class BlocksController < ApplicationController end def destroy notice = if current_user.blocks.find(params[:id]).delete notice = if current_user.blocks.find_by(id: params[:id])&.delete {notice: t("blocks.destroy.success")} else {error: t("blocks.destroy.failure")} Loading @@ -20,7 +20,7 @@ class BlocksController < ApplicationController respond_to do |format| format.json { head :no_content } format.any { redirect_back notice.merge(fallback_location: privacy_settings_path) } format.any { redirect_back fallback_location: privacy_settings_path, flash: notice } end end Loading
spec/controllers/blocks_controller_spec.rb +6 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ describe BlocksController, :type => :controller do it "notifies the user" do delete :destroy, params: {id: @block.id} expect(flash).not_to be_empty expect(flash[:notice]).to eq(I18n.t("blocks.destroy.success")) end it "responds with 204 with json" do Loading @@ -51,6 +51,11 @@ describe BlocksController, :type => :controller do delete :destroy, params: {id: @block.id}, format: :json }.to change { alice.blocks.count }.by(-1) end it "handles when the block to delete doesn't exist" do delete :destroy, params: {id: -1} expect(flash[:error]).to eq(I18n.t("blocks.destroy.failure")) end end describe "#disconnect_if_contact" do Loading