PageRenderTime 43ms CodeModel.GetById 13ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 1ms

/spec/finders/group_labels_finder_spec.rb

https://gitlab.com/tnir/gitlab-ce
Ruby | 42 lines | 28 code | 13 blank | 1 comment | 0 complexity | 6f4b44381ee532fb69b6c17796d8880f MD5 | raw file
 1# frozen_string_literal: true
 2
 3require 'spec_helper'
 4
 5describe GroupLabelsFinder, '#execute' do
 6  let!(:group) { create(:group) }
 7  let!(:user)  { create(:user) }
 8  let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) }
 9  let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) }
10
11  it 'returns all group labels sorted by name if no params' do
12    result = described_class.new(user, group).execute
13
14    expect(result.to_a).to match_array([label2, label1])
15  end
16
17  it 'returns all group labels sorted by name desc' do
18    result = described_class.new(user, group, sort: 'name_desc').execute
19
20    expect(result.to_a).to match_array([label2, label1])
21  end
22
23  it 'returns group labels that match search' do
24    result = described_class.new(user, group, search: 'Foo').execute
25
26    expect(result.to_a).to match_array([label1])
27  end
28
29  it 'returns group labels user subscribed to' do
30    label2.subscribe(user)
31
32    result = described_class.new(user, group, subscribed: 'true').execute
33
34    expect(result.to_a).to match_array([label2])
35  end
36
37  it 'returns second page of labels' do
38    result = described_class.new(user, group, page: '2').execute
39
40    expect(result.to_a).to match_array([])
41  end
42end