2019-09-30 09:06:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-14 17:05:13 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 06:09:01 +00:00
|
|
|
RSpec.describe AnalyticsIssueEntity do
|
2016-11-14 17:05:13 +00:00
|
|
|
let(:user) { create(:user) }
|
2016-11-16 11:01:10 +00:00
|
|
|
let(:entity_hash) do
|
2016-11-14 17:05:13 +00:00
|
|
|
{
|
|
|
|
total_time: "172802.724419",
|
|
|
|
title: "Eos voluptatem inventore in sed.",
|
|
|
|
iid: "1",
|
|
|
|
id: "1",
|
|
|
|
created_at: "2016-11-12 15:04:02.948604",
|
2019-07-04 14:42:31 +00:00
|
|
|
author: user,
|
2019-08-05 21:15:00 +00:00
|
|
|
project_path: project.path,
|
|
|
|
namespace_path: project.namespace.route.path
|
2016-11-14 17:05:13 +00:00
|
|
|
}
|
2016-11-16 11:01:10 +00:00
|
|
|
end
|
2016-11-14 17:05:13 +00:00
|
|
|
|
2019-07-04 14:42:31 +00:00
|
|
|
let(:request) { EntityRequest.new(entity: :merge_request) }
|
2016-11-14 17:05:13 +00:00
|
|
|
|
|
|
|
let(:entity) do
|
2016-11-15 08:59:35 +00:00
|
|
|
described_class.new(entity_hash, request: request, project: project)
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|
|
|
|
|
2020-08-11 15:10:08 +00:00
|
|
|
shared_examples 'generic entity' do
|
2016-11-14 17:05:13 +00:00
|
|
|
it 'contains the entity URL' do
|
|
|
|
expect(subject).to include(:url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the author' do
|
|
|
|
expect(subject).to include(:author)
|
|
|
|
end
|
|
|
|
|
2022-01-12 09:15:13 +00:00
|
|
|
it 'contains the project path' do
|
|
|
|
expect(subject).to include(:project_path)
|
|
|
|
end
|
|
|
|
|
2016-11-14 17:05:13 +00:00
|
|
|
it 'does not contain sensitive information' do
|
|
|
|
expect(subject).not_to include(/token/)
|
|
|
|
expect(subject).not_to include(/variables/)
|
|
|
|
end
|
|
|
|
end
|
2020-08-11 15:10:08 +00:00
|
|
|
|
|
|
|
context 'without subgroup' do
|
|
|
|
let_it_be(:project) { create(:project, name: 'my project') }
|
|
|
|
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
it_behaves_like 'generic entity'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with subgroup' do
|
|
|
|
let_it_be(:project) { create(:project, :in_subgroup, name: 'my project') }
|
|
|
|
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
it_behaves_like 'generic entity'
|
|
|
|
|
|
|
|
it 'has URL containing subgroup' do
|
|
|
|
expect(subject[:url]).to include("#{project.group.parent.name}/#{project.group.name}/my_project/")
|
|
|
|
end
|
|
|
|
end
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|