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
Léo-Paul Géneau
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:
-
'
tmp/**/*'
-
'
bin/**/*'
-
'
lib/backup/**/*'
-
'
lib/ci/backup/**/*'
-
'
lib/tasks/**/*'
-
'
lib/email_validator.rb'
-
'
lib/gitlab/upgrader.rb'
...
...
app/controllers/ci/admin/application_controller.rb
View file @
e2cbb36b
module
Ci
module
Admin
class
ApplicationController
<
Ci
::
ApplicationController
before_
filter
:authenticate_user!
before_
filter
:authenticate_admin!
before_
action
:authenticate_user!
before_
action
:authenticate_admin!
layout
"ci/admin"
end
...
...
lib/ci/api/entities.rb
View file @
e2cbb36b
...
...
@@ -11,16 +11,13 @@ module Ci
expose
:builds
end
class
BuildOptions
<
Grape
::
Entity
expose
:image
expose
:services
end
class
Build
<
Grape
::
Entity
expose
:id
,
:commands
,
:ref
,
:sha
,
:project_id
,
:repo_url
,
:before_sha
,
:allow_git_fetch
,
:project_name
expose
:options
,
using:
BuildOptions
expose
:options
do
|
model
|
model
.
options
end
expose
:timeout
do
|
model
|
model
.
timeout
...
...
spec/controllers/ci/projects_controller_spec.rb
View file @
e2cbb36b
...
...
@@ -7,26 +7,29 @@ describe Ci::ProjectsController do
describe
"POST #build"
do
it
'should respond 200 if params is ok'
do
post
:build
,
id:
@project
.
id
,
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'1c8a9df454ef68c22c2a33cca8232bb50849e5c5'
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
,
commits:
[
{
message:
"Message"
}
]
}
expect
(
response
).
to
be_success
expect
(
response
.
code
).
to
eq
(
'201'
)
end
it
'should respond 400 if push about removed branch'
do
post
:build
,
id:
@project
.
id
,
post
:build
,
{
id:
@project
.
id
,
ref:
'master'
,
before:
'2aa371379db71ac89ae20843fcff3b3477cf1a1d'
,
after:
'0000000000000000000000000000000000000000'
,
token:
@project
.
token
,
ci_yaml_file:
gitlab_ci_yaml
}
expect
(
response
).
not_to
be_success
expect
(
response
.
code
).
to
eq
(
'400'
)
...
...
@@ -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
(
: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
.
merge
(
"url"
=>
gitlab_url
)
end
...
...
@@ -85,7 +88,7 @@ describe Ci::ProjectsController do
describe
"GET /gitlab"
do
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
.
merge
(
"url"
=>
gitlab_url
)
end
...
...
spec/features/ci/runners_spec.rb
View file @
e2cbb36b
...
...
@@ -13,8 +13,8 @@ describe "Runners" do
# all projects should be authorized for user
allow_any_instance_of
(
Network
).
to
receive
(
:projects
).
and_return
([
OpenStruct
.
new
({
id:
@project
.
gitlab_id
}),
OpenStruct
.
new
({
id:
@project2
.
gitlab_id
})
OpenStruct
.
new
({
id:
@project
.
gitlab_id
}),
OpenStruct
.
new
({
id:
@project2
.
gitlab_id
})
])
@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'
describe
Ci
::
GitlabCiYamlProcessor
do
describe
"#builds_for_ref"
do
let
(
:type
)
{
'test'
}
let
(
:type
)
{
'test'
}
it
"returns builds if no branch specified"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -29,7 +29,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not return builds if only has another branch"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"deploy"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"deploy"
]
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -40,7 +40,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not return builds if only has regexp with another branch"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"/^deploy$/"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"/^deploy$/"
]
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -51,7 +51,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns builds if only has specified this branch"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
only:
[
"master"
]
}
rspec:
{
script:
"rspec"
,
only:
[
"master"
]
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -62,7 +62,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"does not build tags"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
except:
[
"tags"
]
}
rspec:
{
script:
"rspec"
,
except:
[
"tags"
]
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -73,7 +73,7 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns builds if only has a list of branches including specified"
do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
}
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -85,10 +85,10 @@ describe Ci::GitlabCiYamlProcessor do
config
=
YAML
.
dump
({
before_script:
[
"pwd"
],
build:
{
script:
"build"
,
type:
"build"
,
only:
[
"master"
,
"deploy"
]
},
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
},
staging:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
production:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
build:
{
script:
"build"
,
type:
"build"
,
only:
[
"master"
,
"deploy"
]
},
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"master"
,
"deploy"
]
},
staging:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
production:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master"
,
"deploy"
]
},
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -105,7 +105,7 @@ describe Ci::GitlabCiYamlProcessor do
image:
"ruby:2.1"
,
services:
[
"mysql"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -128,10 +128,10 @@ describe Ci::GitlabCiYamlProcessor do
it
"returns image and service when overridden for job"
do
config
=
YAML
.
dump
({
image:
"ruby:2.1"
,
services:
[
"mysql"
],
image:
"ruby:2.1"
,
services:
[
"mysql"
],
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
)
...
...
@@ -162,7 +162,7 @@ describe Ci::GitlabCiYamlProcessor do
config
=
YAML
.
dump
({
variables:
variables
,
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
...
...
@@ -197,7 +197,7 @@ describe Ci::GitlabCiYamlProcessor do
end
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
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: image should be a string"
)
...
...
@@ -239,7 +239,7 @@ describe Ci::GitlabCiYamlProcessor do
end
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
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"Unknown parameter: extra"
)
...
...
@@ -267,7 +267,7 @@ describe Ci::GitlabCiYamlProcessor do
end
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
GitlabCiYamlProcessor
.
new
(
config
)
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
end
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
create_from_build
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
end
end
end
spec/models/ci/service_spec.rb
View file @
e2cbb36b
...
...
@@ -29,9 +29,9 @@ describe Ci::Service do
end
describe
"Testable"
do
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
before
do
allow
(
@service
).
to
receive_messages
(
...
...
spec/models/ci/web_hook_spec.rb
View file @
e2cbb36b
...
...
@@ -36,7 +36,7 @@ describe Ci::WebHook do
before
(
:each
)
do
@web_hook
=
FactoryGirl
.
create
(
:ci_web_hook
)
@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
)
end
...
...
@@ -56,9 +56,7 @@ describe Ci::WebHook do
it
"catches exceptions"
do
expect
(
WebHook
).
to
receive
(
:post
).
and_raise
(
"Some HTTP Post error"
)
expect
{
@web_hook
.
execute
(
@data
)
}.
to
raise_error
expect
{
@web_hook
.
execute
(
@data
)
}.
to
raise_error
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
e2cbb36b
...
...
@@ -11,7 +11,7 @@ describe Ci::API::API do
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
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
describe
"POST /builds/register"
do
...
...
@@ -20,7 +20,7 @@ describe Ci::API::API do
commit
.
create_builds
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
(
json_response
[
'sha'
]).
to
eq
(
build
.
sha
)
...
...
@@ -28,7 +28,7 @@ describe Ci::API::API do
end
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
)
end
...
...
@@ -37,7 +37,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
shared_project
)
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
)
end
...
...
@@ -46,7 +46,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
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
)
end
...
...
@@ -55,7 +55,7 @@ describe Ci::API::API do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
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
(
json_response
[
"options"
]).
to
eq
({
"image"
=>
"ruby:2.1"
,
"services"
=>
[
"postgres"
]
})
...
...
@@ -64,9 +64,9 @@ describe Ci::API::API do
it
"returns variables"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
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
(
json_response
[
"variables"
]).
to
eq
([
...
...
@@ -81,9 +81,9 @@ describe Ci::API::API do
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
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
(
json_response
[
"variables"
]).
to
eq
([
...
...
@@ -100,14 +100,14 @@ describe Ci::API::API do
it
"should update a running build"
do
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
)
end
it
'Should not override trace information when no trace is given'
do
build
.
run!
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'
end
end
...
...
spec/requests/ci/api/projects_spec.rb
View file @
e2cbb36b
...
...
@@ -62,7 +62,7 @@ describe Ci::API::API do
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
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
options
.
merge!
(
webhook
)
...
...
spec/requests/ci/api/triggers_spec.rb
View file @
e2cbb36b
...
...
@@ -8,11 +8,11 @@ describe Ci::API::API do
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let
(
:options
)
{
let
(
:options
)
do
{
token:
trigger_token
}
}
end
context
'Handles errors'
do
it
'should return bad request if token is missing'
do
...
...
spec/services/ci/event_service_spec.rb
View file @
e2cbb36b
require
'spec_helper'
describe
Ci
::
EventService
do
let
(
:project
)
{
FactoryGirl
.
create
:project
,
name:
"GitLab / gitlab-shell"
}
let
(
:user
)
{
double
(
username:
"root"
,
id:
1
)
}
let
(
:project
)
{
FactoryGirl
.
create
:project
,
name:
"GitLab / gitlab-shell"
}
let
(
:user
)
{
double
(
username:
"root"
,
id:
1
)
}
before
do
Event
.
destroy_all
...
...
spec/services/ci/web_hook_service_spec.rb
View file @
e2cbb36b
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
:project
}
let
(
:commit
)
{
FactoryGirl
.
create
:commit
,
project:
project
}
let
(
:build
)
{
FactoryGirl
.
create
:build
,
commit:
commit
}
let
(
:hook
)
{
FactoryGirl
.
create
:web_hook
,
project:
project
}
describe
:execute
do
it
"should execute successfully"
do
...
...
spec/support/stub_gitlab_calls.rb
View file @
e2cbb36b
...
...
@@ -24,20 +24,20 @@ module StubGitlabCalls
stub_request
(
:post
,
"
#{
gitlab_url
}
api/v3/session.json"
).
with
(
body:
"{
\"
email
\"
:
\"
test@test.com
\"
,
\"
password
\"
:
\"
123456
\"
}"
,
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
201
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
201
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
def
stub_user
f
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/user.json'
))
stub_request
(
:get
,
"
#{
gitlab_url
}
api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
with
(
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"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
def
stub_project_8
...
...
@@ -54,19 +54,19 @@ module StubGitlabCalls
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"
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
with
(
headers:
{
'Content-Type'
=>
'application/json'
}).
to_return
(
status:
200
,
body:
f
,
headers:
{
'Content-Type'
=>
'application/json'
})
end
def
stub_projects_owned
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:
{})
end
def
stub_ci_enable
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:
{})
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