Commit 62ba789545555dbed2df5e21d3db4dcb54b1bbae
1 parent
0a53e47b
Exists in
master
and in
4 other branches
Added can_test? mehod to Service model and added tests
Showing
3 changed files
with
42 additions
and
1 deletions
Show diff stats
app/models/service.rb
app/views/projects/services/_form.html.haml
@@ -44,5 +44,5 @@ | @@ -44,5 +44,5 @@ | ||
44 | .form-actions | 44 | .form-actions |
45 | = f.submit 'Save', class: 'btn btn-save' | 45 | = f.submit 'Save', class: 'btn btn-save' |
46 | | 46 | |
47 | - - if @service.valid? && @service.activated? | 47 | + - if @service.valid? && @service.activated? && @service.can_test? |
48 | = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small' | 48 | = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small' |
spec/models/service_spec.rb
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | require 'spec_helper' | 18 | require 'spec_helper' |
19 | 19 | ||
20 | describe Service do | 20 | describe Service do |
21 | + | ||
21 | describe "Associations" do | 22 | describe "Associations" do |
22 | it { should belong_to :project } | 23 | it { should belong_to :project } |
23 | it { should have_one :service_hook } | 24 | it { should have_one :service_hook } |
@@ -26,4 +27,40 @@ describe Service do | @@ -26,4 +27,40 @@ describe Service do | ||
26 | describe "Mass assignment" do | 27 | describe "Mass assignment" do |
27 | it { should_not allow_mass_assignment_of(:project_id) } | 28 | it { should_not allow_mass_assignment_of(:project_id) } |
28 | end | 29 | end |
30 | + | ||
31 | + describe "Test Button" do | ||
32 | + before do | ||
33 | + @service = Service.new | ||
34 | + end | ||
35 | + | ||
36 | + describe "Testable" do | ||
37 | + let (:project) { create :project } | ||
38 | + | ||
39 | + before do | ||
40 | + @service.stub( | ||
41 | + project: project | ||
42 | + ) | ||
43 | + @testable = @service.can_test? | ||
44 | + end | ||
45 | + | ||
46 | + describe :can_test do | ||
47 | + it { @testable.should == false } | ||
48 | + end | ||
49 | + end | ||
50 | + | ||
51 | + describe "With commits" do | ||
52 | + let (:project) { create :project_with_code } | ||
53 | + | ||
54 | + before do | ||
55 | + @service.stub( | ||
56 | + project: project | ||
57 | + ) | ||
58 | + @testable = @service.can_test? | ||
59 | + end | ||
60 | + | ||
61 | + describe :can_test do | ||
62 | + it { @testable.should == true } | ||
63 | + end | ||
64 | + end | ||
65 | + end | ||
29 | end | 66 | end |