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,34 +81,50 @@ RSpec.describe ServicesHelper do ...@@ -81,34 +81,50 @@ 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 `reset_integrations` is not enabled' do context 'when integration is existing record' do
it 'returns false' do let_it_be(:integration) { create(:jira_service) }
stub_feature_flags(reset_integrations: false)
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
end
context 'when `reset_integrations` is enabled' do context 'when `reset_integrations` is enabled' do
it 'returns true' do it 'returns true' do
stub_feature_flags(reset_integrations: true) 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
end end
context 'when `reset_integrations` is enabled for a group' do context 'when integration is a new record' do
let(:group) { build_stubbed(:group) } let_it_be(:integration) { build(:jira_service) }
it 'returns true' do context 'when `reset_integrations` is enabled' do
stub_feature_flags(reset_integrations: group) it 'returns false' do
stub_feature_flags(reset_integrations: true)
is_expected.to eq(true) is_expected.to eq(false)
end
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