summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/cycle_analytics/updater_spec.rb
blob: eff54cd369270ae4db769fc28292d9039c35a779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'spec_helper'

describe Gitlab::CycleAnalytics::Updater do
  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