Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
e9a42b2f364d
Commit
62ba7895
authored
Aug 09, 2013
by
Ronald van Eede
Browse files
Added can_test? mehod to Service model and added tests
parent
791a87e221f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models/service.rb
View file @
e9a42b2f
...
...
@@ -49,4 +49,8 @@ def fields
def
execute
# implement inside child
end
def
can_test?
!
project
.
empty_repo?
end
end
app/views/projects/services/_form.html.haml
View file @
e9a42b2f
...
...
@@ -44,5 +44,5 @@
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-save'
-
if
@service
.
valid?
&&
@service
.
activated?
-
if
@service
.
valid?
&&
@service
.
activated?
&&
@service
.
can_test?
=
link_to
'Test settings'
,
test_project_service_path
(
@project
,
@service
.
to_param
),
class:
'btn btn-small'
spec/models/service_spec.rb
View file @
e9a42b2f
...
...
@@ -18,6 +18,7 @@
require
'spec_helper'
describe
Service
do
describe
"Associations"
do
it
{
should
belong_to
:project
}
it
{
should
have_one
:service_hook
}
...
...
@@ -26,4 +27,40 @@
describe
"Mass assignment"
do
it
{
should_not
allow_mass_assignment_of
(
:project_id
)
}
end
describe
"Test Button"
do
before
do
@service
=
Service
.
new
end
describe
"Testable"
do
let
(
:project
)
{
create
:project
}
before
do
@service
.
stub
(
project:
project
)
@testable
=
@service
.
can_test?
end
describe
:can_test
do
it
{
@testable
.
should
==
false
}
end
end
describe
"With commits"
do
let
(
:project
)
{
create
:project_with_code
}
before
do
@service
.
stub
(
project:
project
)
@testable
=
@service
.
can_test?
end
describe
:can_test
do
it
{
@testable
.
should
==
true
}
end
end
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