2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-18 07:00:38 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::CycleAnalytics::Updater do
|
2016-11-18 07:00:38 -05:00
|
|
|
describe 'updates authors' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:events) { [{ 'author_id' => user.id }] }
|
|
|
|
|
|
|
|
it 'maps the correct user' do
|
|
|
|
described_class.update!(events, from: 'author_id', to: 'author', klass: User)
|
|
|
|
|
|
|
|
expect(events.first['author']).to eq(user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'updates builds' do
|
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
let(:events) { [{ 'id' => build.id }] }
|
|
|
|
|
|
|
|
it 'maps the correct build' do
|
|
|
|
described_class.update!(events, from: 'id', to: 'build', klass: ::Ci::Build)
|
|
|
|
|
|
|
|
expect(events.first['build']).to eq(build)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|