debian-mirror-gitlab/spec/finders/boards/visits_finder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Boards::VisitsFinder do
2019-09-30 21:07:59 +05:30
describe '#latest' do
2018-12-13 13:39:08 +05:30
let(:user) { create(:user) }
context 'when a project board' do
let(:project) { create(:project) }
let(:project_board) { create(:board, project: project) }
2019-12-21 20:55:43 +05:30
subject(:finder) { described_class.new(project_board.resource_parent, user) }
2018-12-13 13:39:08 +05:30
it 'returns nil when there is no user' do
2019-09-30 21:07:59 +05:30
finder.current_user = nil
2018-12-13 13:39:08 +05:30
2019-09-30 21:07:59 +05:30
expect(finder.execute).to eq nil
2018-12-13 13:39:08 +05:30
end
it 'queries for most recent visit' do
expect(BoardProjectRecentVisit).to receive(:latest).once
2019-09-30 21:07:59 +05:30
finder.execute
2018-12-13 13:39:08 +05:30
end
2019-07-07 11:18:12 +05:30
it 'queries for last N visits' do
expect(BoardProjectRecentVisit).to receive(:latest).with(user, project, count: 5).once
2019-12-21 20:55:43 +05:30
described_class.new(project_board.resource_parent, user).latest(5)
2019-07-07 11:18:12 +05:30
end
2018-12-13 13:39:08 +05:30
end
context 'when a group board' do
let(:group) { create(:group) }
let(:group_board) { create(:board, group: group) }
2019-12-21 20:55:43 +05:30
subject(:finder) { described_class.new(group_board.resource_parent, user) }
2018-12-13 13:39:08 +05:30
it 'returns nil when there is no user' do
2019-09-30 21:07:59 +05:30
finder.current_user = nil
2018-12-13 13:39:08 +05:30
2019-09-30 21:07:59 +05:30
expect(finder.execute).to eq nil
2018-12-13 13:39:08 +05:30
end
it 'queries for most recent visit' do
expect(BoardGroupRecentVisit).to receive(:latest).once
2019-09-30 21:07:59 +05:30
finder.latest
2018-12-13 13:39:08 +05:30
end
2019-07-07 11:18:12 +05:30
it 'queries for last N visits' do
expect(BoardGroupRecentVisit).to receive(:latest).with(user, group, count: 5).once
2019-12-21 20:55:43 +05:30
described_class.new(group_board.resource_parent, user).latest(5)
2019-07-07 11:18:12 +05:30
end
2018-12-13 13:39:08 +05:30
end
end
end