Welcome to mirror list, hosted at ThFree Co, Russian Federation.

shimo_menu_spec.rb « menus « projects « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 534267a329e3d53b58c1194910e990a30465ccad (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::ShimoMenu do
  let_it_be_with_reload(:project) { create(:project) }

  let(:context) { Sidebars::Projects::Context.new(current_user: project.owner, container: project) }

  subject(:shimo_menu) { described_class.new(context) }

  describe '#render?' do
    context 'without a valid Shimo integration' do
      it "doesn't render the menu" do
        expect(shimo_menu.render?).to be_falsey
      end
    end

    context 'with a valid Shimo integration' do
      let_it_be_with_reload(:shimo_integration) { create(:shimo_integration, project: project) }

      context 'when integration is active' do
        it 'renders the menu' do
          expect(shimo_menu.render?).to eq true
        end

        it 'renders menu link' do
          expected_url = Rails.application.routes.url_helpers.project_integrations_shimo_path(project)
          expect(shimo_menu.link).to eq expected_url
        end
      end

      context 'when integration is inactive' do
        before do
          shimo_integration.update!(active: false)
        end

        it "doesn't render the menu" do
          expect(shimo_menu.render?).to eq false
        end
      end
    end
  end
end