Commit 692e1b4b104f7634226f8c4d3254e3960a6f430a
Exists in
master
and in
4 other branches
Merge pull request #4750 from ronaldvaneede/test_service_button
Fix for #4535 ('Test settings' button for services gives 500 on empty repo)
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 | 44 | .form-actions |
| 45 | 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 | 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 | 18 | require 'spec_helper' |
| 19 | 19 | |
| 20 | 20 | describe Service do |
| 21 | + | |
| 21 | 22 | describe "Associations" do |
| 22 | 23 | it { should belong_to :project } |
| 23 | 24 | it { should have_one :service_hook } |
| ... | ... | @@ -26,4 +27,40 @@ describe Service do |
| 26 | 27 | describe "Mass assignment" do |
| 27 | 28 | it { should_not allow_mass_assignment_of(:project_id) } |
| 28 | 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 | 66 | end | ... | ... |