Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Only ignore events on closed pull requests if its a COMMENT-event #48 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 13, 2015
1 parent 4497d05 commit c1912f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Changelog of Pull Request Notifier for Stash.

## 1.19

* Bugfix: Only ignore events on closed pull requests if its a COMMENT-event.

## 1.18
* Avoiding endless loop if user not 'System Admin' when editing configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
import com.atlassian.stash.event.pull.PullRequestApprovedEvent;
import com.atlassian.stash.event.pull.PullRequestCommentAddedEvent;
import com.atlassian.stash.event.pull.PullRequestCommentEvent;
import com.atlassian.stash.event.pull.PullRequestCommentRepliedEvent;
import com.atlassian.stash.event.pull.PullRequestDeclinedEvent;
import com.atlassian.stash.event.pull.PullRequestEvent;
Expand Down Expand Up @@ -126,7 +127,7 @@ public void onEvent(PullRequestUpdatedEvent e) {
@VisibleForTesting
public void handleEvent(final PullRequestEvent pullRequestEvent) {
try {
if (pullRequestEvent.getPullRequest().isClosed()) {
if (pullRequestEvent.getPullRequest().isClosed() && pullRequestEvent instanceof PullRequestCommentEvent) {
return;
}
final PrnfsSettings settings = getPrnfsSettings(pluginSettingsFactory.createGlobalSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,26 @@ public void testThatAUrlIsOnlyInvokedForConfiguredEvents() {
}

@Test
public void testThatClosedPullRequestsAreIgnored() {
public void testThatClosedPullRequestsAreNotIgnoredForOpenedEvent() {
prnfsTestBuilder()
.isLoggedInAsAdmin()
.withNotification(
notificationBuilder().withFieldValue(AdminFormValues.FIELDS.url, "http://bjurr.se/")
.withFieldValue(AdminFormValues.FIELDS.events, OPENED.name()).build()).store()
.trigger(pullRequestEventBuilder() //
.beingClosed().withToRef(pullRequestRefBuilder()).withPullRequestAction(OPENED).build()).invokedNoUrl();
.beingClosed().withToRef(pullRequestRefBuilder()).withPullRequestAction(OPENED).build())
.invokedOnlyUrl("http://bjurr.se/");
}

@Test
public void testThatClosedPullRequestsAreIgnoredForCommentEvent() {
prnfsTestBuilder()
.isLoggedInAsAdmin()
.withNotification(
notificationBuilder().withFieldValue(AdminFormValues.FIELDS.url, "http://bjurr.se/")
.withFieldValue(AdminFormValues.FIELDS.events, COMMENTED.name()).build()).store()
.trigger(pullRequestEventBuilder() //
.beingClosed().withToRef(pullRequestRefBuilder()).withPullRequestAction(COMMENTED).build()).invokedNoUrl();
}

@Test
Expand Down

0 comments on commit c1912f1

Please sign in to comment.