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
Jérome Perrin
gitlab-ce
Commits
62ba7895
Commit
62ba7895
authored
Aug 09, 2013
by
Ronald van Eede
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added can_test? mehod to Service model and added tests
parent
0a53e47b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
app/models/service.rb
app/models/service.rb
+4
-0
app/views/projects/services/_form.html.haml
app/views/projects/services/_form.html.haml
+1
-1
spec/models/service_spec.rb
spec/models/service_spec.rb
+37
-0
No files found.
app/models/service.rb
View file @
62ba7895
...
...
@@ -49,4 +49,8 @@ class Service < ActiveRecord::Base
def
execute
# implement inside child
end
def
can_test?
!
project
.
empty_repo?
end
end
app/views/projects/services/_form.html.haml
View file @
62ba7895
...
...
@@ -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 @
62ba7895
...
...
@@ -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 Service do
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