BigW Consortium Gitlab

Commit 62ba7895 by Ronald van Eede

Added can_test? mehod to Service model and added tests

parent 0a53e47b
...@@ -49,4 +49,8 @@ class Service < ActiveRecord::Base ...@@ -49,4 +49,8 @@ class Service < ActiveRecord::Base
def execute def execute
# implement inside child # implement inside child
end end
def can_test?
!project.empty_repo?
end
end end
...@@ -44,5 +44,5 @@ ...@@ -44,5 +44,5 @@
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
&nbsp; &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' = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small'
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
require 'spec_helper' require 'spec_helper'
describe Service do describe Service do
describe "Associations" do describe "Associations" do
it { should belong_to :project } it { should belong_to :project }
it { should have_one :service_hook } it { should have_one :service_hook }
...@@ -26,4 +27,40 @@ describe Service do ...@@ -26,4 +27,40 @@ describe Service do
describe "Mass assignment" do describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:project_id) } it { should_not allow_mass_assignment_of(:project_id) }
end 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 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