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