summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorAlexandru Croitor <acroitor@gitlab.com>2019-06-17 15:58:48 +0300
committerAlexandru Croitor <acroitor@gitlab.com>2019-06-26 12:28:00 +0300
commit0f6c42c5ce165dadf1976ae15a043b87ca533618 (patch)
tree9220ed5a8eb628ca3c5170a0d5f9400870538797 /spec/finders
parent2b9ddc2f99bc0a49967c9ccc5b79ccc53e7559b4 (diff)
downloadgitlab-ce-0f6c42c5ce165dadf1976ae15a043b87ca533618.tar.gz
Move Multiple Issue Boards for Projects to Core53811-issue-boards-to-core-projects-backend-ce
Refactor code to allow multiple issue boards management for projects in CE
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/boards/visits_finder_spec.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/finders/boards/visits_finder_spec.rb b/spec/finders/boards/visits_finder_spec.rb
new file mode 100644
index 00000000000..4d40f4826f8
--- /dev/null
+++ b/spec/finders/boards/visits_finder_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Boards::VisitsFinder do
+ describe '#latest' do
+ let(:user) { create(:user) }
+
+ context 'when a project board' do
+ let(:project) { create(:project) }
+ let(:project_board) { create(:board, project: project) }
+
+ subject(:finder) { described_class.new(project_board.parent, user) }
+
+ it 'returns nil when there is no user' do
+ finder.current_user = nil
+
+ expect(finder.execute).to eq nil
+ end
+
+ it 'queries for most recent visit' do
+ expect(BoardProjectRecentVisit).to receive(:latest).once
+
+ finder.execute
+ end
+
+ it 'queries for last N visits' do
+ expect(BoardProjectRecentVisit).to receive(:latest).with(user, project, count: 5).once
+
+ described_class.new(project_board.parent, user).latest(5)
+ end
+ end
+
+ context 'when a group board' do
+ let(:group) { create(:group) }
+ let(:group_board) { create(:board, group: group) }
+
+ subject(:finder) { described_class.new(group_board.parent, user) }
+
+ it 'returns nil when there is no user' do
+ finder.current_user = nil
+
+ expect(finder.execute).to eq nil
+ end
+
+ it 'queries for most recent visit' do
+ expect(BoardGroupRecentVisit).to receive(:latest).once
+
+ finder.latest
+ end
+
+ it 'queries for last N visits' do
+ expect(BoardGroupRecentVisit).to receive(:latest).with(user, group, count: 5).once
+
+ described_class.new(group_board.parent, user).latest(5)
+ end
+ end
+ end
+end