Commit 0682fe87 authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Ash McKenzie

Remove EE references from FOSS code

This removes references to EE only code from FOSS views.

Specs are added at the controller and view level to confirm the
behaviour.
parent c050d8c2
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class Admin::DevOpsReportController < Admin::ApplicationController class Admin::DevOpsReportController < Admin::ApplicationController
include Analytics::UniqueVisitsHelper include Analytics::UniqueVisitsHelper
helper_method :show_adoption?
track_unique_visits :show, target_id: 'i_analytics_dev_ops_score' track_unique_visits :show, target_id: 'i_analytics_dev_ops_score'
feature_category :devops_reports feature_category :devops_reports
...@@ -12,4 +14,10 @@ class Admin::DevOpsReportController < Admin::ApplicationController ...@@ -12,4 +14,10 @@ class Admin::DevOpsReportController < Admin::ApplicationController
@metric = DevOpsReport::Metric.order(:created_at).last&.present @metric = DevOpsReport::Metric.order(:created_at).last&.present
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def show_adoption?
false
end
end end
Admin::DevOpsReportController.prepend_if_ee('EE::Admin::DevOpsReportController')
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
.container .container
.gl-mt-3 .gl-mt-3
- feature_already_in_use = Analytics::DevopsAdoption::Segment.any? - if show_adoption?
- if Gitlab.ee? && Feature.enabled?(:devops_adoption_feature, default_enabled: feature_already_in_use) && License.feature_available?(:devops_adoption)
= render_if_exists 'admin/dev_ops_report/devops_tabs' = render_if_exists 'admin/dev_ops_report/devops_tabs'
- else - else
= render 'report' = render 'report'
......
---
title: Remove EE references from FOSS code
merge_request: 51832
author:
type: fixed
# frozen_string_literal: true
module EE
module Admin
module DevOpsReportController
def show_adoption?
feature_already_in_use = ::Analytics::DevopsAdoption::Segment.any?
::License.feature_available?(:devops_adoption) &&
(feature_already_in_use || ::Feature.enabled?(:devops_adoption_feature, default_enabled: false))
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::DevOpsReportController do
describe 'show_adoption?' do
it 'is false unless the license feature is disabledhttps://gitlab.com/gitlab-org/gitlab/-/issues/298884' do
expect(controller.show_adoption?).to be false
end
context 'the license feature is enabled' do
before do
stub_licensed_features(devops_adoption: true)
end
it 'is true if there are any segments' do
create(:devops_adoption_segment)
expect(controller.show_adoption?).to be true
end
it 'is true if the feature is enabled' do
expect(controller.show_adoption?).to be true
end
it 'is false if the feature is disabled' do
stub_feature_flags(devops_adoption_feature: false)
expect(controller.show_adoption?).to be false
end
end
end
end
...@@ -9,24 +9,40 @@ RSpec.describe 'admin/dev_ops_report/show.html.haml' do ...@@ -9,24 +9,40 @@ RSpec.describe 'admin/dev_ops_report/show.html.haml' do
stub_licensed_features(devops_adoption: true) stub_licensed_features(devops_adoption: true)
end end
context 'when no segment record is present' do context 'when show_adoption? returns false' do
it 'disables the feature' do before do
expect(Feature).to receive(:enabled?).with(:devops_adoption_feature, default_enabled: false).and_return(false) controller.singleton_class.class_eval do
protected
def show_adoption?
false
end
helper_method :show_adoption?
end
end
it 'disables the feature' do
render render
expect(rendered).not_to have_selector('#devops-adoption') expect(rendered).not_to have_selector('#devops-adoption')
end end
end end
context 'when at least one segment record is present' do context 'when show_adoption? returns true' do
before do before do
create(:devops_adoption_segment) controller.singleton_class.class_eval do
protected
def show_adoption?
true
end end
it 'enables the feature' do helper_method :show_adoption?
expect(Feature).to receive(:enabled?).with(:devops_adoption_feature, default_enabled: true).and_return(true) end
end
it 'enables the feature' do
render render
expect(rendered).to have_selector('#devops-adoption') expect(rendered).to have_selector('#devops-adoption')
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Admin::DevOpsReportController do RSpec.describe Admin::DevOpsReportController do
describe 'show_adoption?' do
it 'is always false' do
expect(controller.show_adoption?).to be false
end
end
describe 'GET #show' do describe 'GET #show' do
context 'as admin' do context 'as admin' do
let(:user) { create(:admin) } let(:user) { create(:admin) }
......
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