Skip to content
Permalink
Browse files

Ignore disabled projects when evaluating post-commit hooks [FIXED JEN…

…KINS-15794]
  • Loading branch information...
kutzi committed Nov 24, 2012
1 parent 3d2e8e0 commit e493dd0ca038a126f9066ee31bf09c272d06d7fd
@@ -119,6 +119,7 @@ public void doNotifyCommit(StaplerRequest req, StaplerResponse rsp) throws Servl
}

for (AbstractProject<?,?> p : this.jobProvider.getAllJobs()) {
if(p.isDisabled()) continue;
try {
SCM scm = p.getScm();
if (scm instanceof SubversionSCM) scmFound = true; else continue;
@@ -0,0 +1,54 @@
package hudson.scm;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import hudson.model.AbstractProject;
import hudson.scm.SubversionRepositoryStatus.JobProvider;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

import javax.servlet.ServletException;

import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;


public class SubversionRepositoryStatusTest {

@SuppressWarnings("rawtypes")
@Test
@Bug(15794)
public void shouldIgnoreDisabledJobs() throws ServletException, IOException {
SubversionRepositoryStatus repositoryStatus = new SubversionRepositoryStatus(UUID.randomUUID());

final AbstractProject project = mock(AbstractProject.class);
when(project.isDisabled()).thenReturn(true);

JobProvider jobProvider = new JobProvider() {
@Override
public List<AbstractProject> getAllJobs() {
return Collections.singletonList(project);
}
};

repositoryStatus.setJobProvider(jobProvider);

StaplerRequest request = mock(StaplerRequest.class);
when(request.getReader()).thenReturn(new BufferedReader(new StringReader("/somepath\n")));
StaplerResponse response = mock(StaplerResponse.class);

repositoryStatus.doNotifyCommit(request, response);

verify(project, never()).getScm();
}

}

0 comments on commit e493dd0

Please sign in to comment.
You can’t perform that action at this time.