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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b87ca750
Commit
b87ca750
authored
Sep 15, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix specs. Stage 7
parent
88b3195e
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
406 additions
and
402 deletions
+406
-402
app/models/project_services/ci/hip_chat_message.rb
app/models/project_services/ci/hip_chat_message.rb
+1
-1
app/models/project_services/ci/slack_message.rb
app/models/project_services/ci/slack_message.rb
+2
-2
spec/features/ci/admin/builds_spec.rb
spec/features/ci/admin/builds_spec.rb
+20
-20
spec/features/ci/admin/events_spec.rb
spec/features/ci/admin/events_spec.rb
+2
-2
spec/features/ci/admin/projects_spec.rb
spec/features/ci/admin/projects_spec.rb
+3
-3
spec/features/ci/admin/runners_spec.rb
spec/features/ci/admin/runners_spec.rb
+11
-11
spec/features/ci/events_spec.rb
spec/features/ci/events_spec.rb
+2
-2
spec/features/ci/lint_spec.rb
spec/features/ci/lint_spec.rb
+2
-2
spec/features/ci/runners_spec.rb
spec/features/ci/runners_spec.rb
+14
-14
spec/features/ci/triggers_spec.rb
spec/features/ci/triggers_spec.rb
+3
-3
spec/features/ci/variables_spec.rb
spec/features/ci/variables_spec.rb
+2
-2
spec/lib/ci/charts_spec.rb
spec/lib/ci/charts_spec.rb
+5
-5
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+302
-300
spec/models/ci/mail_service_spec.rb
spec/models/ci/mail_service_spec.rb
+1
-1
spec/models/ci/project_services/slack_message_spec.rb
spec/models/ci/project_services/slack_message_spec.rb
+2
-2
spec/models/ci/project_services/slack_service_spec.rb
spec/models/ci/project_services/slack_service_spec.rb
+2
-2
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+2
-2
spec/models/ci/service_spec.rb
spec/models/ci/service_spec.rb
+1
-1
spec/services/ci/create_project_service_spec.rb
spec/services/ci/create_project_service_spec.rb
+2
-4
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+10
-10
spec/services/ci/event_service_spec.rb
spec/services/ci/event_service_spec.rb
+7
-7
spec/services/ci/web_hook_service_spec.rb
spec/services/ci/web_hook_service_spec.rb
+6
-6
spec/support/login_helpers.rb
spec/support/login_helpers.rb
+4
-0
No files found.
app/models/project_services/ci/hip_chat_message.rb
View file @
b87ca750
...
...
@@ -11,7 +11,7 @@ module Ci
lines
.
push
(
"<a href=
\"
#{
Ci
::
RoutesHelper
.
ci_project_url
(
project
)
}
\"
>
#{
project
.
name
}
</a> - "
)
if
commit
.
matrix?
lines
.
push
(
"<a href=
\"
#{
Ci
::
RoutesHelper
.
ci_project_ref_commit_url
(
project
,
commit
.
ref
,
commit
.
sha
)
}
\"
>Commit #
#{
commit
.
id
}
</a></br>"
)
lines
.
push
(
"<a href=
\"
#{
Ci
::
RoutesHelper
.
ci_project_ref_commit
s
_url
(
project
,
commit
.
ref
,
commit
.
sha
)
}
\"
>Commit #
#{
commit
.
id
}
</a></br>"
)
else
first_build
=
commit
.
builds_without_retry
.
first
lines
.
push
(
"<a href=
\"
#{
Ci
::
RoutesHelper
.
ci_project_build_url
(
project
,
first_build
)
}
\"
>Build '
#{
first_build
.
name
}
' #
#{
first_build
.
id
}
</a></br>"
)
...
...
app/models/project_services/ci/slack_message.rb
View file @
b87ca750
...
...
@@ -46,10 +46,10 @@ module Ci
def
attachment_message
out
=
"<
#{
Ci
::
RoutesHelper
.
ci_project_url
(
project
)
}
|
#{
project_name
}
>: "
if
commit
.
matrix?
out
<<
"Commit <
#{
Ci
::
RoutesHelper
.
ci_project_ref_commit_url
(
project
,
commit
.
ref
,
commit
.
sha
)
}
|
\#
#{
commit
.
id
}
> "
out
<<
"Commit <
#{
Ci
::
RoutesHelper
.
ci_project_ref_commit
s
_url
(
project
,
commit
.
ref
,
commit
.
sha
)
}
|
\#
#{
commit
.
id
}
> "
else
build
=
commit
.
builds_without_retry
.
first
out
<<
"Build <
#{
Ci
::
RoutesHelper
.
ci_project_build_
url
(
project
,
build
)
}
|
\#
#{
build
.
id
}
> "
out
<<
"Build <
#{
Ci
::
RoutesHelper
.
ci_project_build_
path
(
project
,
build
)
}
|
\#
#{
build
.
id
}
> "
end
out
<<
"(<
#{
commit_sha_link
}
|
#{
commit
.
short_sha
}
>) "
out
<<
"of <
#{
commit_ref_link
}
|
#{
commit
.
ref
}
> "
...
...
spec/features/ci/admin/builds_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
"Admin Builds"
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
skip_admin_auth
skip_
ci_
admin_auth
login_as
:user
end
describe
"GET /admin/builds"
do
before
do
build
visit
admin_builds_path
visit
ci_
admin_builds_path
end
it
{
expect
(
page
).
to
have_content
"All builds"
}
...
...
@@ -22,23 +22,23 @@ describe "Admin Builds" do
describe
"Tabs"
do
it
"shows all builds"
do
build
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"failed"
build
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"failed"
visit
admin_builds_path
visit
ci_
admin_builds_path
expect
(
page
.
all
(
".build-link"
).
size
).
to
eq
(
4
)
end
it
"shows pending builds"
do
build
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"failed"
build
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"failed"
visit
admin_builds_path
visit
ci_
admin_builds_path
within
".nav.nav-tabs"
do
click_on
"Pending"
...
...
@@ -51,12 +51,12 @@ describe "Admin Builds" do
end
it
"shows running builds"
do
build
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:build
,
commit:
commit
,
status:
"failed"
build
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"pending"
build1
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"running"
build2
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"success"
build3
=
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
,
status:
"failed"
visit
admin_builds_path
visit
ci_
admin_builds_path
within
".nav.nav-tabs"
do
click_on
"Running"
...
...
spec/features/ci/admin/events_spec.rb
View file @
b87ca750
...
...
@@ -4,14 +4,14 @@ describe "Admin Events" do
let
(
:event
)
{
FactoryGirl
.
create
:admin_event
}
before
do
skip_admin_auth
skip_
ci_
admin_auth
login_as
:user
end
describe
"GET /admin/events"
do
before
do
event
visit
admin_events_path
visit
ci_
admin_events_path
end
it
{
expect
(
page
).
to
have_content
"Events"
}
...
...
spec/features/ci/admin/projects_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
"Admin Projects"
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
before
do
skip_admin_auth
skip_
ci_
admin_auth
login_as
:user
end
describe
"GET /admin/projects"
do
before
do
project
visit
admin_projects_path
visit
ci_
admin_projects_path
end
it
{
expect
(
page
).
to
have_content
"Projects"
}
...
...
spec/features/ci/admin/runners_spec.rb
View file @
b87ca750
...
...
@@ -2,16 +2,16 @@ require 'spec_helper'
describe
"Admin Runners"
do
before
do
skip_admin_auth
skip_
ci_
admin_auth
login_as
:user
end
describe
"Runners page"
do
before
do
runner
=
FactoryGirl
.
create
(
:runner
)
commit
=
FactoryGirl
.
create
(
:commit
)
FactoryGirl
.
create
(
:build
,
commit:
commit
,
runner_id:
runner
.
id
)
visit
admin_runners_path
runner
=
FactoryGirl
.
create
(
:
ci_
runner
)
commit
=
FactoryGirl
.
create
(
:c
i_c
ommit
)
FactoryGirl
.
create
(
:
ci_
build
,
commit:
commit
,
runner_id:
runner
.
id
)
visit
ci_
admin_runners_path
end
it
{
page
.
has_text?
"Manage Runners"
}
...
...
@@ -20,8 +20,8 @@ describe "Admin Runners" do
describe
'search'
do
before
do
FactoryGirl
.
create
:runner
,
description:
'foo'
FactoryGirl
.
create
:runner
,
description:
'bar'
FactoryGirl
.
create
:
ci_
runner
,
description:
'foo'
FactoryGirl
.
create
:
ci_
runner
,
description:
'bar'
fill_in
'search'
,
with:
'foo'
click_button
'Search'
...
...
@@ -33,12 +33,12 @@ describe "Admin Runners" do
end
describe
"Runner show page"
do
let
(
:runner
)
{
FactoryGirl
.
create
:runner
}
let
(
:runner
)
{
FactoryGirl
.
create
:
ci_
runner
}
before
do
FactoryGirl
.
create
(
:project
,
name:
"foo"
)
FactoryGirl
.
create
(
:project
,
name:
"bar"
)
visit
admin_runner_path
(
runner
)
FactoryGirl
.
create
(
:
ci_
project
,
name:
"foo"
)
FactoryGirl
.
create
(
:
ci_
project
,
name:
"bar"
)
visit
ci_
admin_runner_path
(
runner
)
end
describe
'runner info'
do
...
...
spec/features/ci/events_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
"Events"
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
let
(
:event
)
{
FactoryGirl
.
create
:admin_event
,
project:
project
}
before
do
...
...
@@ -11,7 +11,7 @@ describe "Events" do
describe
"GET /project/:id/events"
do
before
do
event
visit
project_events_path
(
project
)
visit
ci_
project_events_path
(
project
)
end
it
{
expect
(
page
).
to
have_content
"Events"
}
...
...
spec/features/ci/lint_spec.rb
View file @
b87ca750
...
...
@@ -7,7 +7,7 @@ describe "Lint" do
it
"Yaml parsing"
,
js:
true
do
content
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
visit
lint_path
visit
ci_
lint_path
fill_in
"content"
,
with:
content
click_on
"Validate"
within
"table"
do
...
...
@@ -19,7 +19,7 @@ describe "Lint" do
end
it
"Yaml parsing with error"
,
js:
true
do
visit
lint_path
visit
ci_
lint_path
fill_in
"content"
,
with:
""
click_on
"Validate"
expect
(
page
).
to
have_content
(
"Status: syntax is incorrect"
)
...
...
spec/features/ci/runners_spec.rb
View file @
b87ca750
...
...
@@ -7,8 +7,8 @@ describe "Runners" do
describe
"specific runners"
do
before
do
@project
=
FactoryGirl
.
create
:project
@project2
=
FactoryGirl
.
create
:project
@project
=
FactoryGirl
.
create
:
ci_
project
@project2
=
FactoryGirl
.
create
:
ci_
project
stub_js_gitlab_calls
# all projects should be authorized for user
...
...
@@ -17,22 +17,22 @@ describe "Runners" do
OpenStruct
.
new
({
id:
@project2
.
gitlab_id
})
])
@shared_runner
=
FactoryGirl
.
create
:shared_runner
@specific_runner
=
FactoryGirl
.
create
:specific_runner
@specific_runner2
=
FactoryGirl
.
create
:specific_runner
@shared_runner
=
FactoryGirl
.
create
:
ci_
shared_runner
@specific_runner
=
FactoryGirl
.
create
:
ci_
specific_runner
@specific_runner2
=
FactoryGirl
.
create
:
ci_
specific_runner
@project
.
runners
<<
@specific_runner
@project2
.
runners
<<
@specific_runner2
end
it
"places runners in right places"
do
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
expect
(
page
.
find
(
".available-specific-runners"
)).
to
have_content
(
@specific_runner2
.
display_name
)
expect
(
page
.
find
(
".activated-specific-runners"
)).
to
have_content
(
@specific_runner
.
display_name
)
expect
(
page
.
find
(
".available-shared-runners"
)).
to
have_content
(
@shared_runner
.
display_name
)
end
it
"enables specific runner for project"
do
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
within
".available-specific-runners"
do
click_on
"Enable for this project"
...
...
@@ -44,7 +44,7 @@ describe "Runners" do
it
"disables specific runner for project"
do
@project2
.
runners
<<
@specific_runner
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
within
".activated-specific-runners"
do
click_on
"Disable for this project"
...
...
@@ -54,7 +54,7 @@ describe "Runners" do
end
it
"removes specific runner for project if this is last project for that runners"
do
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
within
".activated-specific-runners"
do
click_on
"Remove runner"
...
...
@@ -66,12 +66,12 @@ describe "Runners" do
describe
"shared runners"
do
before
do
@project
=
FactoryGirl
.
create
:project
@project
=
FactoryGirl
.
create
:
ci_
project
stub_js_gitlab_calls
end
it
"enables shared runners"
do
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
click_on
"Enable shared runners"
...
...
@@ -81,14 +81,14 @@ describe "Runners" do
describe
"show page"
do
before
do
@project
=
FactoryGirl
.
create
:project
@project
=
FactoryGirl
.
create
:
ci_
project
stub_js_gitlab_calls
@specific_runner
=
FactoryGirl
.
create
:specific_runner
@specific_runner
=
FactoryGirl
.
create
:
ci_
specific_runner
@project
.
runners
<<
@specific_runner
end
it
"shows runner information"
do
visit
project_runners_path
(
@project
)
visit
ci_
project_runners_path
(
@project
)
click_on
@specific_runner
.
short_sha
...
...
spec/features/ci/triggers_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
'
Variable
s'
do
describe
'
Trigger
s'
do
before
do
login_as
:user
@project
=
FactoryGirl
.
create
:project
@project
=
FactoryGirl
.
create
:
ci_
project
stub_js_gitlab_calls
visit
project_triggers_path
(
@project
)
visit
ci_
project_triggers_path
(
@project
)
end
context
'create a trigger'
do
...
...
spec/features/ci/variables_spec.rb
View file @
b87ca750
...
...
@@ -7,12 +7,12 @@ describe "Variables" do
describe
"specific runners"
do
before
do
@project
=
FactoryGirl
.
create
:project
@project
=
FactoryGirl
.
create
:
ci_
project
stub_js_gitlab_calls
end
it
"creates variable"
,
js:
true
do
visit
project_variables_path
(
@project
)
visit
ci_
project_variables_path
(
@project
)
click_on
"Add a variable"
fill_in
"Key"
,
with:
"SECRET_KEY"
fill_in
"Value"
,
with:
"SECRET_VALUE"
...
...
spec/lib/ci/charts_spec.rb
View file @
b87ca750
...
...
@@ -4,14 +4,14 @@ describe "Charts" do
context
"build_times"
do
before
do
@project
=
FactoryGirl
.
create
(
:project
)
@commit
=
FactoryGirl
.
create
(
:commit
,
project:
@project
)
FactoryGirl
.
create
(
:build
,
commit:
@commit
)
@project
=
FactoryGirl
.
create
(
:
ci_
project
)
@commit
=
FactoryGirl
.
create
(
:c
i_c
ommit
,
project:
@project
)
FactoryGirl
.
create
(
:
ci_
build
,
commit:
@commit
)
end
it
'should return build times in minutes'
do
chart
=
Charts
::
BuildTime
.
new
(
@project
)
chart
.
build_times
.
should
==
[
2
]
chart
=
C
i
::
C
harts
::
BuildTime
.
new
(
@project
)
expect
(
chart
.
build_times
).
to
eq
([
2
])
end
end
end
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
GitlabCiYamlProcessor
do
module
Ci
describe
GitlabCiYamlProcessor
do
describe
"#builds_for_ref"
do
let
(
:type
)
{
'test'
}
...
...
@@ -13,8 +14,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
.
should
==
1
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
first
.
should
==
{
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
first
).
to
eq
(
{
stage:
"test"
,
except:
nil
,
name: :rspec
,
...
...
@@ -23,7 +24,7 @@ describe Ci::GitlabCiYamlProcessor do
tags:
[],
options:
{},
allow_failure:
false
}
})
end
it
"does not return builds if only has another branch"
do
...
...
@@ -34,7 +35,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
.
should
==
0
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
0
)
end
it
"does not return builds if only has regexp with another branch"
do
...
...
@@ -45,7 +46,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
.
should
==
0
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
0
)
end
it
"returns builds if only has specified this branch"
do
...
...
@@ -56,7 +57,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
.
should
==
1
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
end
it
"does not build tags"
do
...
...
@@ -67,7 +68,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"0-1"
,
true
).
size
.
should
==
0
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"0-1"
,
true
).
size
).
to
eq
(
0
)
end
it
"returns builds if only has a list of branches including specified"
do
...
...
@@ -78,7 +79,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
.
should
==
1
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
end
it
"returns build only for specified type"
do
...
...
@@ -93,9 +94,9 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
"production"
,
"deploy"
).
size
.
should
==
0
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
.
should
==
1
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"deploy"
).
size
.
should
==
2
expect
(
config_processor
.
builds_for_stage_and_ref
(
"production"
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"deploy"
).
size
).
to
eq
(
2
)
end
end
...
...
@@ -110,8 +111,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
.
should
==
1
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
.
should
==
{
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
(
{
except:
nil
,
stage:
"test"
,
name: :rspec
,
...
...
@@ -123,7 +124,7 @@ describe Ci::GitlabCiYamlProcessor do
services:
[
"mysql"
]
},
allow_failure:
false
}
})
end
it
"returns image and service when overridden for job"
do
...
...
@@ -136,8 +137,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
.
should
==
1
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
.
should
==
{
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
(
{
except:
nil
,
stage:
"test"
,
name: :rspec
,
...
...
@@ -149,7 +150,7 @@ describe Ci::GitlabCiYamlProcessor do
services:
[
"postgresql"
]
},
allow_failure:
false
}
})
end
end
...
...
@@ -166,7 +167,7 @@ describe Ci::GitlabCiYamlProcessor do
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
.
variables
.
should
==
variables
expect
(
config_processor
.
variables
).
to
eq
(
variables
)
end
end
...
...
@@ -308,4 +309,5 @@ describe Ci::GitlabCiYamlProcessor do
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"variables should be a map of key-valued strings"
)
end
end
end
end
spec/models/ci/mail_service_spec.rb
View file @
b87ca750
...
...
@@ -169,7 +169,7 @@ describe Ci::MailService do
end
it
do
Build
.
retry
(
build
)
Ci
::
Build
.
retry
(
build
)
should_email
(
commit
.
git_author_email
)
should_email
(
"jeroen@example.com"
)
mail
.
execute
(
build
)
if
mail
.
can_execute?
(
build
)
...
...
spec/models/ci/project_services/slack_message_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
SlackMessage
do
subject
{
SlackMessage
.
new
(
commit
)
}
subject
{
Ci
::
SlackMessage
.
new
(
commit
)
}
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
...
...
@@ -43,7 +43,7 @@ describe Ci::SlackMessage do
end
context
"Several builds"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:commit_with_two_jobs
,
project:
project
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:c
i_c
ommit_with_two_jobs
,
project:
project
)
}
context
'when all matrix builds succeeded'
do
let
(
:color
)
{
'good'
}
...
...
spec/models/ci/project_services/slack_service_spec.rb
View file @
b87ca750
...
...
@@ -30,7 +30,7 @@ describe Ci::SlackService do
end
describe
"Execute"
do
let
(
:slack
)
{
SlackService
.
new
}
let
(
:slack
)
{
Ci
::
SlackService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
status:
'failed'
}
...
...
@@ -50,7 +50,7 @@ describe Ci::SlackService do
it
"should call Slack API"
do
slack
.
execute
(
build
)
SlackNotifierWorker
.
drain
Ci
::
SlackNotifierWorker
.
drain
expect
(
WebMock
).
to
have_requested
(
:post
,
webhook_url
).
once
end
...
...
spec/models/ci/runner_spec.rb
View file @
b87ca750
...
...
@@ -22,7 +22,7 @@ require 'spec_helper'
describe
Ci
::
Runner
do
describe
'#display_name'
do
it
'should return the description if it has a value'
do
runner
=
FactoryGirl
.
build
(
:runner
,
description:
'Linux/Ruby-1.9.3-p448'
)
runner
=
FactoryGirl
.
build
(
:
ci_
runner
,
description:
'Linux/Ruby-1.9.3-p448'
)
expect
(
runner
.
display_name
).
to
eq
'Linux/Ruby-1.9.3-p448'
end
...
...
@@ -32,7 +32,7 @@ describe Ci::Runner do
end
it
'should return the token if the description is an empty string'
do
runner
=
FactoryGirl
.
build
(
:runner
,
description:
''
)
runner
=
FactoryGirl
.
build
(
:
ci_
runner
,
description:
''
)
expect
(
runner
.
display_name
).
to
eq
runner
.
token
end
end
...
...
spec/models/ci/service_spec.rb
View file @
b87ca750
...
...
@@ -25,7 +25,7 @@ describe Ci::Service do
describe
"Test Button"
do
before
do
@service
=
Service
.
new
@service
=
Ci
::
Service
.
new
end
describe
"Testable"
do
...
...
spec/services/ci/create_project_service_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
CreateProjectService
do
let
(
:service
)
{
CreateProjectService
.
new
}
let
(
:service
)
{
C
i
::
C
reateProjectService
.
new
}
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
{
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'
)
}
...
...
@@ -23,7 +21,7 @@ describe Ci::CreateProjectService do
context
"forking"
do
it
"uses project as a template for settings and jobs"
do
origin_project
=
FactoryGirl
.
create
(
:project
)
origin_project
=
FactoryGirl
.
create
(
:
ci_
project
)
origin_project
.
shared_runners_enabled
=
true
origin_project
.
public
=
true
origin_project
.
allow_git_fetch
=
true
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
CreateTriggerRequestService
do
let
(
:service
)
{
CreateTriggerRequestService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:trigger
)
{
FactoryGirl
.
create
:trigger
,
project:
project
}
let
(
:service
)
{
C
i
::
C
reateTriggerRequestService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
let
(
:trigger
)
{
FactoryGirl
.
create
:
ci_
trigger
,
project:
project
}
describe
:execute
do
context
'valid params'
do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
@commit
=
FactoryGirl
.
create
:commit
,
project:
project
@commit
=
FactoryGirl
.
create
:c
i_c
ommit
,
project:
project
end
it
{
expect
(
subject
).
to
be_kind_of
(
TriggerRequest
)
}
it
{
expect
(
subject
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@commit
)
}
end
...
...
@@ -27,7 +27,7 @@ describe Ci::CreateTriggerRequestService do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
FactoryGirl
.
create
:commit_without_jobs
,
project:
project
FactoryGirl
.
create
:c
i_c
ommit_without_jobs
,
project:
project
end
it
{
expect
(
subject
).
to
be_nil
}
...
...
@@ -37,13 +37,13 @@ describe Ci::CreateTriggerRequestService do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
@commit1
=
FactoryGirl
.
create
:commit
,
committed_at:
2
.
hour
.
ago
,
project:
project
@commit2
=
FactoryGirl
.
create
:commit
,
committed_at:
1
.
hour
.
ago
,
project:
project
@commit3
=
FactoryGirl
.
create
:commit
,
committed_at:
3
.
hour
.
ago
,
project:
project
@commit1
=
FactoryGirl
.
create
:c
i_c
ommit
,
committed_at:
2
.
hour
.
ago
,
project:
project
@commit2
=
FactoryGirl
.
create
:c
i_c
ommit
,
committed_at:
1
.
hour
.
ago
,
project:
project
@commit3
=
FactoryGirl
.
create
:c
i_c
ommit
,
committed_at:
3
.
hour
.
ago
,
project:
project
end
context
'retries latest one'
do
it
{
expect
(
subject
).
to
be_kind_of
(
TriggerRequest
)
}
it
{
expect
(
subject
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
).
to
be_persisted
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@commit2
)
}
end
...
...
spec/services/ci/event_service_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
EventService
do
let
(
:project
)
{
FactoryGirl
.
create
:project
,
name:
"GitLab / gitlab-shell"
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
,
name:
"GitLab / gitlab-shell"
}
let
(
:user
)
{
double
(
username:
"root"
,
id:
1
)
}
before
do
...
...
@@ -10,25 +10,25 @@ describe Ci::EventService do
describe
:remove_project
do
it
"creates event"
do
EventService
.
new
.
remove_project
(
user
,
project
)
Ci
::
EventService
.
new
.
remove_project
(
user
,
project
)
expect
(
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been removed by root"
)
expect
(
Ci
::
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been removed by root"
)
end
end
describe
:create_project
do
it
"creates event"
do
EventService
.
new
.
create_project
(
user
,
project
)
Ci
::
EventService
.
new
.
create_project
(
user
,
project
)
expect
(
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been created by root"
)
expect
(
Ci
::
Event
.
admin
.
last
.
description
).
to
eq
(
"Project
\"
GitLab / gitlab-shell
\"
has been created by root"
)
end
end
describe
:change_project_settings
do
it
"creates event"
do
EventService
.
new
.
change_project_settings
(
user
,
project
)
Ci
::
EventService
.
new
.
change_project_settings
(
user
,
project
)
expect
(
Event
.
last
.
description
).
to
eq
(
"User
\"
root
\"
updated projects settings"
)
expect
(
Ci
::
Event
.
last
.
description
).
to
eq
(
"User
\"
root
\"
updated projects settings"
)
end
end
end
spec/services/ci/web_hook_service_spec.rb
View file @
b87ca750
require
'spec_helper'
describe
Ci
::
WebHookService
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:commit
)
{
FactoryGirl
.
create
:commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:build
,
commit:
commit
}
let
(
:hook
)
{
FactoryGirl
.
create
:web_hook
,
project:
project
}
let
(
:project
)
{
FactoryGirl
.
create
:
ci_
project
}
let
(
:commit
)
{
FactoryGirl
.
create
:c
i_c
ommit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:
ci_
build
,
commit:
commit
}
let
(
:hook
)
{
FactoryGirl
.
create
:
ci_
web_hook
,
project:
project
}
describe
:execute
do
it
"should execute successfully"
do
stub_request
(
:post
,
hook
.
url
).
to_return
(
status:
200
)
expect
(
WebHookService
.
new
.
build_end
(
build
)).
to
be_truthy
expect
(
Ci
::
WebHookService
.
new
.
build_end
(
build
)).
to
be_truthy
end
end
...
...
@@ -31,6 +31,6 @@ describe Ci::WebHookService do
end
def
build_data
(
build
)
WebHookService
.
new
.
send
:build_data
,
build
Ci
::
WebHookService
.
new
.
send
:build_data
,
build
end
end
spec/support/login_helpers.rb
View file @
b87ca750
...
...
@@ -44,4 +44,8 @@ module LoginHelpers
def
logout_direct
page
.
driver
.
submit
:delete
,
'/users/sign_out'
,
{}
end
def
skip_ci_admin_auth
allow_any_instance_of
(
Ci
::
Admin
::
ApplicationController
).
to
receive_messages
(
authenticate_admin!:
true
)
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