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
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
......@@ -130,8 +130,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
......
......@@ -81,34 +81,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