Commit 67688519 authored by Stan Hu's avatar Stan Hu

Merge branch 'justin_ho-fix-reset-integrations-showing-on-new-integrations' into 'master'

Fix reset button showing on new integrations

See merge request gitlab-org/gitlab!49603
parents f4612aa4 8e689a5f
......@@ -102,7 +102,7 @@ module ServicesHelper
cancel_path: scoped_integrations_path,
can_test: integration.can_test?.to_s,
test_path: scoped_test_integration_path(integration),
reset_path: reset_integrations?(group: group) ? scoped_reset_integration_path(integration, group: group) : ''
reset_path: reset_integration?(integration, group: group) ? scoped_reset_integration_path(integration, group: group) : ''
}
end
......@@ -126,8 +126,8 @@ module ServicesHelper
!Gitlab.com?
end
def reset_integrations?(group: nil)
Feature.enabled?(:reset_integrations, group, type: :development)
def reset_integration?(integration, group: nil)
integration.persisted? && Feature.enabled?(:reset_integrations, group, type: :development)
end
extend self
......
......@@ -49,34 +49,50 @@ RSpec.describe ServicesHelper do
end
end
describe '#reset_integrations?' do
describe '#reset_integration?' do
let(:group) { nil }
subject { helper.reset_integrations?(group: group) }
subject { helper.reset_integration?(integration, group: group) }
context 'when `reset_integrations` is not enabled' do
it 'returns false' do
stub_feature_flags(reset_integrations: false)
context 'when integration is existing record' do
let_it_be(:integration) { create(:jira_service) }
is_expected.to eq(false)
context 'when `reset_integrations` is not enabled' do
it 'returns false' do
stub_feature_flags(reset_integrations: false)
is_expected.to eq(false)
end
end
end
context 'when `reset_integrations` is enabled' do
it 'returns true' do
stub_feature_flags(reset_integrations: true)
context 'when `reset_integrations` is enabled' do
it 'returns true' do
stub_feature_flags(reset_integrations: true)
is_expected.to eq(true)
is_expected.to eq(true)
end
end
context 'when `reset_integrations` is enabled for a group' do
let(:group) { build_stubbed(:group) }
it 'returns true' do
stub_feature_flags(reset_integrations: group)
is_expected.to eq(true)
end
end
end
context 'when `reset_integrations` is enabled for a group' do
let(:group) { build_stubbed(:group) }
context 'when integration is a new record' do
let_it_be(:integration) { build(:jira_service) }
it 'returns true' do
stub_feature_flags(reset_integrations: group)
context 'when `reset_integrations` is enabled' do
it 'returns false' do
stub_feature_flags(reset_integrations: true)
is_expected.to eq(true)
is_expected.to eq(false)
end
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