Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/api/entities')
-rw-r--r--spec/lib/api/entities/ci/job_request/dependency_spec.rb7
-rw-r--r--spec/lib/api/entities/plan_limit_spec.rb11
-rw-r--r--spec/lib/api/entities/projects/topic_spec.rb1
-rw-r--r--spec/lib/api/entities/user_spec.rb45
4 files changed, 59 insertions, 5 deletions
diff --git a/spec/lib/api/entities/ci/job_request/dependency_spec.rb b/spec/lib/api/entities/ci/job_request/dependency_spec.rb
index fa5f3da554c..bbeb864c2ee 100644
--- a/spec/lib/api/entities/ci/job_request/dependency_spec.rb
+++ b/spec/lib/api/entities/ci/job_request/dependency_spec.rb
@@ -3,8 +3,9 @@
require 'spec_helper'
RSpec.describe API::Entities::Ci::JobRequest::Dependency do
+ let(:running_job) { create(:ci_build, :artifacts) }
let(:job) { create(:ci_build, :artifacts) }
- let(:entity) { described_class.new(job) }
+ let(:entity) { described_class.new(job, { running_job: running_job }) }
subject { entity.as_json }
@@ -16,8 +17,8 @@ RSpec.describe API::Entities::Ci::JobRequest::Dependency do
expect(subject[:name]).to eq(job.name)
end
- it 'returns the dependency token' do
- expect(subject[:token]).to eq(job.token)
+ it 'returns the token belonging to the running job' do
+ expect(subject[:token]).to eq(running_job.token)
end
it 'returns the dependency artifacts_file', :aggregate_failures do
diff --git a/spec/lib/api/entities/plan_limit_spec.rb b/spec/lib/api/entities/plan_limit_spec.rb
index 1b8b21d47f3..a88ea3f4cad 100644
--- a/spec/lib/api/entities/plan_limit_spec.rb
+++ b/spec/lib/api/entities/plan_limit_spec.rb
@@ -9,6 +9,14 @@ RSpec.describe API::Entities::PlanLimit do
it 'exposes correct attributes' do
expect(subject).to include(
+ :ci_pipeline_size,
+ :ci_active_jobs,
+ :ci_active_pipelines,
+ :ci_project_subscriptions,
+ :ci_pipeline_schedules,
+ :ci_needs_size_limit,
+ :ci_registered_group_runners,
+ :ci_registered_project_runners,
:conan_max_file_size,
:generic_packages_max_file_size,
:helm_max_file_size,
@@ -16,7 +24,8 @@ RSpec.describe API::Entities::PlanLimit do
:npm_max_file_size,
:nuget_max_file_size,
:pypi_max_file_size,
- :terraform_module_max_file_size
+ :terraform_module_max_file_size,
+ :storage_size_limit
)
end
diff --git a/spec/lib/api/entities/projects/topic_spec.rb b/spec/lib/api/entities/projects/topic_spec.rb
index cdf142dbb7d..1ea0e724fed 100644
--- a/spec/lib/api/entities/projects/topic_spec.rb
+++ b/spec/lib/api/entities/projects/topic_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe API::Entities::Projects::Topic do
expect(subject).to include(
:id,
:name,
+ :title,
:description,
:total_projects_count,
:avatar_url
diff --git a/spec/lib/api/entities/user_spec.rb b/spec/lib/api/entities/user_spec.rb
index be5e8e8e8c2..407f2894f01 100644
--- a/spec/lib/api/entities/user_spec.rb
+++ b/spec/lib/api/entities/user_spec.rb
@@ -12,7 +12,40 @@ RSpec.describe API::Entities::User do
subject { entity.as_json }
it 'exposes correct attributes' do
- expect(subject).to include(:name, :bio, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title, :work_information, :pronouns)
+ expect(subject.keys).to contain_exactly(
+ # UserSafe
+ :id, :username, :name,
+ # UserBasic
+ :state, :avatar_url, :web_url,
+ # User
+ :created_at, :bio, :location, :public_email, :skype, :linkedin, :twitter,
+ :website_url, :organization, :job_title, :pronouns, :bot, :work_information,
+ :followers, :following, :is_followed, :local_time
+ )
+ end
+
+ context 'exposing follow relationships' do
+ before do
+ allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(can_read_user_profile)
+ end
+
+ %i(followers following is_followed).each do |relationship|
+ context 'when current user cannot read user profile' do
+ let(:can_read_user_profile) { false }
+
+ it "does not expose #{relationship}" do
+ expect(subject).not_to include(relationship)
+ end
+ end
+
+ context 'when current user can read user profile' do
+ let(:can_read_user_profile) { true }
+
+ it "exposes #{relationship}" do
+ expect(subject).to include(relationship)
+ end
+ end
+ end
end
it 'exposes created_at if the current user can read the user profile' do
@@ -135,6 +168,16 @@ RSpec.describe API::Entities::User do
end
end
+ context 'with logged-out user' do
+ let(:current_user) { nil }
+
+ it 'exposes is_followed as nil' do
+ allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, user).and_return(true)
+
+ expect(subject.keys).not_to include(:is_followed)
+ end
+ end
+
it 'exposes local_time' do
local_time = '2:30 PM'
expect(entity).to receive(:local_time).with(timezone).and_return(local_time)