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

latest_service_spec.rb « visits « boards « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e55d599e2cc61f16167f7dd46133085d802c9bbd (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
47
# frozen_string_literal: true

require 'spec_helper'

describe Boards::Visits::LatestService do
  describe '#execute' do
    let(:user) { create(:user) }

    context 'when a project board' do
      let(:project)       { create(:project) }
      let(:project_board) { create(:board, project: project) }

      subject(:service) { described_class.new(project_board.parent, user) }

      it 'returns nil when there is no user' do
        service.current_user = nil

        expect(service.execute).to eq nil
      end

      it 'queries for most recent visit' do
        expect(BoardProjectRecentVisit).to receive(:latest).once

        service.execute
      end
    end

    context 'when a group board' do
      let(:group)       { create(:group) }
      let(:group_board) { create(:board, group: group) }

      subject(:service) { described_class.new(group_board.parent, user) }

      it 'returns nil when there is no user' do
        service.current_user = nil

        expect(service.execute).to eq nil
      end

      it 'queries for most recent visit' do
        expect(BoardGroupRecentVisit).to receive(:latest).once

        service.execute
      end
    end
  end
end