示例#1
0
  @Test
  public void should_not_log_in_with_invalid_user() {
    UserFlow navigation = login(navigate(), "invalidEmail");
    VRaptorTestResult loginResult = navigation.followRedirect().execute();
    loginResult.wasStatus(200).isValid();

    LoggedUser loggedUser = loginResult.getObject("currentUser");
    User currentUser = loggedUser.getCurrent();

    assertThat(currentUser, equalTo(User.GHOST));
  }
示例#2
0
  @Test
  public void should_log_in() {
    User user = randomUser();
    UserFlow navigation = login(navigate(), user.getEmail());
    VRaptorTestResult loginResult = navigation.followRedirect().execute();
    loginResult.wasStatus(200).isValid();

    LoggedUser loggedUser = loginResult.getObject("currentUser");
    User currentUser = loggedUser.getCurrent();

    assertThat(currentUser.getId(), equalTo(user.getId()));
  }
示例#3
0
 public boolean shouldShowAds() {
   if (!loggedUser.isLoggedIn()) {
     return true;
   }
   User current = loggedUser.getCurrent();
   if (current.getKarma() <= 50) {
     return true;
   }
   if (current.getKarma() <= 1000) {
     return shouldShowWithPercentage(50);
   }
   return shouldShowWithPercentage(25);
 }
 @Override
 public boolean shouldHandle(Flaggable flaggable) {
   boolean isQuestion = Answer.class.isAssignableFrom(flaggable.getClass());
   return isQuestion && loggedUser.isLoggedIn() && loggedUser.isModerator();
 }