Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6c9e6395
Commit
6c9e6395
authored
May 05, 2021
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'force-flag-generator' of gitlab.com:gitlab-org/gitlab into force-flag-generator
parents
e0f079b6
e9aa9281
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
doc/development/snowplow/event_dictionary_guide.md
doc/development/snowplow/event_dictionary_guide.md
+1
-1
lib/generators/gitlab/snowplow_event_definition_generator.rb
lib/generators/gitlab/snowplow_event_definition_generator.rb
+2
-2
spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb
...rators/gitlab/snowplow_event_definition_generator_spec.rb
+5
-6
No files found.
doc/development/snowplow/event_dictionary_guide.md
View file @
6c9e6395
...
...
@@ -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.
-
`--f
f
`
: Force flag to overwrite existing event definition.
-
`--f
orce
`
: Force flag to overwrite existing event definition.
```
shell
bundle
exec
rails generate gitlab:snowplow_event_definition
--category
Groups::EmailCampaignsController
--action
click
...
...
lib/generators/gitlab/snowplow_event_definition_generator.rb
View file @
6c9e6395
...
...
@@ -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
:f
f
,
type: :boolean
,
optional:
true
,
default:
false
,
desc:
'Force definition override'
class_option
:f
orce
,
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
[
:f
f
]
options
[
:f
orce
]
end
private
...
...
spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb
View file @
6c9e6395
...
...
@@ -38,21 +38,20 @@ RSpec.describe Gitlab::SnowplowEventDefinitionGenerator do
described_class
.
new
([],
generator_options
).
invoke_all
end
it
'overwrites event definition --f
f
flag set to true'
do
it
'overwrites event definition --f
orce
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
(
'f
f
'
=>
true
)).
invoke_all
described_class
.
new
([],
generator_options
.
merge
(
'f
orce
'
=>
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 --f
f
flag set to false'
do
expect
{
described_class
.
new
([],
generator_options
.
merge
(
'f
f
'
=>
false
)).
invoke_all
}
it
'raises error when --f
orce
flag set to false'
do
expect
{
described_class
.
new
([],
generator_options
.
merge
(
'f
orce
'
=>
false
)).
invoke_all
}
.
to
raise_error
(
StandardError
,
/Event definition already exists at/
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment