2019-09-30 05:06:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-14 12:05:13 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe AnalyticsIssueEntity do
|
2016-11-14 12:05:13 -05:00
|
|
|
let(:user) { create(:user) }
|
2016-11-16 06:01:10 -05:00
|
|
|
let(:entity_hash) do
|
2016-11-14 12:05:13 -05: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 10:42:31 -04:00
|
|
|
author: user,
|
2019-08-05 17:15:00 -04:00
|
|
|
project_path: project.path,
|
|
|
|
namespace_path: project.namespace.route.path
|
2016-11-14 12:05:13 -05:00
|
|
|
}
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2016-11-14 12:05:13 -05:00
|
|
|
|
2019-07-04 10:42:31 -04:00
|
|
|
let(:request) { EntityRequest.new(entity: :merge_request) }
|
2016-11-14 12:05:13 -05:00
|
|
|
|
|
|
|
let(:entity) do
|
2016-11-15 03:59:35 -05:00
|
|
|
described_class.new(entity_hash, request: request, project: project)
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
|
2020-08-11 11:10:08 -04:00
|
|
|
shared_examples 'generic entity' do
|
2016-11-14 12:05:13 -05:00
|
|
|
it 'contains the entity URL' do
|
|
|
|
expect(subject).to include(:url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the author' do
|
|
|
|
expect(subject).to include(:author)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not contain sensitive information' do
|
|
|
|
expect(subject).not_to include(/token/)
|
|
|
|
expect(subject).not_to include(/variables/)
|
|
|
|
end
|
|
|
|
end
|
2020-08-11 11:10:08 -04: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 12:05:13 -05:00
|
|
|
end
|