Commit 68e1a43d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '7866-fix-epics-promotion-helper' into 'master'

Remove epics field for projects not in groups

Closes #7866

See merge request gitlab-org/gitlab-ee!8919
parents 4d7d7462 7e60a9e2
......@@ -373,7 +373,5 @@ module Issuable
end
end
# We have to prepend into Issuable::ClassMethods, as otherwise the methods
# defined in EE::Issuable will available on Issuable, and not
# Issuable::ClassMethods (= what in turn is exposed to classes).
Issuable::ClassMethods.prepend(EE::Issuable)
Issuable.prepend(EE::Issuable) # rubocop: disable Cop/InjectEnterpriseEditionModule
Issuable::ClassMethods.prepend(EE::Issuable::ClassMethods)
......@@ -110,9 +110,5 @@ module LicenseHelper
!Gitlab::CurrentSettings.should_check_namespace_plan? && show_promotions? && show_callout?('promote_advanced_search_dismissed') && !License.feature_available?(:elastic_search)
end
def promote_feature?(feature_name)
!@project&.group&.feature_available?(feature_name) && show_promotions? && show_callout?(feature_name)
end
extend self
end
......@@ -4,15 +4,21 @@ module EE
module Issuable
extend ActiveSupport::Concern
def labels_hash
issue_labels = Hash.new { |h, k| h[k] = [] }
class_methods do
def labels_hash
issue_labels = Hash.new { |h, k| h[k] = [] }
relation = unscoped.where(id: self.select(:id)).eager_load(:labels)
relation.pluck(:id, 'labels.title').each do |issue_id, label|
issue_labels[issue_id] << label
relation = unscoped.where(id: self.select(:id)).eager_load(:labels)
relation.pluck(:id, 'labels.title').each do |issue_id, label|
issue_labels[issue_id] << label
end
issue_labels
end
end
issue_labels
def supports_epic?
is_a?(Issue) && project.group
end
end
end
- if issuable.project.feature_available?(:epics)
- if issuable.is_a?(Issue)
- if issuable.supports_epic?
- if issuable.project.group.feature_available?(:epics)
.block.epic
#js-vue-sidebar-item-epic
.title.hide-collapsed
Epic
= icon('spinner spin')
- else
= render 'shared/promotions/promote_epics'
- else
= render 'shared/promotions/promote_epics'
- promotion_feature = 'promote_epics_sidebar_dismissed'
- if promote_feature?(:epic) && show_promotions? && show_callout?(promotion_feature)
- if show_promotions? && show_callout?(promotion_feature)
.block.js-epics-sidebar-callout.promotion-issue-sidebar{ data: { uid: promotion_feature } }
.sidebar-collapsed-icon{ data: { toggle: "dropdown", target: ".js-epics-sidebar-callout" } }
%span{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: _('Epic') }
......
---
title: Remove epic field in sidebar for projects without groups
merge_request: 8919
author:
type: fixed
......@@ -8,27 +8,66 @@ describe 'Epic in issue sidebar', :js do
let(:issue) { create(:issue, project: project) }
let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) }
shared_examples 'epic in issue sidebar' do
it 'shows epic in issue sidebar for projects with group' do
visit project_issue_path(project, issue)
expect(page.find('.block.epic .value')).to have_content(epic.title)
end
it 'does not show epic in issue sidebar for personal projects' do
personal_project = create(:project, :public)
other_issue = create(:issue, project: personal_project)
visit project_issue_path(personal_project, other_issue)
expect_no_epic
end
end
context 'when epics available' do
before do
stub_licensed_features(epics: true)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'shows epic in issue sidebar' do
expect(page.find('.block.epic .value')).to have_content(epic.title)
it_behaves_like 'epic in issue sidebar'
context 'with namespaced plans' do
before do
stub_application_setting(check_namespace_plan: true)
end
context 'group has license' do
before do
create(:gitlab_subscription, :gold, namespace: group)
end
it_behaves_like 'epic in issue sidebar'
end
context 'group has no license' do
it 'does not show epic for public projects and groups' do
visit project_issue_path(project, issue)
expect_no_epic
end
end
end
end
context 'when epics unavailable' do
before do
stub_licensed_features(epics: false)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'does not show epic in issue sidebar' do
expect(page).not_to have_selector('.block.epic')
visit project_issue_path(project, issue)
expect_no_epic
end
end
def expect_no_epic
expect(page).not_to have_selector('.block.epic')
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Merge Request sidebar' do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :repository, :public, group: group) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
context 'when epics available' do
before do
stub_licensed_features(epics: true)
end
it 'does not show epics in MR sidebar' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_selector('.block.epic')
end
end
context 'when epics unavailable' do
before do
stub_licensed_features(epics: false)
end
it 'does not show epics promotion in MR sidebar' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_selector('.js-epics-sidebar-callout')
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