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,10 +49,13 @@ 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 integration is existing record' do
let_it_be(:integration) { create(:jira_service) }
context 'when `reset_integrations` is not enabled' do
it 'returns false' do
......@@ -80,4 +83,17 @@ RSpec.describe ServicesHelper do
end
end
end
context 'when integration is a new record' do
let_it_be(:integration) { build(:jira_service) }
context 'when `reset_integrations` is enabled' do
it 'returns false' do
stub_feature_flags(reset_integrations: true)
is_expected.to eq(false)
end
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