Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #1264: Rultor accepts merge on PR made by ARC #1288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/rultor/agents/github/qtn/QnByArchitect.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
* @author Yegor Bugayenko ([email protected])
* @version $Id$
* @since 1.45
* @todo #1246:30min PR by ARC merge shouldn't require confirmation by ARC.
* Implement the asked in #1246. The tests have already benn implemented in
* QnByArchitectTest.acceptsIfMergeArchitectPull. After resolving this
* issue, uncomment the test.
*/
@Immutable
@ToString
Expand Down
36 changes: 36 additions & 0 deletions src/test/java/com/rultor/agents/github/qtn/QnByArchitectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.jcabi.github.Comment;
import com.jcabi.github.Issue;
import com.jcabi.github.Repo;
import com.jcabi.github.User;
import com.jcabi.github.mock.MkGithub;
import com.jcabi.xml.XMLDocument;
import com.rultor.agents.github.Question;
Expand All @@ -41,6 +42,7 @@
import java.util.Locale;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;

Expand Down Expand Up @@ -108,4 +110,38 @@ public void acceptsIfArchitect() throws Exception {
Mockito.verify(question).understand(comment, home);
}

/**
* QnByArchitect can accept if is a merge request made by anyone in a
* pull request made by an architect.
* @throws Exception In case of error.
*/
@Ignore
@Test
public void acceptsIfMergeArchitectPull() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final User author = Mockito.mock(User.class);
Mockito.when(author.login()).thenReturn(
repo.github().users().self().login().toUpperCase(
Locale.ENGLISH
)
);
final Issue.Smart issue = Mockito.mock(Issue.Smart.class);
Mockito.when(issue.author()).thenReturn(author);
Mockito.when(issue.isPull()).thenReturn(true);
final User reviewer = Mockito.mock(User.class);
Mockito.when(reviewer.login()).thenReturn("alfred");
final Comment.Smart comment = Mockito.mock(Comment.Smart.class);
Mockito.when(comment.body()).thenReturn("merge");
Mockito.when(comment.author()).thenReturn(reviewer);
final Question question = Mockito.mock(Question.class);
final URI home = new URI("#2");
new QnByArchitect(
new Profile.Fixed(
new XMLDocument("<p><entry key='c'>alfred</entry></p>")
),
"/p/entry[@key='c']/text()", question
).understand(comment, home);
Mockito.verify(question).understand(comment, home);
}

}