summaryrefslogtreecommitdiff
path: root/spec/presenters/event_presenter_spec.rb
blob: 79f5e3591411d334aa02f5dd9fa7a07e7cadc15b (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

require 'spec_helper'

describe EventPresenter do
  include Gitlab::Routing.url_helpers

  set(:group) { create(:group) }
  set(:project) { create(:project, group: group) }
  set(:target) { create(:milestone, project: project) }
  set(:group_event) { create(:event, :created, project: nil, group: group, target: target) }
  set(:project_event) { create(:event, :created, project: project, target: target) }

  describe '#resource_parent_name' do
    context 'with group event' do
      subject { group_event.present.resource_parent_name }

      it { is_expected.to eq(group.full_name) }
    end

    context 'with project label' do
      subject { project_event.present.resource_parent_name }

      it { is_expected.to eq(project.full_name) }
    end
  end

  describe '#target_link_options' do
    context 'with group event' do
      subject { group_event.present.target_link_options }

      it { is_expected.to eq([group, target]) }
    end

    context 'with project label' do
      subject { project_event.present.target_link_options }

      it { is_expected.to eq([group.becomes(Namespace), project, target]) }
    end
  end
end