summaryrefslogtreecommitdiff
path: root/spec/lib/api/entities/release_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/api/entities/release_spec.rb')
-rw-r--r--spec/lib/api/entities/release_spec.rb34
1 files changed, 18 insertions, 16 deletions
diff --git a/spec/lib/api/entities/release_spec.rb b/spec/lib/api/entities/release_spec.rb
index f0bbaa35efe..c45dbc15856 100644
--- a/spec/lib/api/entities/release_spec.rb
+++ b/spec/lib/api/entities/release_spec.rb
@@ -4,26 +4,29 @@ require 'spec_helper'
describe API::Entities::Release do
let_it_be(:project) { create(:project) }
- let_it_be(:user) { create(:user) }
- let(:entity) { described_class.new(release, current_user: user) }
-
- describe 'evidence' do
- let(:release) { create(:release, :with_evidence, project: project) }
-
- subject { entity.as_json }
+ let_it_be(:release) { create(:release, :with_evidence, project: project) }
+ let(:evidence) { release.evidences.first }
+ let(:user) { create(:user) }
+ let(:entity) { described_class.new(release, current_user: user).as_json }
+ describe 'evidences' do
context 'when the current user can download 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)
- expect(subject[:evidence_sha]).to eq(release.evidence_sha)
- expect(subject[:assets][:evidence_file_path]).to eq(
- Gitlab::Routing.url_helpers.evidence_project_release_url(project,
- release.tag,
- format: :json)
- )
+ expect(entity_evidence[:sha]).to eq(evidence.summary_sha)
+ expect(entity_evidence[:collected_at]).to eq(evidence.collected_at)
+ expect(entity_evidence[:filepath]).to eq(
+ Gitlab::Routing.url_helpers.namespace_project_evidence_url(
+ namespace_id: project.namespace,
+ project_id: project,
+ tag: release,
+ id: evidence.id,
+ format: :json))
end
end
@@ -33,8 +36,7 @@ describe API::Entities::Release do
allow(Ability).to receive(:allowed?)
.with(user, :download_code, project).and_return(false)
- expect(subject.keys).not_to include(:evidence_sha)
- expect(subject[:assets].keys).not_to include(:evidence_file_path)
+ expect(entity.keys).not_to include(:evidences)
end
end
end
@@ -45,7 +47,7 @@ describe API::Entities::Release do
let(:issue_title) { 'title="%s"' % issue.title }
let(:release) { create(:release, project: project, description: "Now shipping #{issue.to_reference}") }
- subject(:description_html) { entity.as_json[:description_html] }
+ subject(:description_html) { entity.as_json['description_html'] }
it 'renders special references if current user has access' do
project.add_reporter(user)