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
1abf34cb
Commit
1abf34cb
authored
Feb 14, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE-specific code from spec/factories/projects.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
df4c9b24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
46 deletions
+59
-46
ee/spec/factories/projects.rb
ee/spec/factories/projects.rb
+59
-0
spec/factories/projects.rb
spec/factories/projects.rb
+0
-46
No files found.
ee/spec/factories/projects.rb
0 → 100644
View file @
1abf34cb
# frozen_string_literal: true
FactoryBot
.
modify
do
factory
:project
do
transient
do
last_update_at
nil
last_successful_update_at
nil
retry_count
0
end
after
(
:create
)
do
|
project
,
evaluator
|
import_state
=
project
.
import_state
if
import_state
import_state
.
last_successful_update_at
=
evaluator
.
last_successful_update_at
import_state
.
retry_count
=
evaluator
.
retry_count
case
import_state
.
status
.
to_sym
when
:scheduled
import_state
.
last_update_scheduled_at
=
Time
.
now
when
:started
import_state
.
last_update_started_at
=
Time
.
now
when
:finished
timestamp
=
evaluator
.
last_update_at
||
Time
.
now
import_state
.
last_update_at
=
timestamp
import_state
.
last_successful_update_at
=
timestamp
when
:failed
import_state
.
last_update_at
=
evaluator
.
last_update_at
||
Time
.
now
end
import_state
.
save!
end
end
trait
:import_none
do
import_status
:none
end
trait
:import_hard_failed
do
import_status
:failed
last_update_at
{
Time
.
now
-
1
.
minute
}
retry_count
{
Gitlab
::
Mirror
::
MAX_RETRY
+
1
}
end
trait
:disabled_mirror
do
mirror
false
import_url
{
generate
(
:url
)
}
mirror_user_id
{
creator_id
}
end
trait
:mirror
do
mirror
true
import_url
{
generate
(
:url
)
}
mirror_user_id
{
creator_id
}
end
trait
:random_last_repository_updated_at
do
last_repository_updated_at
{
rand
(
1
.
year
).
seconds
.
ago
}
end
end
end
spec/factories/projects.rb
View file @
1abf34cb
...
...
@@ -32,9 +32,6 @@ FactoryBot.define do
group_runners_enabled
nil
import_status
nil
import_jid
nil
last_update_at
nil
last_successful_update_at
nil
retry_count
0
end
after
(
:create
)
do
|
project
,
evaluator
|
...
...
@@ -73,9 +70,6 @@ FactoryBot.define do
if
evaluator
.
import_status
import_state
=
project
.
import_state
||
project
.
build_import_state
import_state
.
status
=
evaluator
.
import_status
import_state
.
last_update_at
=
evaluator
.
last_update_at
import_state
.
last_successful_update_at
=
evaluator
.
last_successful_update_at
import_state
.
retry_count
=
evaluator
.
retry_count
import_state
.
jid
=
evaluator
.
import_jid
import_state
.
save
end
...
...
@@ -93,55 +87,20 @@ FactoryBot.define do
visibility_level
Gitlab
::
VisibilityLevel
::
PRIVATE
end
trait
:import_none
do
import_status
:none
end
trait
:import_scheduled
do
import_status
:scheduled
after
(
:create
)
do
|
project
,
_
|
project
.
import_state
&
.
update_attributes
(
last_update_scheduled_at:
Time
.
now
)
end
end
trait
:import_started
do
import_status
:started
after
(
:create
)
do
|
project
,
_
|
project
.
import_state
&
.
update_attributes
(
last_update_started_at:
Time
.
now
)
end
end
trait
:import_finished
do
timestamp
=
Time
.
now
import_status
:finished
last_update_at
timestamp
last_successful_update_at
timestamp
end
trait
:import_failed
do
import_status
:failed
last_update_at
{
Time
.
now
}
end
trait
:import_hard_failed
do
import_status
:failed
last_update_at
{
Time
.
now
-
1
.
minute
}
retry_count
{
Gitlab
::
Mirror
::
MAX_RETRY
+
1
}
end
trait
:disabled_mirror
do
mirror
false
import_url
{
generate
(
:url
)
}
mirror_user_id
{
creator_id
}
end
trait
:mirror
do
mirror
true
import_url
{
generate
(
:url
)
}
mirror_user_id
{
creator_id
}
end
trait
:archived
do
...
...
@@ -247,7 +206,6 @@ FactoryBot.define do
url
"http://foo.com"
enabled
true
end
after
(
:create
)
do
|
project
,
evaluator
|
project
.
remote_mirrors
.
create!
(
url:
evaluator
.
url
,
enabled:
evaluator
.
enabled
)
end
...
...
@@ -287,10 +245,6 @@ FactoryBot.define do
end
end
trait
:random_last_repository_updated_at
do
last_repository_updated_at
{
rand
(
1
.
year
).
seconds
.
ago
}
end
trait
(
:wiki_enabled
)
{
wiki_access_level
ProjectFeature
::
ENABLED
}
trait
(
:wiki_disabled
)
{
wiki_access_level
ProjectFeature
::
DISABLED
}
trait
(
:wiki_private
)
{
wiki_access_level
ProjectFeature
::
PRIVATE
}
...
...
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