Move `belongs_to_current_user?` to UserController

This commit is contained in:
Andreas Nedbal 2022-08-19 04:25:33 +02:00 committed by Andreas Nedbal
parent 87c2ed3ab7
commit 6693864fbc
3 changed files with 4 additions and 31 deletions

View File

@ -63,4 +63,8 @@ class UserController < ApplicationController
format.js { render layout: false } format.js { render layout: false }
end end
end end
private
def belongs_to_current_user? = @user == current_user
end end

View File

@ -21,10 +21,6 @@ module UserHelper
current_user&.mod? && session[:moderation_view] == true current_user&.mod? && session[:moderation_view] == true
end end
def belongs_to_current_user?
@user == current_user
end
private private
def profile_link(user) def profile_link(user)

View File

@ -149,31 +149,4 @@ describe UserHelper, type: :helper do
end end
end end
end end
describe "#belongs_to_current_user?" do
context "user is logged in" do
let(:user) { FactoryBot.create(:user) }
before do
sign_in user
@user = user
end
it "returns the correct value" do
expect(helper.belongs_to_current_user?).to eq(true)
end
end
context "user is not logged in" do
let(:user) { FactoryBot.create(:user) }
before do
@user = user
end
it "returns the correct value" do
expect(helper.belongs_to_current_user?).to eq(false)
end
end
end
end end