Skip to content
Snippets Groups Projects
Commit 7c21d60b authored by Kev's avatar Kev :dog:
Browse files

Add missing tests for following and follower count

This adds tests for the `following` and `followers` fields on the User
entity because they were missing. This also adds the tests as negated
variant to be safe that the ability check is present in the entity.
parent 572f6a7a
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !76050. Comments created here will be created in the context of that merge request.
......@@ -15,6 +15,30 @@
expect(subject).to include(:name, :bio, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title, :work_information, :pronouns, :is_followed)
end
it 'exposes followers if the current user can read the user profile' do
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(true)
expect(subject).to include(:followers)
end
it 'does not expose followers if the current user cannot read the user profile' do
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(false)
expect(subject).not_to include(:followers)
end
it 'exposes following if the current user can read the user profile' do
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(true)
expect(subject).to include(:following)
end
it 'does not expose following if the current user cannot read the user profile' do
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(false)
expect(subject).not_to include(:following)
end
it 'exposes is_followed if the current user can read the user profile' do
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment