debian-mirror-gitlab/spec/lib/api/entities/user_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe API::Entities::User do
2020-04-22 19:07:51 +05:30
let(:user) { create(:user) }
let(:current_user) { create(:user) }
subject { described_class.new(user, current_user: current_user).as_json }
it 'exposes correct attributes' do
2021-09-30 23:02:18 +05:30
expect(subject).to include(:bio, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title, :work_information, :pronouns)
2020-04-22 19:07:51 +05:30
end
it 'exposes created_at 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(:created_at)
end
it 'does not expose created_at 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(:created_at)
end
2021-03-11 19:13:27 +05:30
it 'exposes user as not a bot' do
expect(subject[:bot]).to be_falsey
end
context 'with bot user' do
let(:user) { create(:user, :security_bot) }
it 'exposes user as a bot' do
expect(subject[:bot]).to eq(true)
end
end
2020-04-22 19:07:51 +05:30
end