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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
10b3c85e
Commit
10b3c85e
authored
Sep 10, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some issues with ci models specs
parent
381180bc
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
55 deletions
+55
-55
app/models/ci/web_hook.rb
app/models/ci/web_hook.rb
+2
-2
spec/factories/ci/web_hook.rb
spec/factories/ci/web_hook.rb
+2
-2
spec/models/ci/project_spec.rb
spec/models/ci/project_spec.rb
+28
-28
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+8
-8
spec/models/ci/service_spec.rb
spec/models/ci/service_spec.rb
+3
-3
spec/models/ci/trigger_spec.rb
spec/models/ci/trigger_spec.rb
+3
-3
spec/models/ci/user_spec.rb
spec/models/ci/user_spec.rb
+7
-7
spec/models/ci/web_hook_spec.rb
spec/models/ci/web_hook_spec.rb
+1
-1
spec/support/setup_builds_storage.rb
spec/support/setup_builds_storage.rb
+1
-1
No files found.
app/models/ci/web_hook.rb
View file @
10b3c85e
...
...
@@ -15,7 +15,7 @@ module Ci
include
HTTParty
belongs_to
:project
,
class_name:
'Ci::
WebHook
'
belongs_to
:project
,
class_name:
'Ci::
Project
'
# HTTParty timeout
default_timeout
10
...
...
spec/factories/ci/web_hook.rb
View file @
10b3c85e
FactoryGirl
.
define
do
factory
:ci_web_hook
,
class:
Ci
::
WebHook
do
sequence
(
:url
)
{
Faker
::
Internet
.
uri
(
'http'
)
}
project
sequence
(
:url
)
{
F
F
aker
::
Internet
.
uri
(
'http'
)
}
project
factory: :ci_project
end
end
spec/models/ci/project_spec.rb
View file @
10b3c85e
...
...
@@ -28,7 +28,7 @@
require
'spec_helper'
describe
Project
do
subject
{
FactoryGirl
.
build
:project
}
subject
{
FactoryGirl
.
build
:
ci_
project
}
it
{
should
have_many
(
:commits
)
}
...
...
@@ -38,36 +38,36 @@ describe Project do
describe
'before_validation'
do
it
'should set an random token if none provided'
do
project
=
FactoryGirl
.
create
:project_without_token
project
=
FactoryGirl
.
create
:
ci_
project_without_token
project
.
token
.
should_not
==
""
end
it
'should not set an random toke if one provided'
do
project
=
FactoryGirl
.
create
:project
project
=
FactoryGirl
.
create
:
ci_
project
project
.
token
.
should
==
"iPWx6WM4lhHNedGfBpPJNP"
end
end
describe
"ordered_by_last_commit_date"
do
it
"returns ordered projects"
do
newest_project
=
FactoryGirl
.
create
:project
oldest_project
=
FactoryGirl
.
create
:project
project_without_commits
=
FactoryGirl
.
create
:project
newest_project
=
FactoryGirl
.
create
:
ci_
project
oldest_project
=
FactoryGirl
.
create
:
ci_
project
project_without_commits
=
FactoryGirl
.
create
:
ci_
project
FactoryGirl
.
create
:commit
,
committed_at:
1
.
hour
.
ago
,
project:
newest_project
FactoryGirl
.
create
:commit
,
committed_at:
2
.
hour
.
ago
,
project:
oldest_project
FactoryGirl
.
create
:c
i_c
ommit
,
committed_at:
1
.
hour
.
ago
,
project:
newest_project
FactoryGirl
.
create
:c
i_c
ommit
,
committed_at:
2
.
hour
.
ago
,
project:
oldest_project
Project
.
ordered_by_last_commit_date
.
should
==
[
newest_project
,
oldest_project
,
project_without_commits
]
end
end
context
:valid_project
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
context
:project_with_commit_and_builds
do
before
do
commit
=
FactoryGirl
.
create
(
:commit
,
project:
project
)
FactoryGirl
.
create
(
:build
,
commit:
commit
)
commit
=
FactoryGirl
.
create
(
:c
i_c
ommit
,
project:
project
)
FactoryGirl
.
create
(
:
ci_
build
,
commit:
commit
)
end
it
{
project
.
status
.
should
==
'pending'
}
...
...
@@ -78,45 +78,45 @@ describe Project do
describe
'#email_notification?'
do
it
do
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
true
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
true
project
.
email_notification?
.
should
==
true
end
it
do
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
false
,
email_recipients:
'test tesft'
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
false
,
email_recipients:
'test tesft'
project
.
email_notification?
.
should
==
true
end
it
do
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
false
,
email_recipients:
''
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
false
,
email_recipients:
''
project
.
email_notification?
.
should
==
false
end
end
describe
'#broken_or_success?'
do
it
{
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
true
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
true
project
.
stub
(
:broken?
).
and_return
(
true
)
project
.
stub
(
:success?
).
and_return
(
true
)
project
.
broken_or_success?
.
should
==
true
}
it
{
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
true
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
true
project
.
stub
(
:broken?
).
and_return
(
true
)
project
.
stub
(
:success?
).
and_return
(
false
)
project
.
broken_or_success?
.
should
==
true
}
it
{
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
true
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
true
project
.
stub
(
:broken?
).
and_return
(
false
)
project
.
stub
(
:success?
).
and_return
(
true
)
project
.
broken_or_success?
.
should
==
true
}
it
{
project
=
FactoryGirl
.
create
:project
,
email_add_pusher:
true
project
=
FactoryGirl
.
create
:
ci_
project
,
email_add_pusher:
true
project
.
stub
(
:broken?
).
and_return
(
false
)
project
.
stub
(
:success?
).
and_return
(
false
)
project
.
broken_or_success?
.
should
==
false
...
...
@@ -140,7 +140,7 @@ describe Project do
end
describe
:repo_url_with_auth
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
subject
{
project
.
repo_url_with_auth
}
it
{
should
be_a
(
String
)
}
...
...
@@ -152,7 +152,7 @@ describe Project do
end
describe
:search
do
let!
(
:project
)
{
FactoryGirl
.
create
(
:project
,
name:
"foo"
)
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:
ci_
project
,
name:
"foo"
)
}
it
{
Project
.
search
(
'fo'
).
should
include
(
project
)
}
it
{
Project
.
search
(
'bar'
).
should
be_empty
}
...
...
@@ -160,25 +160,25 @@ describe Project do
describe
:any_runners
do
it
"there are no runners available"
do
project
=
FactoryGirl
.
create
(
:project
)
project
=
FactoryGirl
.
create
(
:
ci_
project
)
project
.
any_runners?
.
should
be_false
end
it
"there is a specific runner"
do
project
=
FactoryGirl
.
create
(
:project
)
project
.
runners
<<
FactoryGirl
.
create
(
:specific_runner
)
project
=
FactoryGirl
.
create
(
:
ci_
project
)
project
.
runners
<<
FactoryGirl
.
create
(
:
ci_
specific_runner
)
project
.
any_runners?
.
should
be_true
end
it
"there is a shared runner"
do
project
=
FactoryGirl
.
create
(
:project
,
shared_runners_enabled:
true
)
FactoryGirl
.
create
(
:shared_runner
)
project
=
FactoryGirl
.
create
(
:
ci_
project
,
shared_runners_enabled:
true
)
FactoryGirl
.
create
(
:
ci_
shared_runner
)
project
.
any_runners?
.
should
be_true
end
it
"there is a shared runner, but they are prohibited to use"
do
project
=
FactoryGirl
.
create
(
:project
)
FactoryGirl
.
create
(
:shared_runner
)
project
=
FactoryGirl
.
create
(
:
ci_
project
)
FactoryGirl
.
create
(
:
ci_
shared_runner
)
project
.
any_runners?
.
should
be_false
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
10b3c85e
...
...
@@ -27,7 +27,7 @@ describe Ci::Runner do
end
it
'should return the token if it does not have a description'
do
runner
=
FactoryGirl
.
create
(
:runner
)
runner
=
FactoryGirl
.
create
(
:
ci_
runner
)
expect
(
runner
.
display_name
).
to
eq
runner
.
description
end
...
...
@@ -38,8 +38,8 @@ describe Ci::Runner do
end
describe
:assign_to
do
let!
(
:project
)
{
FactoryGirl
.
create
:project
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:shared_runner
)
}
let!
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:
ci_
shared_runner
)
}
before
{
shared_runner
.
assign_to
(
project
)
}
...
...
@@ -50,9 +50,9 @@ describe Ci::Runner do
describe
"belongs_to_one_project?"
do
it
"returns false if there are two projects runner assigned to"
do
runner
=
FactoryGirl
.
create
(
:specific_runner
)
project
=
FactoryGirl
.
create
(
:project
)
project1
=
FactoryGirl
.
create
(
:project
)
runner
=
FactoryGirl
.
create
(
:
ci_
specific_runner
)
project
=
FactoryGirl
.
create
(
:
ci_
project
)
project1
=
FactoryGirl
.
create
(
:
ci_
project
)
project
.
runners
<<
runner
project1
.
runners
<<
runner
...
...
@@ -60,8 +60,8 @@ describe Ci::Runner do
end
it
"returns true"
do
runner
=
FactoryGirl
.
create
(
:specific_runner
)
project
=
FactoryGirl
.
create
(
:project
)
runner
=
FactoryGirl
.
create
(
:
ci_
specific_runner
)
project
=
FactoryGirl
.
create
(
:
ci_
project
)
project
.
runners
<<
runner
runner
.
belongs_to_one_project?
.
should
be_true
...
...
spec/models/ci/service_spec.rb
View file @
10b3c85e
...
...
@@ -29,9 +29,9 @@ describe Ci::Service do
end
describe
"Testable"
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:commit
)
{
FactoryGirl
.
create
:commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:build
,
commit:
commit
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
let
(
:commit
)
{
FactoryGirl
.
create
:c
i_c
ommit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
}
before
do
@service
.
stub
(
...
...
spec/models/ci/trigger_spec.rb
View file @
10b3c85e
require
'spec_helper'
describe
Ci
::
Trigger
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
describe
'before_validation'
do
it
'should set an random token if none provided'
do
trigger
=
FactoryGirl
.
create
:trigger_without_token
,
project:
project
trigger
=
FactoryGirl
.
create
:
ci_
trigger_without_token
,
project:
project
trigger
.
token
.
should_not
be_nil
end
it
'should not set an random token if one provided'
do
trigger
=
FactoryGirl
.
create
:trigger
,
project:
project
trigger
=
FactoryGirl
.
create
:
ci_
trigger
,
project:
project
trigger
.
token
.
should
==
'token'
end
end
...
...
spec/models/ci/user_spec.rb
View file @
10b3c85e
...
...
@@ -6,8 +6,8 @@ describe Ci::User do
let
(
:user
)
{
User
.
new
({})
}
before
do
FactoryGirl
.
create
:project
,
gitlab_id:
1
FactoryGirl
.
create
:project
,
gitlab_id:
2
FactoryGirl
.
create
:
ci_
project
,
gitlab_id:
1
FactoryGirl
.
create
:
ci_
project
,
gitlab_id:
2
gitlab_project
=
OpenStruct
.
new
({
id:
1
})
gitlab_project1
=
OpenStruct
.
new
({
id:
2
})
User
.
any_instance
.
stub
(
:gitlab_projects
).
and_return
([
gitlab_project
,
gitlab_project1
])
...
...
@@ -28,17 +28,17 @@ describe Ci::User do
describe
"authorized_runners"
do
it
"returns authorized runners"
do
project
=
FactoryGirl
.
create
:project
,
gitlab_id:
1
project1
=
FactoryGirl
.
create
:project
,
gitlab_id:
2
project
=
FactoryGirl
.
create
:
ci_
project
,
gitlab_id:
1
project1
=
FactoryGirl
.
create
:
ci_
project
,
gitlab_id:
2
gitlab_project
=
OpenStruct
.
new
({
id:
1
})
gitlab_project1
=
OpenStruct
.
new
({
id:
2
})
User
.
any_instance
.
stub
(
:gitlab_projects
).
and_return
([
gitlab_project
,
gitlab_project1
])
User
.
any_instance
.
stub
(
:can_manage_project?
).
and_return
(
true
)
user
=
User
.
new
({})
runner
=
FactoryGirl
.
create
:specific_runner
runner1
=
FactoryGirl
.
create
:specific_runner
runner2
=
FactoryGirl
.
create
:specific_runner
runner
=
FactoryGirl
.
create
:
ci_
specific_runner
runner1
=
FactoryGirl
.
create
:
ci_
specific_runner
runner2
=
FactoryGirl
.
create
:
ci_
specific_runner
project
.
runners
<<
runner
project1
.
runners
<<
runner1
...
...
spec/models/ci/web_hook_spec.rb
View file @
10b3c85e
...
...
@@ -34,7 +34,7 @@ describe Ci::WebHook do
describe
"execute"
do
before
(
:each
)
do
@web_hook
=
FactoryGirl
.
create
(
:web_hook
)
@web_hook
=
FactoryGirl
.
create
(
:
ci_
web_hook
)
@project
=
@web_hook
.
project
@data
=
{
before:
'oldrev'
,
after:
'newrev'
,
ref:
'ref'
}
...
...
spec/support/setup_builds_storage.rb
View file @
10b3c85e
...
...
@@ -5,7 +5,7 @@ RSpec.configure do |config|
config
.
before
(
:each
)
do
FileUtils
.
mkdir_p
(
builds_path
)
Ci
::
Settings
.
gitlab_ci
[
'builds_path'
]
=
builds_path
Settings
.
gitlab_ci
[
'builds_path'
]
=
builds_path
end
config
.
after
(
:suite
)
do
...
...
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