mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-10 16:54:38 -04:00
Rubocop fixes
This commit is contained in:
@@ -12,7 +12,7 @@ class BlocksController < ApplicationController
|
||||
else
|
||||
flash[:error] = "Already blocking or error while blocking."
|
||||
end
|
||||
redirect_back fallback_location: root_path
|
||||
redirect_back_or_to(root_path)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -39,7 +39,7 @@ class MessagesController < ApplicationController
|
||||
recipient = Member.find(params[:recipient_id])
|
||||
if recipient.already_blocking?(current_member)
|
||||
flash[:error] = "You cannot send a message to a member who has blocked you."
|
||||
redirect_back fallback_location: root_path
|
||||
redirect_back_or_to(root_path)
|
||||
return
|
||||
end
|
||||
body = params[:body]
|
||||
|
||||
@@ -31,8 +31,9 @@ class Comment < ApplicationRecord
|
||||
|
||||
def author_is_not_blocked
|
||||
return unless author
|
||||
if commentable.author.already_blocking?(author)
|
||||
errors.add(:base, "You cannot comment on a post of a member who has blocked you.")
|
||||
end
|
||||
|
||||
return unless commentable.author.already_blocking?(author)
|
||||
|
||||
errors.add(:base, "You cannot comment on a post of a member who has blocked you.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,8 +20,9 @@ class Follow < ApplicationRecord
|
||||
|
||||
def follower_is_not_blocked
|
||||
return unless follower
|
||||
if followed.already_blocking?(follower)
|
||||
errors.add(:base, "You cannot follow a member who has blocked you.")
|
||||
end
|
||||
|
||||
return unless followed.already_blocking?(follower)
|
||||
|
||||
errors.add(:base, "You cannot follow a member who has blocked you.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,9 +19,10 @@ class Like < ApplicationRecord
|
||||
|
||||
def member_is_not_blocked
|
||||
return unless member
|
||||
|
||||
author = likeable_author
|
||||
if author && author.already_blocking?(member)
|
||||
errors.add(:base, "You cannot like content of a member who has blocked you.")
|
||||
end
|
||||
return unless author&.already_blocking?(member)
|
||||
|
||||
errors.add(:base, "You cannot like content of a member who has blocked you.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,6 @@ class CreateBlocks < ActiveRecord::Migration[6.1]
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :blocks, [:blocker_id, :blocked_id], unique: true
|
||||
add_index :blocks, %i(blocker_id blocked_id), unique: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,9 +49,9 @@ describe ForumsController do
|
||||
let(:valid_attributes) { { name: "New Forum", description: "A new forum", owner_id: admin.id } }
|
||||
|
||||
it "creates a new Forum" do
|
||||
expect {
|
||||
expect do
|
||||
post :create, params: { forum: valid_attributes }
|
||||
}.to change(Forum, :count).by(1)
|
||||
end.to change(Forum, :count).by(1)
|
||||
end
|
||||
|
||||
it "redirects to the created forum" do
|
||||
@@ -81,9 +81,9 @@ describe ForumsController do
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested forum" do
|
||||
forum # ensure forum exists
|
||||
expect {
|
||||
expect do
|
||||
delete :destroy, params: { id: forum.to_param }
|
||||
}.to change(Forum, :count).by(-1)
|
||||
end.to change(Forum, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the forums list" do
|
||||
|
||||
@@ -37,9 +37,9 @@ describe "Forums" do
|
||||
before { sign_in admin }
|
||||
|
||||
it "creates a new forum" do
|
||||
expect {
|
||||
expect do
|
||||
post forums_path, params: { forum: { name: "New Request Forum", description: "Desc", owner_id: admin.id } }
|
||||
}.to change(Forum, :count).by(1)
|
||||
end.to change(Forum, :count).by(1)
|
||||
expect(response).to redirect_to(forum_path(Forum.last))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user