Commit 8e689a5f authored by Justin Ho's avatar Justin Ho

Fix reset button showing on new integrations

Only show Reset button when integration is already
saved and not for new integrations.
parent ae1f26ee
...@@ -102,7 +102,7 @@ module ServicesHelper ...@@ -102,7 +102,7 @@ module ServicesHelper
cancel_path: scoped_integrations_path, cancel_path: scoped_integrations_path,
can_test: integration.can_test?.to_s, can_test: integration.can_test?.to_s,
test_path: scoped_test_integration_path(integration), 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 end
...@@ -130,8 +130,8 @@ module ServicesHelper ...@@ -130,8 +130,8 @@ module ServicesHelper
!Gitlab.com? !Gitlab.com?
end end
def reset_integrations?(group: nil) def reset_integration?(integration, group: nil)
Feature.enabled?(:reset_integrations, group, type: :development) integration.persisted? && Feature.enabled?(:reset_integrations, group, type: :development)
end end
extend self extend self
......
...@@ -81,10 +81,13 @@ RSpec.describe ServicesHelper do ...@@ -81,10 +81,13 @@ RSpec.describe ServicesHelper do
end end
end end
describe '#reset_integrations?' do describe '#reset_integration?' do
let(:group) { nil } 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 context 'when `reset_integrations` is not enabled' do
it 'returns false' do it 'returns false' do
...@@ -112,4 +115,17 @@ RSpec.describe ServicesHelper do ...@@ -112,4 +115,17 @@ RSpec.describe ServicesHelper do
end end
end 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 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