Commit 29713000 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '298884-fix-broken-foss' into 'master'

Remove EE references from FOSS view [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!51832
parents c67d0826 c8092cdc
...@@ -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 if license feature 'devops_adoption' is disabled" do
expect(controller.show_adoption?).to be false
end
context "'devops_adoption' 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 'devops_adoption_feature' feature is enabled" do
expect(controller.show_adoption?).to be true
end
it "is false if the 'devops_adoption_feature' 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
helper_method :show_adoption?
end
end end
it 'enables the feature' do it 'enables the feature' do
expect(Feature).to receive(:enabled?).with(:devops_adoption_feature, default_enabled: true).and_return(true)
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