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
Kazuhiko Shiozaki
gitlab-ce
Commits
88b3195e
Commit
88b3195e
authored
Sep 15, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix specs. Stage 6
parent
e2cbb36b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
144 deletions
+148
-144
spec/mailers/ci/notify_spec.rb
spec/mailers/ci/notify_spec.rb
+6
-6
spec/models/ci/project_services/hip_chat_service_spec.rb
spec/models/ci/project_services/hip_chat_service_spec.rb
+2
-2
spec/services/ci/create_project_service_spec.rb
spec/services/ci/create_project_service_spec.rb
+6
-6
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+7
-7
spec/services/ci/event_service_spec.rb
spec/services/ci/event_service_spec.rb
+3
-3
spec/services/ci/image_for_build_service_spec.rb
spec/services/ci/image_for_build_service_spec.rb
+44
-42
spec/services/ci/register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+78
-76
spec/services/ci/web_hook_service_spec.rb
spec/services/ci/web_hook_service_spec.rb
+2
-2
No files found.
spec/mailers/ci/notify_spec.rb
View file @
88b3195e
require
'spec_helper'
describe
Notify
do
describe
Ci
::
Notify
do
include
EmailSpec
::
Helpers
include
EmailSpec
::
Matchers
before
do
@project
=
FactoryGirl
.
create
:project
@commit
=
FactoryGirl
.
create
:commit
,
project:
@project
@build
=
FactoryGirl
.
create
:build
,
commit:
@commit
@project
=
FactoryGirl
.
create
:
ci_
project
@commit
=
FactoryGirl
.
create
:c
i_c
ommit
,
project:
@project
@build
=
FactoryGirl
.
create
:
ci_
build
,
commit:
@commit
end
describe
'build success'
do
subject
{
Notify
.
build_success_email
(
@build
.
id
,
'wow@example.com'
)
}
subject
{
Ci
::
Notify
.
build_success_email
(
@build
.
id
,
'wow@example.com'
)
}
it
'has the correct subject'
do
should
have_subject
/Build success for/
...
...
@@ -23,7 +23,7 @@ describe Notify do
end
describe
'build fail'
do
subject
{
Notify
.
build_fail_email
(
@build
.
id
,
'wow@example.com'
)
}
subject
{
Ci
::
Notify
.
build_fail_email
(
@build
.
id
,
'wow@example.com'
)
}
it
'has the correct subject'
do
should
have_subject
/Build failed for/
...
...
spec/models/ci/project_services/hip_chat_service_spec.rb
View file @
88b3195e
...
...
@@ -53,13 +53,13 @@ describe Ci::HipChatService do
it
"should call the HipChat API"
do
service
.
execute
(
build
)
HipChatNotifierWorker
.
drain
Ci
::
HipChatNotifierWorker
.
drain
expect
(
WebMock
).
to
have_requested
(
:post
,
api_url
).
once
end
it
"calls the worker with expected arguments"
do
expect
(
HipChatNotifierWorker
).
to
receive
(
:perform_async
)
\
expect
(
Ci
::
HipChatNotifierWorker
).
to
receive
(
:perform_async
)
\
.
with
(
an_instance_of
(
String
),
hash_including
(
token:
'a1b2c3d4e5f6'
,
room:
123
,
...
...
spec/services/ci/create_project_service_spec.rb
View file @
88b3195e
...
...
@@ -5,14 +5,14 @@ describe Ci::CreateProjectService do
let
(
:current_user
)
{
double
.
as_null_object
}
let
(
:project_dump
)
{
YAML
.
load
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/raw_project.yml'
))
}
before
{
Network
.
any_instance
.
stub
(
enable_ci:
true
)
}
before
{
allow_any_instance_of
(
Network
).
to
receive_messages
(
enable_ci:
true
)
}
describe
:execute
do
context
'valid params'
do
let
(
:project
)
{
service
.
execute
(
current_user
,
project_dump
,
'http://localhost/projects/:project_id'
)
}
it
{
project
.
should
be_kind_of
(
Project
)
}
it
{
project
.
should
be_persisted
}
it
{
expect
(
project
).
to
be_kind_of
(
Project
)
}
it
{
expect
(
project
).
to
be_persisted
}
end
context
'without project dump'
do
...
...
@@ -31,9 +31,9 @@ describe Ci::CreateProjectService do
project
=
service
.
execute
(
current_user
,
project_dump
,
'http://localhost/projects/:project_id'
,
origin_project
)
project
.
shared_runners_enabled
.
should
be_true
project
.
public
.
should
be_true
project
.
allow_git_fetch
.
should
be_true
expect
(
project
.
shared_runners_enabled
).
to
be_truthy
expect
(
project
.
public
).
to
be_truthy
expect
(
project
.
allow_git_fetch
).
to
be_truthy
end
end
end
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
88b3195e
...
...
@@ -13,14 +13,14 @@ describe Ci::CreateTriggerRequestService do
@commit
=
FactoryGirl
.
create
:commit
,
project:
project
end
it
{
subject
.
should
be_kind_of
(
TriggerRequest
)
}
it
{
subject
.
commit
.
should
==
@commit
}
it
{
expect
(
subject
).
to
be_kind_of
(
TriggerRequest
)
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@commit
)
}
end
context
'no commit for ref'
do
subject
{
service
.
execute
(
project
,
trigger
,
'other-branch'
)
}
it
{
subject
.
should
be_nil
}
it
{
expect
(
subject
).
to
be_nil
}
end
context
'no builds created'
do
...
...
@@ -30,7 +30,7 @@ describe Ci::CreateTriggerRequestService do
FactoryGirl
.
create
:commit_without_jobs
,
project:
project
end
it
{
subject
.
should
be_nil
}
it
{
expect
(
subject
).
to
be_nil
}
end
context
'for multiple commits'
do
...
...
@@ -43,9 +43,9 @@ describe Ci::CreateTriggerRequestService do
end
context
'retries latest one'
do
it
{
subject
.
should
be_kind_of
(
TriggerRequest
)
}
it
{
subject
.
should
be_persisted
}
it
{
subject
.
commit
.
should
==
@commit2
}
it
{
expect
(
subject
).
to
be_kind_of
(
TriggerRequest
)
}
it
{
expect
(
subject
).
to
be_persisted
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@commit2
)
}
end
end
end
...
...
spec/services/ci/event_service_spec.rb
View file @
88b3195e
...
...
@@ -12,7 +12,7 @@ describe Ci::EventService do
it
"creates event"
do
EventService
.
new
.
remove_project
(
user
,
project
)
Event
.
admin
.
last
.
description
.
should
==
"Project
\"
GitLab / gitlab-shell
\"
has been removed by root"
expect
(
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been removed by root"
)
end
end
...
...
@@ -20,7 +20,7 @@ describe Ci::EventService do
it
"creates event"
do
EventService
.
new
.
create_project
(
user
,
project
)
Event
.
admin
.
last
.
description
.
should
==
"Project
\"
GitLab / gitlab-shell
\"
has been created by root"
expect
(
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been created by root"
)
end
end
...
...
@@ -28,7 +28,7 @@ describe Ci::EventService do
it
"creates event"
do
EventService
.
new
.
change_project_settings
(
user
,
project
)
Event
.
last
.
description
.
should
==
"User
\"
root
\"
updated projects settings"
expect
(
Event
.
last
.
description
).
to
eq
(
"User
\"
root
\"
updated projects settings"
)
end
end
end
spec/services/ci/image_for_build_service_spec.rb
View file @
88b3195e
require
'spec_helper'
describe
Ci
::
ImageForBuildService
do
module
Ci
describe
ImageForBuildService
do
let
(
:service
)
{
ImageForBuildService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:
project
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:
commit
,
project:
project
,
ref:
'master'
)
}
let
(
:build
)
{
FactoryGirl
.
create
(
:
build
,
commit:
commit
)
}
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_
project
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_
commit
,
project:
project
,
ref:
'master'
)
}
let
(
:build
)
{
FactoryGirl
.
create
(
:ci_
build
,
commit:
commit
)
}
describe
:execute
do
before
{
build
}
...
...
@@ -13,34 +14,35 @@ describe Ci::ImageForBuildService do
before
{
build
.
run!
}
let
(
:image
)
{
service
.
execute
(
project
,
ref:
'master'
)
}
it
{
image
.
should
be_kind_of
(
OpenStruct
)
}
it
{
image
.
path
.
to_s
.
should
include
(
'public
/build-running.svg'
)
}
it
{
image
.
name
.
should
==
'build-running.svg'
}
it
{
expect
(
image
).
to
be_kind_of
(
OpenStruct
)
}
it
{
expect
(
image
.
path
.
to_s
).
to
include
(
'public/ci
/build-running.svg'
)
}
it
{
expect
(
image
.
name
).
to
eq
(
'build-running.svg'
)
}
end
context
'unknown branch name'
do
let
(
:image
)
{
service
.
execute
(
project
,
ref:
'feature'
)
}
it
{
image
.
should
be_kind_of
(
OpenStruct
)
}
it
{
image
.
path
.
to_s
.
should
include
(
'public
/build-unknown.svg'
)
}
it
{
image
.
name
.
should
==
'build-unknown.svg'
}
it
{
expect
(
image
).
to
be_kind_of
(
OpenStruct
)
}
it
{
expect
(
image
.
path
.
to_s
).
to
include
(
'public/ci
/build-unknown.svg'
)
}
it
{
expect
(
image
.
name
).
to
eq
(
'build-unknown.svg'
)
}
end
context
'commit sha'
do
before
{
build
.
run!
}
let
(
:image
)
{
service
.
execute
(
project
,
sha:
build
.
sha
)
}
it
{
image
.
should
be_kind_of
(
OpenStruct
)
}
it
{
image
.
path
.
to_s
.
should
include
(
'public
/build-running.svg'
)
}
it
{
image
.
name
.
should
==
'build-running.svg'
}
it
{
expect
(
image
).
to
be_kind_of
(
OpenStruct
)
}
it
{
expect
(
image
.
path
.
to_s
).
to
include
(
'public/ci
/build-running.svg'
)
}
it
{
expect
(
image
.
name
).
to
eq
(
'build-running.svg'
)
}
end
context
'unknown commit sha'
do
let
(
:image
)
{
service
.
execute
(
project
,
sha:
'0000000'
)
}
it
{
image
.
should
be_kind_of
(
OpenStruct
)
}
it
{
image
.
path
.
to_s
.
should
include
(
'public/build-unknown.svg'
)
}
it
{
image
.
name
.
should
==
'build-unknown.svg'
}
it
{
expect
(
image
).
to
be_kind_of
(
OpenStruct
)
}
it
{
expect
(
image
.
path
.
to_s
).
to
include
(
'public/ci/build-unknown.svg'
)
}
it
{
expect
(
image
.
name
).
to
eq
(
'build-unknown.svg'
)
}
end
end
end
end
\ No newline at end of file
spec/services/ci/register_build_service_spec.rb
View file @
88b3195e
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
RegisterBuildService
do
module
Ci
describe
RegisterBuildService
do
let!
(
:service
)
{
RegisterBuildService
.
new
}
let!
(
:project
)
{
FactoryGirl
.
create
:
project
}
let!
(
:commit
)
{
FactoryGirl
.
create
:
commit
,
project:
project
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:
build
,
project:
project
,
commit:
commit
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:
runner
,
is_shared:
true
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:
runner
,
is_shared:
false
)
}
let!
(
:project
)
{
FactoryGirl
.
create
:ci_
project
}
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_
commit
,
project:
project
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:ci_
build
,
project:
project
,
commit:
commit
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_
runner
,
is_shared:
true
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_
runner
,
is_shared:
false
)
}
before
do
specific_runner
.
assign_to
(
project
)
...
...
@@ -18,29 +19,29 @@ describe Ci::RegisterBuildService do
pending_build
.
tag_list
=
[
"linux"
]
pending_build
.
save
specific_runner
.
tag_list
=
[
"linux"
]
service
.
execute
(
specific_runner
).
should
==
pending_build
expect
(
service
.
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
it
"does not pick build with different tag"
do
pending_build
.
tag_list
=
[
"linux"
]
pending_build
.
save
specific_runner
.
tag_list
=
[
"win32"
]
service
.
execute
(
specific_runner
).
should
be_false
expect
(
service
.
execute
(
specific_runner
)).
to
be_falsey
end
it
"picks build without tag"
do
service
.
execute
(
specific_runner
).
should
==
pending_build
expect
(
service
.
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
it
"does not pick build with tag"
do
pending_build
.
tag_list
=
[
"linux"
]
pending_build
.
save
service
.
execute
(
specific_runner
).
should
be_false
expect
(
service
.
execute
(
specific_runner
)).
to
be_falsey
end
it
"pick build without tag"
do
specific_runner
.
tag_list
=
[
"win32"
]
service
.
execute
(
specific_runner
).
should
==
pending_build
expect
(
service
.
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
end
...
...
@@ -53,19 +54,19 @@ describe Ci::RegisterBuildService do
context
'shared runner'
do
let
(
:build
)
{
service
.
execute
(
shared_runner
)
}
it
{
build
.
should
be_kind_of
(
Build
)
}
it
{
build
.
should
be_valid
}
it
{
build
.
should
be_running
}
it
{
build
.
runner
.
should
==
shared_runner
}
it
{
expect
(
build
).
to
be_kind_of
(
Build
)
}
it
{
expect
(
build
).
to
be_valid
}
it
{
expect
(
build
).
to
be_running
}
it
{
expect
(
build
.
runner
).
to
eq
(
shared_runner
)
}
end
context
'specific runner'
do
let
(
:build
)
{
service
.
execute
(
specific_runner
)
}
it
{
build
.
should
be_kind_of
(
Build
)
}
it
{
build
.
should
be_valid
}
it
{
build
.
should
be_running
}
it
{
build
.
runner
.
should
==
specific_runner
}
it
{
expect
(
build
).
to
be_kind_of
(
Build
)
}
it
{
expect
(
build
).
to
be_valid
}
it
{
expect
(
build
).
to
be_running
}
it
{
expect
(
build
.
runner
).
to
eq
(
specific_runner
)
}
end
end
...
...
@@ -73,16 +74,17 @@ describe Ci::RegisterBuildService do
context
'shared runner'
do
let
(
:build
)
{
service
.
execute
(
shared_runner
)
}
it
{
build
.
should
be_nil
}
it
{
expect
(
build
).
to
be_nil
}
end
context
'specific runner'
do
let
(
:build
)
{
service
.
execute
(
specific_runner
)
}
it
{
build
.
should
be_kind_of
(
Build
)
}
it
{
build
.
should
be_valid
}
it
{
build
.
should
be_running
}
it
{
build
.
runner
.
should
==
specific_runner
}
it
{
expect
(
build
).
to
be_kind_of
(
Build
)
}
it
{
expect
(
build
).
to
be_valid
}
it
{
expect
(
build
).
to
be_running
}
it
{
expect
(
build
.
runner
).
to
eq
(
specific_runner
)
}
end
end
end
end
...
...
spec/services/ci/web_hook_service_spec.rb
View file @
88b3195e
...
...
@@ -9,13 +9,13 @@ describe Ci::WebHookService do
describe
:execute
do
it
"should execute successfully"
do
stub_request
(
:post
,
hook
.
url
).
to_return
(
status:
200
)
WebHookService
.
new
.
build_end
(
build
).
should
be_true
expect
(
WebHookService
.
new
.
build_end
(
build
)).
to
be_truthy
end
end
context
'build_data'
do
it
"contains all needed fields"
do
build_data
(
build
).
should
include
(
expect
(
build_data
(
build
)).
to
include
(
:build_id
,
:project_id
,
:ref
,
...
...
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