Commit 2c060a54 authored by Kushal Pandya's avatar Kushal Pandya

jprovaznik: Add `row_count` to helper

parent ef10484f
......@@ -17,7 +17,13 @@ class EpicsFinder < IssuableFinder
end
def row_count
execute.count
count = execute.count
# When filtering by multiple labels, count returns a hash of
# records grouped by id - so we just have to get length of the Hash.
# Once we have state for epics, we can use default issuables row_count
# method.
count.is_a?(Hash) ? count.length : count
end
# we don't have states for epics for now this method (#4017)
......
......@@ -130,4 +130,22 @@ describe EpicsFinder do
end
end
end
describe '#row_count' do
let(:label) { create(:label) }
let(:label2) { create(:label) }
let!(:labeled_epic) { create(:labeled_epic, group: group, labels: [label]) }
let!(:labeled_epic2) { create(:labeled_epic, group: group, labels: [label, label2]) }
before do
group.add_developer(search_user)
stub_licensed_features(epics: true)
end
it 'returns number of rows when epics are grouped' do
params = { group_id: group.id, label_name: [label.title, label2.title] }
expect(described_class.new(search_user, params).row_count).to eq(1)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment