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
Boxiang Sun
gitlab-ce
Commits
e2cbb36b
Commit
e2cbb36b
authored
Sep 15, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix specs. Stage 5
parent
16ba41a1
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
72 additions
and
74 deletions
+72
-74
.rubocop.yml
.rubocop.yml
+1
-0
app/controllers/ci/admin/application_controller.rb
app/controllers/ci/admin/application_controller.rb
+2
-2
lib/ci/api/entities.rb
lib/ci/api/entities.rb
+3
-6
spec/controllers/ci/projects_controller_spec.rb
spec/controllers/ci/projects_controller_spec.rb
+8
-5
spec/features/ci/runners_spec.rb
spec/features/ci/runners_spec.rb
+2
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+19
-19
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/models/ci/project_services/hip_chat_service_spec.rb
spec/models/ci/project_services/hip_chat_service_spec.rb
+0
-1
spec/models/ci/service_spec.rb
spec/models/ci/service_spec.rb
+3
-3
spec/models/ci/web_hook_spec.rb
spec/models/ci/web_hook_spec.rb
+2
-4
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+12
-12
spec/requests/ci/api/projects_spec.rb
spec/requests/ci/api/projects_spec.rb
+1
-1
spec/requests/ci/api/triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+2
-2
spec/services/ci/event_service_spec.rb
spec/services/ci/event_service_spec.rb
+2
-2
spec/services/ci/web_hook_service_spec.rb
spec/services/ci/web_hook_service_spec.rb
+4
-4
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+10
-10
No files found.
.rubocop.yml
View file @
e2cbb36b
...
@@ -998,6 +998,7 @@ AllCops:
...
@@ -998,6 +998,7 @@ AllCops:
-
'
tmp/**/*'
-
'
tmp/**/*'
-
'
bin/**/*'
-
'
bin/**/*'
-
'
lib/backup/**/*'
-
'
lib/backup/**/*'
-
'
lib/ci/backup/**/*'
-
'
lib/tasks/**/*'
-
'
lib/tasks/**/*'
-
'
lib/email_validator.rb'
-
'
lib/email_validator.rb'
-
'
lib/gitlab/upgrader.rb'
-
'
lib/gitlab/upgrader.rb'
...
...
app/controllers/ci/admin/application_controller.rb
View file @
e2cbb36b
module
Ci
module
Ci
module
Admin
module
Admin
class
ApplicationController
<
Ci
::
ApplicationController
class
ApplicationController
<
Ci
::
ApplicationController
before_
filter
:authenticate_user!
before_
action
:authenticate_user!
before_
filter
:authenticate_admin!
before_
action
:authenticate_admin!
layout
"ci/admin"
layout
"ci/admin"
end
end
...
...
lib/ci/api/entities.rb
View file @
e2cbb36b
...
@@ -11,16 +11,13 @@ module Ci
...
@@ -11,16 +11,13 @@ module Ci
expose
:builds
expose
:builds
end
end
class
BuildOptions
<
Grape
::
Entity
expose
:image
expose
:services
end
class
Build
<
Grape
::
Entity
class
Build
<
Grape
::
Entity
expose
:id
,
:commands
,
:ref
,
:sha
,
:project_id
,
:repo_url
,
expose
:id
,
:commands
,
:ref
,
:sha
,
:project_id
,
:repo_url
,
:before_sha
,
:allow_git_fetch
,
:project_name
:before_sha
,
:allow_git_fetch
,
:project_name
expose
:options
,
using:
BuildOptions
expose
:options
do
|
model
|
model
.
options
end
expose
:timeout
do
|
model
|
expose
:timeout
do
|
model
|
model
.
timeout
model
.
timeout
...
...
spec/controllers/ci/projects_controller_spec.rb
View file @
e2cbb36b
...
@@ -7,26 +7,29 @@ describe Ci::ProjectsController do
...
@@ -7,26 +7,29 @@ describe Ci::ProjectsController do
describe
"POST #build"
do
describe
"POST #build"
do
it
'should respond 200 if params is ok'
do
it
'should respond 200 if params is ok'
do
post
:build
,
id:
@project
.
id
,
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'1c8a9df454ef68c22c2a33cca8232bb50849e5c5'
,
after:
'1c8a9df454ef68c22c2a33cca8232bb50849e5c5'
,
token:
@project
.
token
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
,
ci_yaml_file:
gitlab_ci_yaml
,
commits:
[
{
message:
"Message"
}
]
commits:
[
{
message:
"Message"
}
]
}
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
code
).
to
eq
(
'201'
)
expect
(
response
.
code
).
to
eq
(
'201'
)
end
end
it
'should respond 400 if push about removed branch'
do
it
'should respond 400 if push about removed branch'
do
post
:build
,
id:
@project
.
id
,
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'0000000000000000000000000000000000000000'
,
after:
'0000000000000000000000000000000000000000'
,
token:
@project
.
token
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
ci_yaml_file:
gitlab_ci_yaml
}
expect
(
response
).
not_to
be_success
expect
(
response
).
not_to
be_success
expect
(
response
.
code
).
to
eq
(
'400'
)
expect
(
response
.
code
).
to
eq
(
'400'
)
...
@@ -49,7 +52,7 @@ describe Ci::ProjectsController do
...
@@ -49,7 +52,7 @@ describe Ci::ProjectsController do
let
(
:project_dump
)
{
YAML
.
load
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/raw_project.yml'
))
}
let
(
:project_dump
)
{
YAML
.
load
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/raw_project.yml'
))
}
let
(
:gitlab_url
)
{
GitlabCi
.
config
.
gitlab_server
.
url
}
let
(
:gitlab_url
)
{
GitlabCi
.
config
.
gitlab_server
.
url
}
let
(
:user_data
)
do
let
(
:user_data
)
do
data
=
JSON
.
parse
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
data
=
JSON
.
parse
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
data
.
merge
(
"url"
=>
gitlab_url
)
data
.
merge
(
"url"
=>
gitlab_url
)
end
end
...
@@ -85,7 +88,7 @@ describe Ci::ProjectsController do
...
@@ -85,7 +88,7 @@ describe Ci::ProjectsController do
describe
"GET /gitlab"
do
describe
"GET /gitlab"
do
let
(
:gitlab_url
)
{
GitlabCi
.
config
.
gitlab_server
.
url
}
let
(
:gitlab_url
)
{
GitlabCi
.
config
.
gitlab_server
.
url
}
let
(
:user_data
)
do
let
(
:user_data
)
do
data
=
JSON
.
parse
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
data
=
JSON
.
parse
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
data
.
merge
(
"url"
=>
gitlab_url
)
data
.
merge
(
"url"
=>
gitlab_url
)
end
end
...
...
spec/features/ci/runners_spec.rb
View file @
e2cbb36b
...
@@ -13,8 +13,8 @@ describe "Runners" do
...
@@ -13,8 +13,8 @@ describe "Runners" do
# all projects should be authorized for user
# all projects should be authorized for user
allow_any_instance_of
(
Network
).
to
receive
(
:projects
).
and_return
([
allow_any_instance_of
(
Network
).
to
receive
(
:projects
).
and_return
([
OpenStruct
.
new
({
id:
@project
.
gitlab_id
}),
OpenStruct
.
new
({
id:
@project
.
gitlab_id
}),
OpenStruct
.
new
({
id:
@project2
.
gitlab_id
})
OpenStruct
.
new
({
id:
@project2
.
gitlab_id
})
])
])
@shared_runner
=
FactoryGirl
.
create
:shared_runner
@shared_runner
=
FactoryGirl
.
create
:shared_runner
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
e2cbb36b
...
@@ -3,12 +3,12 @@ require 'spec_helper'
...
@@ -3,12 +3,12 @@ require 'spec_helper'
describe
Ci
::
GitlabCiYamlProcessor
do
describe
Ci
::
GitlabCiYamlProcessor
do
describe
"#builds_for_ref"
do
describe
"#builds_for_ref"
do
let
(
:type
)
{
'test'
}
let
(
:type
)
{
'test'
}
it
"returns builds if no branch specified"
do
it
"returns builds if no branch specified"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -29,7 +29,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -29,7 +29,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not return builds if only has another branch"
do
it
"does not return builds if only has another branch"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"deploy"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"deploy"
]
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -40,7 +40,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -40,7 +40,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not return builds if only has regexp with another branch"
do
it
"does not return builds if only has regexp with another branch"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"/^deploy$/"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"/^deploy$/"
]
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -51,7 +51,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -51,7 +51,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns builds if only has specified this branch"
do
it
"returns builds if only has specified this branch"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"master"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"master"
]
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -62,7 +62,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -62,7 +62,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not build tags"
do
it
"does not build tags"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
except:
[
"tags"
]
}
rspec:
{
script:
"rspec"
,
except:
[
"tags"
]
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -73,7 +73,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -73,7 +73,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns builds if only has a list of branches including specified"
do
it
"returns builds if only has a list of branches including specified"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
}
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -85,10 +85,10 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -85,10 +85,10 @@ describe Ci::GitlabCiYamlProcessor do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
build:
{
script:
"build"
,
type:
"build"
,
only:
[
"master"
,
"deploy"
]
},
build:
{
script:
"build"
,
type:
"build"
,
only:
[
"master"
,
"deploy"
]
},
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
},
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
},
staging:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
staging:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
production:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
production:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -105,7 +105,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -105,7 +105,7 @@ describe Ci::GitlabCiYamlProcessor do
image:
"ruby:2.1"
,
image:
"ruby:2.1"
,
services:
[
"mysql"
],
services:
[
"mysql"
],
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -128,10 +128,10 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -128,10 +128,10 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns image and service when overridden for job"
do
it
"returns image and service when overridden for job"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
image:
"ruby:2.1"
,
image:
"ruby:2.1"
,
services:
[
"mysql"
],
services:
[
"mysql"
],
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
image:
"ruby:2.5"
,
services:
[
"postgresql"
],
script:
"rspec"
}
rspec:
{
image:
"ruby:2.5"
,
services:
[
"postgresql"
],
script:
"rspec"
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -162,7 +162,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -162,7 +162,7 @@ describe Ci::GitlabCiYamlProcessor do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
variables:
variables
,
variables:
variables
,
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
@@ -197,7 +197,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -197,7 +197,7 @@ describe Ci::GitlabCiYamlProcessor do
end
end
it
"returns errors if job image parameter is invalid"
do
it
"returns errors if job image parameter is invalid"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
image:
[
"test"
]
}
})
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
image:
[
"test"
]
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: image should be a string"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: image should be a string"
)
...
@@ -239,7 +239,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -239,7 +239,7 @@ describe Ci::GitlabCiYamlProcessor do
end
end
it
"returns errors if there are unknown parameters that are hashes, but doesn't have a script"
do
it
"returns errors if there are unknown parameters that are hashes, but doesn't have a script"
do
config
=
YAML
.
dump
({
extra:
{
services:
"test"
}
})
config
=
YAML
.
dump
({
extra:
{
services:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"Unknown parameter: extra"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"Unknown parameter: extra"
)
...
@@ -267,7 +267,7 @@ describe Ci::GitlabCiYamlProcessor do
...
@@ -267,7 +267,7 @@ describe Ci::GitlabCiYamlProcessor do
end
end
it
"returns errors if job stage is not a pre-defined stage"
do
it
"returns errors if job stage is not a pre-defined stage"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
"acceptance"
,
allow_failure:
"string"
}
})
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
"acceptance"
,
allow_failure:
"string"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: stage parameter should be build, test, deploy"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: stage parameter should be build, test, deploy"
)
...
...
spec/models/ci/build_spec.rb
View file @
e2cbb36b
...
@@ -56,7 +56,7 @@ describe Ci::Build do
...
@@ -56,7 +56,7 @@ describe Ci::Build do
end
end
let
(
:create_from_build
)
{
Ci
::
Build
.
create_from
build
}
let
(
:create_from_build
)
{
Ci
::
Build
.
create_from
build
}
it
(
'there should be a pending task'
)
do
it
'there should be a pending task'
do
expect
(
Ci
::
Build
.
pending
.
count
(
:all
)).
to
eq
0
expect
(
Ci
::
Build
.
pending
.
count
(
:all
)).
to
eq
0
create_from_build
create_from_build
expect
(
Ci
::
Build
.
pending
.
count
(
:all
)).
to
be
>
0
expect
(
Ci
::
Build
.
pending
.
count
(
:all
)).
to
be
>
0
...
...
spec/models/ci/project_services/hip_chat_service_spec.rb
View file @
e2cbb36b
...
@@ -72,4 +72,3 @@ describe Ci::HipChatService do
...
@@ -72,4 +72,3 @@ describe Ci::HipChatService do
end
end
end
end
end
end
spec/models/ci/service_spec.rb
View file @
e2cbb36b
...
@@ -29,9 +29,9 @@ describe Ci::Service do
...
@@ -29,9 +29,9 @@ describe Ci::Service do
end
end
describe
"Testable"
do
describe
"Testable"
do
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
before
do
before
do
allow
(
@service
).
to
receive_messages
(
allow
(
@service
).
to
receive_messages
(
...
...
spec/models/ci/web_hook_spec.rb
View file @
e2cbb36b
...
@@ -36,7 +36,7 @@ describe Ci::WebHook do
...
@@ -36,7 +36,7 @@ describe Ci::WebHook do
before
(
:each
)
do
before
(
:each
)
do
@web_hook
=
FactoryGirl
.
create
(
:ci_web_hook
)
@web_hook
=
FactoryGirl
.
create
(
:ci_web_hook
)
@project
=
@web_hook
.
project
@project
=
@web_hook
.
project
@data
=
{
before:
'oldrev'
,
after:
'newrev'
,
ref:
'ref'
}
@data
=
{
before:
'oldrev'
,
after:
'newrev'
,
ref:
'ref'
}
WebMock
.
stub_request
(
:post
,
@web_hook
.
url
)
WebMock
.
stub_request
(
:post
,
@web_hook
.
url
)
end
end
...
@@ -56,9 +56,7 @@ describe Ci::WebHook do
...
@@ -56,9 +56,7 @@ describe Ci::WebHook do
it
"catches exceptions"
do
it
"catches exceptions"
do
expect
(
WebHook
).
to
receive
(
:post
).
and_raise
(
"Some HTTP Post error"
)
expect
(
WebHook
).
to
receive
(
:post
).
and_raise
(
"Some HTTP Post error"
)
expect
{
expect
{
@web_hook
.
execute
(
@data
)
}.
to
raise_error
@web_hook
.
execute
(
@data
)
}.
to
raise_error
end
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
e2cbb36b
...
@@ -11,7 +11,7 @@ describe Ci::API::API do
...
@@ -11,7 +11,7 @@ describe Ci::API::API do
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
before
do
before
do
FactoryGirl
.
create
:runner_project
,
project_id:
project
.
id
,
runner_id:
runner
.
id
FactoryGirl
.
create
:
ci_
runner_project
,
project_id:
project
.
id
,
runner_id:
runner
.
id
end
end
describe
"POST /builds/register"
do
describe
"POST /builds/register"
do
...
@@ -20,7 +20,7 @@ describe Ci::API::API do
...
@@ -20,7 +20,7 @@ describe Ci::API::API do
commit
.
create_builds
commit
.
create_builds
build
=
commit
.
builds
.
first
build
=
commit
.
builds
.
first
post
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'sha'
]).
to
eq
(
build
.
sha
)
expect
(
json_response
[
'sha'
]).
to
eq
(
build
.
sha
)
...
@@ -28,7 +28,7 @@ describe Ci::API::API do
...
@@ -28,7 +28,7 @@ describe Ci::API::API do
end
end
it
"should return 404 error if no pending build found"
do
it
"should return 404 error if no pending build found"
do
post
api
(
"/builds/register"
),
token:
runner
.
token
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
...
@@ -37,7 +37,7 @@ describe Ci::API::API do
...
@@ -37,7 +37,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
shared_project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
shared_project
)
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
status:
'pending'
)
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
status:
'pending'
)
post
api
(
"/builds/register"
),
token:
runner
.
token
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
...
@@ -46,7 +46,7 @@ describe Ci::API::API do
...
@@ -46,7 +46,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
status:
'pending'
)
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
status:
'pending'
)
post
api
(
"/builds/register"
),
token:
shared_runner
.
token
post
ci_
api
(
"/builds/register"
),
token:
shared_runner
.
token
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
...
@@ -55,7 +55,7 @@ describe Ci::API::API do
...
@@ -55,7 +55,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
.
create_builds
commit
.
create_builds
post
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
"options"
]).
to
eq
({
"image"
=>
"ruby:2.1"
,
"services"
=>
[
"postgres"
]
})
expect
(
json_response
[
"options"
]).
to
eq
({
"image"
=>
"ruby:2.1"
,
"services"
=>
[
"postgres"
]
})
...
@@ -64,9 +64,9 @@ describe Ci::API::API do
...
@@ -64,9 +64,9 @@ describe Ci::API::API do
it
"returns variables"
do
it
"returns variables"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
.
create_builds
commit
.
create_builds
project
.
variables
<<
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
"variables"
]).
to
eq
([
expect
(
json_response
[
"variables"
]).
to
eq
([
...
@@ -81,9 +81,9 @@ describe Ci::API::API do
...
@@ -81,9 +81,9 @@ describe Ci::API::API do
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
commit
.
create_builds
(
trigger_request
)
commit
.
create_builds
(
trigger_request
)
project
.
variables
<<
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_
api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
"variables"
]).
to
eq
([
expect
(
json_response
[
"variables"
]).
to
eq
([
...
@@ -100,14 +100,14 @@ describe Ci::API::API do
...
@@ -100,14 +100,14 @@ describe Ci::API::API do
it
"should update a running build"
do
it
"should update a running build"
do
build
.
run!
build
.
run!
put
api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
put
ci_
api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
it
'Should not override trace information when no trace is given'
do
it
'Should not override trace information when no trace is given'
do
build
.
run!
build
.
run!
build
.
update!
(
trace:
'hello_world'
)
build
.
update!
(
trace:
'hello_world'
)
put
api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
put
ci_
api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
expect
(
build
.
reload
.
trace
).
to
eq
'hello_world'
expect
(
build
.
reload
.
trace
).
to
eq
'hello_world'
end
end
end
end
...
...
spec/requests/ci/api/projects_spec.rb
View file @
e2cbb36b
...
@@ -62,7 +62,7 @@ describe Ci::API::API do
...
@@ -62,7 +62,7 @@ describe Ci::API::API do
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
context
"Valid Webhook URL"
do
context
"Valid Webhook URL"
do
let!
(
:webhook
)
{
{
web_hook:
"http://example.com/sth/1/ala_ma_kota"
}
}
let!
(
:webhook
)
{
{
web_hook:
"http://example.com/sth/1/ala_ma_kota"
}
}
before
do
before
do
options
.
merge!
(
webhook
)
options
.
merge!
(
webhook
)
...
...
spec/requests/ci/api/triggers_spec.rb
View file @
e2cbb36b
...
@@ -8,11 +8,11 @@ describe Ci::API::API do
...
@@ -8,11 +8,11 @@ describe Ci::API::API do
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let
(
:options
)
{
let
(
:options
)
do
{
{
token:
trigger_token
token:
trigger_token
}
}
}
end
context
'Handles errors'
do
context
'Handles errors'
do
it
'should return bad request if token is missing'
do
it
'should return bad request if token is missing'
do
...
...
spec/services/ci/event_service_spec.rb
View file @
e2cbb36b
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
EventService
do
describe
Ci
::
EventService
do
let
(
:project
)
{
FactoryGirl
.
create
:project
,
name:
"GitLab / gitlab-shell"
}
let
(
:project
)
{
FactoryGirl
.
create
:project
,
name:
"GitLab / gitlab-shell"
}
let
(
:user
)
{
double
(
username:
"root"
,
id:
1
)
}
let
(
:user
)
{
double
(
username:
"root"
,
id:
1
)
}
before
do
before
do
Event
.
destroy_all
Event
.
destroy_all
...
...
spec/services/ci/web_hook_service_spec.rb
View file @
e2cbb36b
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
WebHookService
do
describe
Ci
::
WebHookService
do
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:project
)
{
FactoryGirl
.
create
:project
}
let
(
:commit
)
{
FactoryGirl
.
create
:commit
,
project:
project
}
let
(
:commit
)
{
FactoryGirl
.
create
:commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:build
,
commit:
commit
}
let
(
:build
)
{
FactoryGirl
.
create
:build
,
commit:
commit
}
let
(
:hook
)
{
FactoryGirl
.
create
:web_hook
,
project:
project
}
let
(
:hook
)
{
FactoryGirl
.
create
:web_hook
,
project:
project
}
describe
:execute
do
describe
:execute
do
it
"should execute successfully"
do
it
"should execute successfully"
do
...
...
spec/support/stub_gitlab_calls.rb
View file @
e2cbb36b
...
@@ -24,20 +24,20 @@ module StubGitlabCalls
...
@@ -24,20 +24,20 @@ module StubGitlabCalls
stub_request
(
:post
,
"
#{
gitlab_url
}
api/v3/session.json"
).
stub_request
(
:post
,
"
#{
gitlab_url
}
api/v3/session.json"
).
with
(
body:
"{
\"
email
\"
:
\"
test@test.com
\"
,
\"
password
\"
:
\"
123456
\"
}"
,
with
(
body:
"{
\"
email
\"
:
\"
test@test.com
\"
,
\"
password
\"
:
\"
123456
\"
}"
,
headers:
{
'Content-Type'
=>
'application/json'
}).
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
201
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
to_return
(
status:
201
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
end
def
stub_user
def
stub_user
f
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
f
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"
).
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/user?access_token=some_token"
).
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/user?access_token=some_token"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
end
def
stub_project_8
def
stub_project_8
...
@@ -54,19 +54,19 @@ module StubGitlabCalls
...
@@ -54,19 +54,19 @@ module StubGitlabCalls
f
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/projects.json'
))
f
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/projects.json'
))
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"
).
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
end
def
stub_projects_owned
def
stub_projects_owned
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"
).
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
""
,
headers:
{})
to_return
(
status:
200
,
body:
""
,
headers:
{})
end
end
def
stub_ci_enable
def
stub_ci_enable
stub_request
(
:put
,
"
#{
gitlab_url
}
api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"
).
stub_request
(
:put
,
"
#{
gitlab_url
}
api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
""
,
headers:
{})
to_return
(
status:
200
,
body:
""
,
headers:
{})
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