summaryrefslogtreecommitdiff
path: root/spec/helpers/releases_helper_spec.rb
blob: ff820b3cc95aaf68667d29a914e512046dc47e7c (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
44
45
46
# frozen_string_literal: true

require 'spec_helper'

describe ReleasesHelper do
  describe '#illustration' do
    it 'returns the correct image path' do
      expect(helper.illustration).to match(/illustrations\/releases-(\w+)\.svg/)
    end
  end

  describe '#help_page' do
    it 'returns the correct link to the help page' do
      expect(helper.help_page).to include('user/project/releases/index')
    end
  end

  context 'url helpers' do
    let(:project) { build(:project, namespace: create(:group)) }

    before do
      helper.instance_variable_set(:@project, project)
    end

    describe '#url_for_merge_requests' do
      it 'returns the the correct link with the correct parameters' do
        path = "#{project.group.path}/#{project.path}/merge_requests?scope=all&state=opened"
        expect(helper.url_for_merge_requests).to include(path)
      end
    end

    describe '#url_for_issues' do
      it 'returns the the correct link with the correct parameters' do
        path = "#{project.group.path}/#{project.path}/issues?scope=all&state=opened"
        expect(helper.url_for_issues).to include(path)
      end
    end

    describe '#data_for_releases_page' do
      it 'has the needed data to display release blocks' do
        keys = %i(project_id illustration_path documentation_path merge_requests_url issues_url)
        expect(helper.data_for_releases_page.keys).to eq(keys)
      end
    end
  end
end