Skip to content
Snippets Groups Projects

Allow (un)following someone in the user popover

1 file
+ 24
0
Compare changes
  • Side-by-side
  • Inline
  • 7c21d60b
    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.
@@ -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)
Loading