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
7e3a1eb9
Commit
7e3a1eb9
authored
Jan 06, 2021
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove NamespaceOnboardingAction model
Because it is no longer needed
parent
db82a385
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
125 deletions
+0
-125
app/models/namespace.rb
app/models/namespace.rb
+0
-1
app/models/namespace_onboarding_action.rb
app/models/namespace_onboarding_action.rb
+0
-36
spec/factories/namespace_onboarding_actions.rb
spec/factories/namespace_onboarding_actions.rb
+0
-8
spec/models/namespace_onboarding_action_spec.rb
spec/models/namespace_onboarding_action_spec.rb
+0
-79
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+0
-1
No files found.
app/models/namespace.rb
View file @
7e3a1eb9
...
...
@@ -28,7 +28,6 @@ class Namespace < ApplicationRecord
has_many
:runner_namespaces
,
inverse_of: :namespace
,
class_name:
'Ci::RunnerNamespace'
has_many
:runners
,
through: :runner_namespaces
,
source: :runner
,
class_name:
'Ci::Runner'
has_many
:namespace_onboarding_actions
has_one
:onboarding_progress
# This should _not_ be `inverse_of: :namespace`, because that would also set
...
...
app/models/namespace_onboarding_action.rb
deleted
100644 → 0
View file @
db82a385
# frozen_string_literal: true
class
NamespaceOnboardingAction
<
ApplicationRecord
belongs_to
:namespace
,
optional:
false
validates
:action
,
presence:
true
ACTIONS
=
{
subscription_created:
1
,
git_write:
2
,
merge_request_created:
3
,
git_read:
4
,
pipeline_created:
5
,
user_added:
6
}.
freeze
# The monitoring window prevents the recording of a namespace_onboarding_action if a namespace is created before this
# time span. We are not interested in older namspaces, because the purpose of this table is to monitor and act on the
# progress of newly created namespaces or namespaces that already have at least one recorded action.
MONITORING_WINDOW
=
90
.
days
enum
action:
ACTIONS
class
<<
self
def
completed?
(
namespace
,
action
)
where
(
namespace:
namespace
,
action:
action
).
exists?
end
def
create_action
(
namespace
,
action
)
return
unless
namespace
.
root?
return
if
namespace
.
created_at
<
MONITORING_WINDOW
.
ago
&&
!
namespace
.
namespace_onboarding_actions
.
exists?
NamespaceOnboardingAction
.
safe_find_or_create_by
(
namespace:
namespace
,
action:
action
)
end
end
end
spec/factories/namespace_onboarding_actions.rb
deleted
100644 → 0
View file @
db82a385
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:namespace_onboarding_action
do
namespace
action
{
:subscription_created
}
end
end
spec/models/namespace_onboarding_action_spec.rb
deleted
100644 → 0
View file @
db82a385
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
NamespaceOnboardingAction
do
let
(
:namespace
)
{
create
(
:namespace
)
}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:namespace
).
required
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:action
)
}
end
describe
'.completed?'
do
let
(
:action
)
{
:subscription_created
}
subject
{
described_class
.
completed?
(
namespace
,
action
)
}
context
'action created for the namespace'
do
before
do
create
(
:namespace_onboarding_action
,
namespace:
namespace
,
action:
action
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'action created for another namespace'
do
before
do
create
(
:namespace_onboarding_action
,
namespace:
build
(
:namespace
),
action:
action
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'.create_action'
do
let
(
:action
)
{
:subscription_created
}
subject
(
:create_action
)
{
described_class
.
create_action
(
namespace
,
action
)
}
it
'creates the action for the namespace just once'
do
expect
{
create_action
}.
to
change
{
count_namespace_actions
}.
by
(
1
)
expect
{
create_action
}.
to
change
{
count_namespace_actions
}.
by
(
0
)
end
context
'when the namespace is created outside the monitoring window'
do
let
(
:namespace
)
{
create
(
:namespace
,
created_at:
(
NamespaceOnboardingAction
::
MONITORING_WINDOW
+
1
.
day
).
ago
)
}
it
'does not create an action for the namespace'
do
expect
{
create_action
}.
not_to
change
{
count_namespace_actions
}
end
context
'when an action has already been recorded for the namespace'
do
before
do
described_class
.
create!
(
namespace:
namespace
,
action: :git_write
)
end
it
'creates an action for the namespace'
do
expect
{
create_action
}.
to
change
{
count_namespace_actions
}.
by
(
1
)
end
end
end
context
'when the namespace is not a root'
do
let
(
:namespace
)
{
create
(
:namespace
,
parent:
build
(
:namespace
))
}
it
'does not create an action for the namespace'
do
expect
{
create_action
}.
not_to
change
{
count_namespace_actions
}
end
end
def
count_namespace_actions
described_class
.
where
(
namespace:
namespace
,
action:
action
).
count
end
end
end
spec/models/namespace_spec.rb
View file @
7e3a1eb9
...
...
@@ -19,7 +19,6 @@ RSpec.describe Namespace do
it
{
is_expected
.
to
have_one
:aggregation_schedule
}
it
{
is_expected
.
to
have_one
:namespace_settings
}
it
{
is_expected
.
to
have_many
:custom_emoji
}
it
{
is_expected
.
to
have_many
:namespace_onboarding_actions
}
it
{
is_expected
.
to
have_one
:package_setting_relation
}
it
{
is_expected
.
to
have_one
:onboarding_progress
}
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