mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 20:36:01 +01:00
Move belongs_to_current_user?
to UserController
This commit is contained in:
parent
87c2ed3ab7
commit
6693864fbc
3 changed files with 4 additions and 31 deletions
|
@ -63,4 +63,8 @@ class UserController < ApplicationController
|
|||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def belongs_to_current_user? = @user == current_user
|
||||
end
|
||||
|
|
|
@ -21,10 +21,6 @@ module UserHelper
|
|||
current_user&.mod? && session[:moderation_view] == true
|
||||
end
|
||||
|
||||
def belongs_to_current_user?
|
||||
@user == current_user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def profile_link(user)
|
||||
|
|
|
@ -149,31 +149,4 @@ describe UserHelper, type: :helper do
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue