Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rspeicher/gitlab
  • reprazent/gitlab
  • mwasilewski-gitlab/gitlab
  • mlapierre/gitlab
  • gl-gitaly/gitlab
  • gitlab-org/gitlab
  • 1and1_ebusiness/gitlab-ee
  • marin/gitlab-ee
  • max-group/gitlab-ee
  • cirosantilli/gitlab-ee
  • cernvcs/gitlab-ee
  • chrisrohr/gitlab-ee
  • stanhu/gitlab-ee
  • ealcantara/gitlab
  • sijis/gitlab-ee
  • kalibyrn/gitlab-ee
  • bbodenmiller/gitlab-ee
  • cvd/gitlab-ee
  • alexwarren/gitlab-ee
  • j.seto/gitlab
  • cmiskell/gitlab
  • Ashley/gitlab-ee
  • kkm/gitlab-ee
  • haynes/gitlab-ee
  • dblessing/gitlab-ee
  • allison.browne/gitlab
  • singingwolfboy/gitlab-ee
  • coderhugo/gitlab-ee
  • axil/gitlab-ee
  • truongsinh/gitlab-ee
  • tensky/gitlab-ee
  • rymai/gitlab-ee
  • jt-gitlab/gitlab-ee
  • patricio/gitlab-ee
  • b.lashen/gitlab-ee
  • acroitor/gitlab
  • rosiv/gitlab-ee
  • sune-keller/gitlab-ee
  • wiget/gitlab-ee
  • bandel/gitlab-ee
  • e4r7hbug/gitlab-ee
  • chaosaffe/gitlab-ee
  • yannick-croissant/gitlab-ee
  • jameslopez/gitlab-ee
  • xellor/gitlab-ee
  • ymotiongroup/gitlab-ee
  • cwilcox/gitlab-ee
  • daniel.hoffmann/gitlab-ee
  • johnnyeric/gitlab-ee
  • pidge/gitlab-ee
  • Posp/gitlab-ee
  • jonafato/gitlab-ee
  • Quintasan/gitlab
  • shobra/gitlab-ee
  • sleepyknife/gitlab-ee
  • yorickpeterse/gitlab
  • abualy/gitlab-ee
  • ci-test-user-mk/gitlab
  • jogo/gitlab-ee
  • foxnewsnetwork/gitlab-ee
  • riemers/gitlab-ee
  • pacoguzman/gitlab-ee
  • usr01/gitlab-ee
  • samuel.bernard/gitlab-ee
  • codelust/gitlab-ee
  • takitak/gitlab-ee
  • ftasdelen/gitlab-ee
  • qhcthanh/gitlab-ee
  • clairton/gitlab-ee
  • cuongtm/gitlab-ee
  • m5/gitlab-ee
  • Sivapuram/gitlab-ee
  • sbeleidy/gitlab-ee
  • baparici/gitlab-ee
  • Hubbitus/gitlab-ee
  • lbennett/gitlab-ee
  • klml/gitlab-ee
  • jaydeland/gitlab-ee
  • lupine/gitlab-ee
  • leftathome/gitlab-ee
  • ianb/gitlab-ee
  • mumayank/gitlab-ee
  • nagoyamavps/gitlab-ee
  • pattyhama/gitlab-ee
  • momirza/gitlab-ee
  • BhavaniM/gitlab-ee
  • morefice/gitlab
  • splattael-staging/gitlab
  • toanalien/gitlab-ee
  • clever_usr_name/gitlab-ee
  • oscar-lopez/gitlab-ee
  • svansteenis/gitlab-ee
  • prashtest/gitlab-ee
  • bonsai/gitlab-ee
  • graingert/gitlab-ee
  • niijv/gitlab-ee
  • abdiasshaw/gitlab-ee
  • peter9208/gitlab-ee
  • gforcada/gitlab-ee
  • broftkd/gitlab-ee
  • mkobel/gitlab-ee
  • mikaelz/gitlab-ee
  • OdNairy/gitlab-ee
  • christinebeaubrun/gitlab-ee
  • haakoo/gitlab-ee
  • Rencs/gitlab-ee
  • marcia/gitlab-ee
  • dehvmartins/gitlab-ee
  • rouzbeh84/gitlab-ee
  • gjunker/gitlab-ee
  • nick.thomas/gitlab-ee
  • heijmans/gitlab-ee
  • s.ghafarpour/gitlab-ee
  • markglenfletcher1/gitlab-ee
  • Benno/gitlab-ee
  • s2gluser/gitlab-ee
  • hazelyang/gitlab-ee
  • dewetblomerus/gitlab-ee
  • chrisbelyea/gitlab-ee
  • nick.volynkin/gitlab-ee
  • sevenseacat/gitlab-ee
  • yuanchenxi95/gitlab-ee
  • andyli/gitlab-ee
  • nacredata/gitlab-ee
  • srkaycg_admin/gitlab-ee
  • tagyangyang/gitlab-ee
  • miroslav.meca/gitlab-ee
  • cafed00d/gitlab-ee
  • iOrange/gitlab-ee
  • shackledtodesk/gitlab-ee
  • kalleva/gitlab-ee
  • paulsen.jan/gitlab-ee
  • hu19891110/gitlab-ee
  • gmeans/gitlab-ee
  • nithin2/gitlab-ee
  • dbelova/gitlab-ee
  • GeorgConradi/gitlab-ee
  • iunet/gitlab-ee
  • ephemeric/gitlab-ee
  • wendy0402/gitlab-ee
  • phil7/gitlab-ee
  • Eichi4Eichler/gitlab-ee
  • Munken/gitlab-ee
  • clim/gitlab-ee
  • averyduffin/gitlab-ee
  • DKovel/gitlab-ee
  • katrinleinweber/gitlab-ee
  • tmaier/gitlab-ee
  • Shahriar_Rabbi/gitlab-ee
  • Stretch96/gitlab-ee
  • brennanroberts/gitlab-ee
  • sanyatuning/gitlab-ee
  • hkrutzer/gitlab-ee
  • visualrobots/gitlab-ee
  • jieme/gitlab-ee
  • vansch/gitlab-ee
  • smuthusamy.fivedtech/gitlab-ee
  • almtoolbox/gitlab-ee
  • niketgupta6590/gitlab-ee
  • d.demichelis/gitlab-ee
  • LeclercA/gitlab-ee
  • bpietraga/gitlab-ee
  • ivikash/gitlab-ee
  • TobbenTM/gitlab-ee
  • YarNayar/gitlab-ee
  • dcondrey/gitlab-ee
  • atronah/gitlab-ee
  • mindupper/gitlab-ee
  • zyfran/gitlab-ee
  • savitojs/gitlab-ee
  • vino.v/gitlab-ee
  • athar/gitlab-ee
  • me63/gitlab-ee
  • l00mi/gitlab-ee
  • trentontri/gitlab-ee
  • peterlebrun/gitlab-ee
  • gwawr/gitlab-ee
  • isolation85/gitlab-ee
  • timothyandrew/gitlab-ee
  • shawonsoyket439/gitlab-ee
  • afolson/gitlab-ee
  • ismail-s/gitlab-ee
  • peterramsing/gitlab-ee
  • kason/gitlab-ee
  • al1_andre/gitlab-ee
  • pchojnacki/gitlab-ee
  • juliusv/gitlab-ee
  • scallopedllama/gitlab-ee
  • frech/gitlab-ee
  • z9g9l9/gitlab-ee
  • jamiekaw/gitlab-ee
  • mrburrito/gitlab-ee
  • headcrabmeat/gitlab-ee
  • cristiantmbr/gitlab-ee
  • revuel/gitlab-ee
  • Nnidyu/gitlab-ee
  • MrCirwos/gitlab-ee
  • Gutenevv/gitlab-ee
  • jmeyo/gitlab-ee
  • ollie314/gitlab-ee
  • sang9402/gitlab-ee
  • mickael9/gitlab-ee
  • vsizov/gitlab-ee
  • dosuken123/gitlab-ee
  • geoandri/gitlab-ee
  • afrastgeek/gitlab-ee
  • steveschooncts/gitlab-ee
  • dinsaw/gitlab-ee
  • xqua/gitlab-ee
  • smith-kyle/gitlab-ee
  • Mattlk13/gitlab-ee
  • andy_b_84/gitlab-ee
  • raansari/gitlab-ee
  • abitduck/gitlab-ee
  • mgresko/gitlab-ee
  • sidewinder12s/gitlab-ee
  • andresca/gitlab-ee
  • ccrebolder/gitlab-ee
  • rodrigo.pereira1/gitlab-ee
  • mohideen.rahuman/gitlab-ee
  • hebbet/gitlab-ee
  • smcgivern/gitlab-ee
  • heapifyman/gitlab-ee
  • TeNNoX/gitlab-ee
  • herryLi/gitlab-ee
  • AlexKalinin/gitlab-ee
  • vincedmg/gitlab-ee
  • martflu/gitlab-ee
  • derik/gitlab-ee
  • Ruby-and-Friends/gitlab-ee
  • wojciechlisik/gitlab-ee
  • winniehell-gitlab/gitlab-ee
  • Vaidehee5/gitlab-ee
  • vignesh.ravichandran02/gitlab-ee
  • tanyan2004/gitlab-ee
  • gitlabproject_s/gitlab-ee
  • virth/gitlab-ee
  • tmlee/gitlab-ee
  • hwdegroot/gitlab-ee
  • kybae/gitlab-ee
  • xiaogang_gitlab/gitlab-ee
  • jabber/gitlab-ee
  • eswar.madhira/gitlab-ee
  • alshamiri2/gitlab-ee
  • ba2014sheer/gitlab-ee
  • paulcodiny/gitlab-ee
  • glabio/gitlab-ee
  • lenghan1991/gitlab-ee
  • peterl/gitlab-ee
  • lucianomx/gitlab-ee
  • jbrandhorst/gitlab-ee
  • abushoeb/gitlab-ee
  • shellthor/gitlab-ee
  • jameshclrk/gitlab-ee
  • jontdelorme/gitlab-ee
  • tzc_007/gitlab-ee
  • indobits/gitlab-ee
  • dturner_ts/gitlab-ee
  • gauravkk22/gitlab-ee
  • andy9775/gitlab-ee
  • vladel/gitlab-ee
  • hakulatata99/gitlab-ee
  • lee0824/gitlab-ee
  • pk-codebox-evo/gitlab-ee
  • feshu/gitlab-ee
  • techguru/gitlab-ee
  • ei-grad/gitlab-ee
  • mccomput3rfr3ak/gitlab-ee
  • winnetou/gitlab-ee
  • julian-poidevin/gitlab-ee
  • arihantar/gitlab-ee
  • Trilom/gitlab-ee
  • Waysb1/gitlab-ee
  • jjung/gitlab-ee
  • xiaole/gitlab-ee
  • kikipq/gitlab-ee
  • rpadovani/gitlab-ee
  • zsturgess/gitlab-ee
  • mishunov/gitlab
  • nodeable/gitlab-ee
  • m1guelpiedrafita/gitlab-ee
  • jonas1/gitlab-ee
  • imranh/gitlab-ee
  • vitor.tyburski/gitlab-ee
  • pavel-voronin/gitlab-ee
  • alizadeh/gitlab-ee
  • aaaaaaq/gitlab-ee
  • JaKXz/gitlab-ee
  • umirra/gitlab-ee
  • jjcarstens/gitlab-ee
  • jenibella/gitlab-ee
  • hnk/gitlab-ee
  • roccolangeweg/gitlab-ee
  • batok/gitlab-ee
  • rajgomase24/gitlab-ee
  • qmnguyen0711/gitlab
  • 413063135/gitlab-ee
  • josephmarty/gitlab-ee
  • rdumont/gitlab-ee
  • gucong3000/gitlab-ee
  • ckatanda/gitlab-ee
  • overflowsith/gitlab-ee
  • TheJaredWilcurt/gitlab-ee
  • Riktos/gitlab-ee
  • losingle/gitlab-ee
  • mlushpenko/gitlab-ee
  • ericy_ts/gitlab-ee
  • fadb/gitlab-ee
  • dbvid/gitlab-ee
  • thejacer87/gitlab-ee
  • eli.boyarski/gitlab-ee
  • baldwinSPC/gitlab-ee
  • baldwinmathew/gitlab-ee
  • gsmethells/gitlab-ee
  • funkypenguin/gitlab-ee
  • rrentfro/gitlab-ee
  • M1TKO/gitlab-ee
  • SuriyaaKudoIsc/gitlab-ee
  • lmsurprenant/gitlab-ee
  • kay54088/gitlab-ee
  • pablo.catalina/gitlab-ee
  • xji/gitlab-ee
  • iscorer/gitlab-ee
  • kenny-evitt/gitlab-ee
  • Francis_Jude/gitlab-ee
  • xukaierwen/gitlab-ee
  • mustafayildirim/gitlab-ee
  • hh1/gitlab-ee
  • clamp27/gitlab-ee
  • UIPCO/gitlab-ee
  • chaase/gitlab-ee
  • matt.faure/gitlab-ee
  • wstomv/gitlab-ee
  • childNode/gitlab-ee
  • LockiStrike/gitlab-ee
  • Habiballah786/gitlab-ee
  • natebird/gitlab-ee
  • tamcv/gitlab-ee
  • adligithub/gitlab-ee
  • SuperDragon317/gitlab-ee
  • pkoretic/gitlab-ee
  • schoh/gitlab-ee
  • kpankonen/gitlab-ee
  • madnut_ua/gitlab-ee
  • smoothsailing/gitlab-ee
  • TimoSolo/gitlab-ee
  • collen/gitlab-ee
  • 0_0_0/gitlab-ee
  • innerwhisper/gitlab-ee
  • issue-reproduce-forks/gitlab-ee
  • szpak/gitlab-ee
  • zullusa/gitlab-ee
  • jamatute/gitlab-ee
  • mauriciomeirelles/gitlab-ee
  • anarcat/gitlab-ee
  • Shura/gitlab-ee
  • polarise/gitlab-ee
  • ecbrodie/gitlab-ee
  • odromark/gitlab-ee
  • senk/gitlab-ee
  • hiroponz/gitlab-ee
  • rawkode/gitlab-ee
  • HaPPyWaLLaCe/gitlab-ee
  • FeditskiyRoman/gitlab-ee
  • slrz/gitlab-ee
  • realsobek/gitlab-ee
  • Eternal21/gitlab-ee
  • leungpeng/gitlab-ee
  • nprabhu02/gitlab-ee
  • CodingGroup/gitlab-ee
  • smhoekstra/gitlab-ee
  • zeih/gitlab-ee
  • biancaghiurutan/gitlab-ee
  • bstrong/gitlab-ee
  • nap/gitlab-ee
  • mollybeth/gitlab-ee
  • Jeismeier/gitlab-ee
  • bouland/gitlab-ee
  • poneytruand/gitlab-ee
  • robotmay/gitlab
380 results
Show changes
Commits on Source (1)
  • Charlie Ablett's avatar
    Expose epic weights sum [skip-ci] · 47dc3f43
    Charlie Ablett authored
    - add DescendentService abstract class
    - add issue weights sum scope
    - add descendent weight service
    - Refactor common spec shared examples into separate file
    - Add weight filter to scope (exclude nil or 0 weight issues)
    - Remove group filter to include all issues
    47dc3f43
Showing
with 245 additions and 64 deletions
Loading
Loading
@@ -1862,6 +1862,11 @@ type Epic implements Noteable {
"""
descendantCounts: EpicDescendantCount
 
"""
Total weight of open and closed descendant epic's issues
"""
descendantWeightSum: EpicDescendantWeights
"""
Description of the epic
"""
Loading
Loading
@@ -2178,6 +2183,18 @@ type EpicDescendantCount {
openedIssues: Int
}
 
type EpicDescendantWeights {
"""
Total weight of completed (closed) issues in this epic, including epic descendants
"""
closedIssues: Int
"""
Total weight of opened issues in this epic, including epic descendants
"""
openedIssues: Int
}
"""
An edge in a connection.
"""
Loading
Loading
Loading
Loading
@@ -4889,6 +4889,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "descendantWeightSum",
"description": "Total weight of open and closed descendant epic's issues",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "EpicDescendantWeights",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "description",
"description": "Description of the epic",
Loading
Loading
@@ -12990,6 +13004,47 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "EpicDescendantWeights",
"description": null,
"fields": [
{
"name": "closedIssues",
"description": "Total weight of completed (closed) issues in this epic, including epic descendants",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "openedIssues",
"description": "Total weight of opened issues in this epic, including epic descendants",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "TimelogConnection",
Loading
Loading
Loading
Loading
@@ -294,6 +294,7 @@ Represents an epic.
| `closedAt` | Time | Timestamp of the epic's closure |
| `createdAt` | Time | Timestamp of the epic's creation |
| `descendantCounts` | EpicDescendantCount | Number of open and closed descendant epics and issues |
| `descendantWeightSum` | EpicDescendantWeights | Total weight of open and closed descendant epic's issues |
| `description` | String | Description of the epic |
| `downvotes` | Int! | Number of downvotes the epic has received |
| `dueDate` | Time | Due date of the epic |
Loading
Loading
@@ -334,6 +335,13 @@ Counts of descendent epics.
| `openedEpics` | Int | Number of opened sub-epics |
| `openedIssues` | Int | Number of opened epic issues |
 
## EpicDescendantWeights
| Name | Type | Description |
| --- | ---- | ---------- |
| `closedIssues` | Int | Total weight of completed (closed) issues in this epic, including epic descendants |
| `openedIssues` | Int | Total weight of opened issues in this epic, including epic descendants |
## EpicIssue
 
Relationship between an epic and an issue
Loading
Loading
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class EpicDescendantWeightSumType < BaseObject
graphql_name 'EpicDescendantWeights'
field :opened_issues, GraphQL::INT_TYPE, null: true,
description: 'Total weight of opened issues in this epic, including epic descendants'
field :closed_issues, GraphQL::INT_TYPE, null: true,
description: 'Total weight of completed (closed) issues in this epic, including epic descendants'
end
# rubocop: enable Graphql/AuthorizeTypes
end
Loading
Loading
@@ -126,6 +126,12 @@ class EpicType < BaseObject
Epics::DescendantCountService.new(epic, ctx[:current_user])
end
 
field :descendant_weight_sum, Types::EpicDescendantWeightSumType, null: true, complexity: 10,
description: "Total weight of open and closed descendant epic's issues",
resolve: -> (epic, args, ctx) do
Epics::DescendantWeightService.new(epic, ctx[:current_user])
end
field :health_status,
::Types::HealthStatusEnum,
null: true,
Loading
Loading
Loading
Loading
@@ -21,6 +21,8 @@ module Issue
scope :order_weight_asc, -> { reorder ::Gitlab::Database.nulls_last_order('weight') }
scope :order_created_at_desc, -> { reorder(created_at: :desc) }
scope :service_desk, -> { where(author: ::User.support_bot) }
scope :weight_total_by_state, -> { reorder(nil).where('weight IS NOT NULL AND weight > 0').group(:state_id).sum(:weight) }
scope :no_epic, -> { left_outer_joins(:epic_issue).where(epic_issues: { epic_id: nil }) }
scope :in_epics, ->(epics) do
issue_ids = EpicIssue.where(epic_id: epics).select(:issue_id)
Loading
Loading
# frozen_string_literal: true
 
module Epics
class DescendantCountService
include Gitlab::Utils::StrongMemoize
attr_reader :epic, :current_user
def initialize(epic, current_user)
@epic = epic
@current_user = current_user
end
class DescendantCountService < DescendantService
def opened_epics
epics_count.fetch(Epic.state_ids[:opened], 0)
end
Loading
Loading
@@ -44,14 +35,5 @@ def issues_count
IssuesFinder.new(current_user).execute.in_epics(accessible_epics).counts_by_state
end
end
def accessible_epics
strong_memoize(:epics) do
epics = epic.base_and_descendants
epic_groups = Group.for_epics(epics)
groups = Group.groups_user_can_read_epics(epic_groups, current_user, same_root: true)
epics.in_selected_groups(groups)
end
end
end
end
# frozen_string_literal: true
module Epics
class DescendantService
include Gitlab::Utils::StrongMemoize
def initialize(epic, current_user)
@epic = epic
@current_user = current_user
end
private
attr_reader :epic, :current_user
def accessible_epics
strong_memoize(:epics) do
epic.base_and_descendants
end
end
end
end
# frozen_string_literal: true
module Epics
class DescendantWeightService < DescendantService
def opened_issues
issues_weight_total.fetch(Epic.state_ids[:opened], 0)
end
def closed_issues
issues_weight_total.fetch(Epic.state_ids[:closed], 0)
end
private
def issues_weight_total
strong_memoize(:issues_weight_total) do
IssuesFinder.new(current_user).execute.in_epics(accessible_epics).weight_total_by_state
end
end
end
end
---
title: Show weight and progress information in roadmap epic bars
merge_request: 22284
author:
type: added
Loading
Loading
@@ -11,7 +11,7 @@
closed_at created_at updated_at children has_children has_issues
web_path web_url relation_path reference issues user_permissions
notes discussions relative_position subscribed participants
descendant_counts upvotes downvotes health_status
descendant_counts upvotes downvotes descendant_weight_sum health_status
]
end
 
Loading
Loading
Loading
Loading
@@ -615,4 +615,37 @@
end
 
it_behaves_like 'having health status'
describe ".weight_total_by_state" do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, namespace: group) }
let_it_be(:subgroup) { create(:group, :private, parent: group)}
let_it_be(:subproject) { create(:project, namespace: subgroup) }
# open, public
let_it_be(:issue1) { create(:issue, project: project, weight: 1) }
let_it_be(:issue2) { create(:issue, project: project, weight: 1) }
# closed
let_it_be(:issue3) { create(:issue, project: project, weight: 1, state: :closed) }
let_it_be(:issue4) { create(:issue, project: project, weight: 1, state: :closed) }
# confidential
let_it_be(:issue5) { create(:issue, project: project, weight: 1, confidential: true) }
let_it_be(:issue6) { create(:issue, project: project, weight: 1, confidential: true) }
# in private subgroup
let_it_be(:issue7) { create(:issue, project: project, weight: 1) }
let_it_be(:issue8) { create(:issue, project: project, weight: 1) }
# subgroup, confidential
let_it_be(:issue9) { create(:issue, project: project, weight: 1, confidential: true) }
let_it_be(:issue10) { create(:issue, project: project, weight: 1, confidential: true) }
# nil weight doesn't break it
let_it_be(:issue1) { create(:issue, project: project, weight: 0) }
let_it_be(:issue2) { create(:issue, project: project, weight: nil) }
it 'sums all the weights, even confidential, or in private groups' do
opened_state_id = described_class.available_states[:opened]
closed_state_id = described_class.available_states[:closed]
expected_result = { opened_state_id => 8, closed_state_id => 2 }
expect(project.issues.weight_total_by_state).to eq expected_result
end
end
end
Loading
Loading
@@ -3,59 +3,19 @@
require 'spec_helper'
 
describe Epics::DescendantCountService do
let_it_be(:group) { create(:group, :public)}
let_it_be(:subgroup) { create(:group, :private, parent: group)}
let_it_be(:user) { create(:user) }
let_it_be(:parent_epic) { create(:epic, group: group) }
let_it_be(:epic1) { create(:epic, group: subgroup, parent: parent_epic, state: :opened) }
let_it_be(:epic2) { create(:epic, group: subgroup, parent: parent_epic, state: :closed) }
let_it_be(:project) { create(:project, :private, group: group)}
let_it_be(:issue1) { create(:issue, project: project, state: :opened) }
let_it_be(:issue2) { create(:issue, project: project, state: :closed) }
let_it_be(:issue3) { create(:issue, project: project, state: :opened) }
let_it_be(:issue4) { create(:issue, project: project, state: :closed) }
let_it_be(:epic_issue1) { create(:epic_issue, epic: parent_epic, issue: issue1) }
let_it_be(:epic_issue2) { create(:epic_issue, epic: parent_epic, issue: issue2) }
let_it_be(:epic_issue3) { create(:epic_issue, epic: epic1, issue: issue3) }
let_it_be(:epic_issue4) { create(:epic_issue, epic: epic2, issue: issue4) }
subject { described_class.new(parent_epic, user) }
shared_examples 'descendants state count' do |method, expected_count|
before do
stub_licensed_features(epics: true)
end
it 'does not count inaccessible epics' do
expect(subject.public_send(method)).to eq 0
end
context 'when authorized' do
before do
subgroup.add_developer(user)
project.add_developer(user)
end
it 'returns correct number of epics' do
expect(subject.public_send(method)).to eq expected_count
end
end
end
describe '#opened_epics' do
it_behaves_like 'descendants state count', :opened_epics, 1
it_behaves_like 'descendants total', :opened_epics, 1
end
 
describe '#closed_epics' do
it_behaves_like 'descendants state count', :closed_epics, 1
it_behaves_like 'descendants total', :closed_epics, 1
end
 
describe '#opened_issues' do
it_behaves_like 'descendants state count', :opened_issues, 2
it_behaves_like 'descendants total', :opened_issues, 2
end
 
describe '#closed_issues' do
it_behaves_like 'descendants state count', :closed_issues, 2
it_behaves_like 'descendants total', :closed_issues, 2
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Epics::DescendantWeightService do
describe '#opened_issues' do
it_behaves_like 'descendants total', :opened_issues, 10
end
describe '#closed_issues' do
it_behaves_like 'descendants total', :closed_issues, 14
end
end
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'descendants total' do |method, expected_result|
let_it_be(:group) { create(:group, :public)}
let_it_be(:subgroup) { create(:group, :private, parent: group)}
let_it_be(:user) { create(:user) }
let_it_be(:parent_epic) { create(:epic, group: group) }
let_it_be(:epic1) { create(:epic, group: subgroup, parent: parent_epic, state: :opened) }
let_it_be(:epic2) { create(:epic, group: subgroup, parent: parent_epic, state: :closed) }
let_it_be(:project) { create(:project, :private, group: group)}
let_it_be(:issue1) { create(:issue, project: project, state: :opened, weight: 3) }
let_it_be(:issue2) { create(:issue, project: project, state: :closed, weight: 5) }
let_it_be(:issue3) { create(:issue, project: project, state: :opened, weight: 7) }
let_it_be(:issue4) { create(:issue, project: project, state: :closed, weight: 9) }
let_it_be(:epic_issue1) { create(:epic_issue, epic: parent_epic, issue: issue1) }
let_it_be(:epic_issue2) { create(:epic_issue, epic: parent_epic, issue: issue2) }
let_it_be(:epic_issue3) { create(:epic_issue, epic: epic1, issue: issue3) }
let_it_be(:epic_issue4) { create(:epic_issue, epic: epic2, issue: issue4) }
subject { described_class.new(parent_epic, user) }
before do
stub_licensed_features(epics: true)
end
it 'counts inaccessible epics' do
expect(subject.public_send(method)).to eq 1
end
context 'when authorized' do
before do
subgroup.add_developer(user)
project.add_developer(user)
end
it "returns correct #{method}" do
expect(subject.public_send(method)).to eq expected_result
end
end
end