summaryrefslogtreecommitdiff
path: root/spec/presenters/issue_presenter_spec.rb
blob: f08cd0f202658e26074d4dcd37bb7044fa2b852f (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
42
43
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe IssuePresenter do
  include Gitlab::Routing.url_helpers

  let(:user)      { create(:user) }
  let(:group)     { create(:group) }
  let(:project)   { create(:project, group: group) }
  let(:issue)     { create(:issue, project: project) }
  let(:presenter) { described_class.new(issue, current_user: user) }

  before do
    group.add_developer(user)
  end

  describe '#web_url' do
    it 'returns correct path' do
      expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
    end
  end

  describe '#subscribed?' do
    subject { presenter.subscribed? }

    it 'returns not subscribed' do
      is_expected.to be(false)
    end

    it 'returns subscribed' do
      create(:subscription, user: user, project: project, subscribable: issue, subscribed: true)

      is_expected.to be(true)
    end
  end

  describe '#issue_path' do
    it 'returns correct path' do
      expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
    end
  end
end