2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe AnalyticsIssueEntity do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:entity_hash) do
|
|
|
|
{
|
|
|
|
total_time: "172802.724419",
|
|
|
|
title: "Eos voluptatem inventore in sed.",
|
|
|
|
iid: "1",
|
|
|
|
id: "1",
|
|
|
|
created_at: "2016-11-12 15:04:02.948604",
|
2019-10-12 21:52:04 +05:30
|
|
|
author: user,
|
|
|
|
project_path: project.path,
|
|
|
|
namespace_path: project.namespace.route.path
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
let(:request) { EntityRequest.new(entity: :merge_request) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
let(:entity) do
|
|
|
|
described_class.new(entity_hash, request: request, project: project)
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
shared_examples 'generic entity' do
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'contains the entity URL' do
|
|
|
|
expect(subject).to include(:url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the author' do
|
|
|
|
expect(subject).to include(:author)
|
|
|
|
end
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
it 'contains the project path' do
|
|
|
|
expect(subject).to include(:project_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the namespace full path' do
|
|
|
|
expect(subject).to include(:namespace_full_path)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'does not contain sensitive information' do
|
|
|
|
expect(subject).not_to include(/token/)
|
|
|
|
expect(subject).not_to include(/variables/)
|
|
|
|
end
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|