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/merge_request_basic_spec.rb16
-rw-r--r--spec/lib/api/entities/ml/mlflow/run_info_spec.rb4
-rw-r--r--spec/lib/api/entities/release_spec.rb8
-rw-r--r--spec/lib/api/entities/user_counts_spec.rb24
4 files changed, 40 insertions, 12 deletions
diff --git a/spec/lib/api/entities/merge_request_basic_spec.rb b/spec/lib/api/entities/merge_request_basic_spec.rb
index 40f259b86e2..bb0e25d2613 100644
--- a/spec/lib/api/entities/merge_request_basic_spec.rb
+++ b/spec/lib/api/entities/merge_request_basic_spec.rb
@@ -18,12 +18,16 @@ RSpec.describe ::API::Entities::MergeRequestBasic do
subject { entity.as_json }
- it 'includes basic fields' do
- is_expected.to include(
- draft: merge_request.draft?,
- work_in_progress: merge_request.draft?,
- merge_user: nil
- )
+ it 'includes expected fields' do
+ expected_fields = %i[
+ merged_by merge_user merged_at closed_by closed_at target_branch user_notes_count upvotes downvotes
+ author assignees assignee reviewers source_project_id target_project_id labels draft work_in_progress
+ milestone merge_when_pipeline_succeeds merge_status detailed_merge_status sha merge_commit_sha
+ squash_commit_sha discussion_locked should_remove_source_branch force_remove_source_branch
+ reference references web_url time_stats squash task_completion_status has_conflicts blocking_discussions_resolved
+ ]
+
+ is_expected.to include(*expected_fields)
end
context "with :with_api_entity_associations scope" do
diff --git a/spec/lib/api/entities/ml/mlflow/run_info_spec.rb b/spec/lib/api/entities/ml/mlflow/run_info_spec.rb
index 2a6d0825e5c..d5a37f53e21 100644
--- a/spec/lib/api/entities/ml/mlflow/run_info_spec.rb
+++ b/spec/lib/api/entities/ml/mlflow/run_info_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe API::Entities::Ml::Mlflow::RunInfo do
let_it_be(:candidate) { create(:ml_candidates) }
- subject { described_class.new(candidate).as_json }
+ subject { described_class.new(candidate, packages_url: 'http://example.com').as_json }
context 'when start_time is nil' do
it { expect(subject[:start_time]).to eq(0) }
@@ -53,7 +53,7 @@ RSpec.describe API::Entities::Ml::Mlflow::RunInfo do
describe 'artifact_uri' do
it 'is not implemented' do
- expect(subject[:artifact_uri]).to eq('not_implemented')
+ expect(subject[:artifact_uri]).to eq("http://example.com#{candidate.artifact_root}")
end
end
diff --git a/spec/lib/api/entities/release_spec.rb b/spec/lib/api/entities/release_spec.rb
index aa2c5126bb9..d1e5f191614 100644
--- a/spec/lib/api/entities/release_spec.rb
+++ b/spec/lib/api/entities/release_spec.rb
@@ -16,13 +16,13 @@ RSpec.describe API::Entities::Release do
end
describe 'evidences' do
- context 'when the current user can download code' do
+ context 'when the current user can read code' do
let(:entity_evidence) { entity[:evidences].first }
it 'exposes the evidence sha and the json path' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?)
- .with(user, :download_code, project).and_return(true)
+ .with(user, :read_code, project).and_return(true)
expect(entity_evidence[:sha]).to eq(evidence.summary_sha)
expect(entity_evidence[:collected_at]).to eq(evidence.collected_at)
@@ -36,11 +36,11 @@ RSpec.describe API::Entities::Release do
end
end
- context 'when the current user cannot download code' do
+ context 'when the current user cannot read code' do
it 'does not expose any evidence data' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?)
- .with(user, :download_code, project).and_return(false)
+ .with(user, :read_code, project).and_return(false)
expect(entity.keys).not_to include(:evidences)
end
diff --git a/spec/lib/api/entities/user_counts_spec.rb b/spec/lib/api/entities/user_counts_spec.rb
new file mode 100644
index 00000000000..0ed989ad7e9
--- /dev/null
+++ b/spec/lib/api/entities/user_counts_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe API::Entities::UserCounts do
+ let(:user) { build(:user) }
+
+ subject(:entity) { described_class.new(user).as_json }
+
+ it 'represents user counts', :aggregate_failures do
+ expect(user).to receive(:assigned_open_merge_requests_count).and_return(1).twice
+ expect(user).to receive(:assigned_open_issues_count).and_return(2).once
+ expect(user).to receive(:review_requested_open_merge_requests_count).and_return(3).once
+ expect(user).to receive(:todos_pending_count).and_return(4).once
+
+ expect(entity).to include(
+ merge_requests: 1,
+ assigned_issues: 2,
+ assigned_merge_requests: 1,
+ review_requested_merge_requests: 3,
+ todos: 4
+ )
+ end
+end