Commit 6c9e6395 authored by Rajendra Kadam's avatar Rajendra Kadam

Merge branch 'force-flag-generator' of gitlab.com:gitlab-org/gitlab into force-flag-generator

parents e0f079b6 e9aa9281
......@@ -86,7 +86,7 @@ The generator takes three options:
- `--ee`: Indicates if the event is for EE.
- `--category=CATEGORY`: Indicates the `category` of the event.
- `--action=ACTION`: Indicates the `action` of the event.
- `--ff`: Force flag to overwrite existing event definition.
- `--force`: Force flag to overwrite existing event definition.
```shell
bundle exec rails generate gitlab:snowplow_event_definition --category Groups::EmailCampaignsController --action click
......
......@@ -14,7 +14,7 @@ module Gitlab
class_option :ee, type: :boolean, optional: true, default: false, desc: 'Indicates if event is for ee'
class_option :category, type: :string, optional: false, desc: 'Category of the event'
class_option :action, type: :string, optional: false, desc: 'Action of the event'
class_option :ff, type: :boolean, optional: true, default: false, desc: 'Force definition override'
class_option :force, type: :boolean, optional: true, default: false, desc: 'Force definition override'
def create_event_file
raise "Event definition already exists at #{file_path}" if definition_exists? && !force_definition_override?
......@@ -43,7 +43,7 @@ module Gitlab
end
def force_definition_override?
options[:ff]
options[:force]
end
private
......
......@@ -38,21 +38,20 @@ RSpec.describe Gitlab::SnowplowEventDefinitionGenerator do
described_class.new([], generator_options).invoke_all
end
it 'overwrites event definition --ff flag set to true' do
it 'overwrites event definition --force flag set to true' do
sample_event = ::Gitlab::Config::Loader::Yaml.new(fixture_file(File.join(sample_event_dir, 'sample_event.yml'))).load_raw!
sample_event["label_description"] = "some description"
stub_const('Gitlab::VERSION', '13.11.0-pre')
described_class.new([], generator_options.merge('ff' => true)).invoke_all
described_class.new([], generator_options.merge('force' => true)).invoke_all
event_definition_path = File.join(ce_temp_dir, 'groups__email_campaigns_controller_click.yml')
event_data = ::Gitlab::Config::Loader::Yaml.new(File.read(event_definition_path)).load_raw!
event_data["label_description"] = "some description"
expect(event_data).to eq(sample_event)
end
it 'raises error when --ff flag set to false' do
expect { described_class.new([], generator_options.merge('ff' => false)).invoke_all }
it 'raises error when --force flag set to false' do
expect { described_class.new([], generator_options.merge('force' => false)).invoke_all }
.to raise_error(StandardError, /Event definition already exists at/)
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