Loading app/controllers/blocks_controller.rb +8 −5 Original line number Diff line number Diff line class BlocksController < ApplicationController before_action :authenticate_user! respond_to :json def create block = current_user.blocks.new(block_params) disconnect_if_contact(block.person) if block.save respond_with do |format| respond_to do |format| format.json { head :no_content } end end def destroy current_user.blocks.find(params[:id]).delete notice = if current_user.blocks.find(params[:id]).delete {notice: t("blocks.destroy.success")} else {error: t("blocks.destroy.failure")} end respond_with do |format| respond_to do |format| format.json { head :no_content } format.any { redirect_back notice.merge(fallback_location: privacy_settings_path) } end end Loading app/views/users/privacy_settings.mobile.haml +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,10 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - flash.each do |name, msg| .alert{class: "alert-#{flash_class name}", role: "alert"} = msg - content_for :page_title do = t(".title") Loading spec/controllers/blocks_controller_spec.rb +16 −1 Original line number Diff line number Diff line Loading @@ -26,11 +26,26 @@ describe BlocksController, :type => :controller do @block = alice.blocks.create(:person => eve.person) end it "responds with 204" do it "redirects back" do delete :destroy, params: {id: @block.id} expect(response).to be_redirect end it "notifies the user" do delete :destroy, params: {id: @block.id} expect(flash).not_to be_empty end it "responds with 204 with json" do delete :destroy, params: {id: @block.id}, format: :json expect(response.status).to eq(204) end it "redirects back on mobile" do delete :destroy, params: {id: @block.id}, format: :mobile expect(response).to be_redirect end it "removes a block" do expect { delete :destroy, params: {id: @block.id}, format: :json Loading Loading
app/controllers/blocks_controller.rb +8 −5 Original line number Diff line number Diff line class BlocksController < ApplicationController before_action :authenticate_user! respond_to :json def create block = current_user.blocks.new(block_params) disconnect_if_contact(block.person) if block.save respond_with do |format| respond_to do |format| format.json { head :no_content } end end def destroy current_user.blocks.find(params[:id]).delete notice = if current_user.blocks.find(params[:id]).delete {notice: t("blocks.destroy.success")} else {error: t("blocks.destroy.failure")} end respond_with do |format| respond_to do |format| format.json { head :no_content } format.any { redirect_back notice.merge(fallback_location: privacy_settings_path) } end end Loading
app/views/users/privacy_settings.mobile.haml +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,10 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - flash.each do |name, msg| .alert{class: "alert-#{flash_class name}", role: "alert"} = msg - content_for :page_title do = t(".title") Loading
spec/controllers/blocks_controller_spec.rb +16 −1 Original line number Diff line number Diff line Loading @@ -26,11 +26,26 @@ describe BlocksController, :type => :controller do @block = alice.blocks.create(:person => eve.person) end it "responds with 204" do it "redirects back" do delete :destroy, params: {id: @block.id} expect(response).to be_redirect end it "notifies the user" do delete :destroy, params: {id: @block.id} expect(flash).not_to be_empty end it "responds with 204 with json" do delete :destroy, params: {id: @block.id}, format: :json expect(response.status).to eq(204) end it "redirects back on mobile" do delete :destroy, params: {id: @block.id}, format: :mobile expect(response).to be_redirect end it "removes a block" do expect { delete :destroy, params: {id: @block.id}, format: :json Loading