Commit 62ba7895 authored by Ronald van Eede's avatar Ronald van Eede

Added can_test? mehod to Service model and added tests

parent 0a53e47b
......@@ -49,4 +49,8 @@ class Service < ActiveRecord::Base
def execute
# implement inside child
end
def can_test?
!project.empty_repo?
end
end
......@@ -44,5 +44,5 @@
.form-actions
= f.submit 'Save', class: 'btn btn-save'
&nbsp;
- 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'
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment