use of org.mamute.model.LoggedUser in project mamute by caelum.
the class FlaggableDAOTest method setup.
@Before
public void setup() {
flaggedInvisible.remove();
addFlags(commentWithOneFlag, 1, author);
addFlags(commentWithTwo, 2, author);
addFlags(flaggedInvisible, 2, author);
session.save(author);
session.save(anyone);
session.save(commentWithTwo);
session.save(flaggedInvisible);
session.save(commentWithOneFlag);
session.save(java);
session.save(question);
session.flush();
flaggables = new FlaggableDAO(session, meta);
questions = new QuestionDAO(session, new InvisibleForUsersRule(new LoggedUser(anyone, null)));
List<Class<? extends Flaggable>> moderatableTypes = new ArrayList<>();
moderatableTypes.add(Question.class);
moderatableTypes.add(Answer.class);
moderatableTypes.add(Comment.class);
moderatableTypes.add(News.class);
when(meta.getFlaggableTypes()).thenReturn(moderatableTypes);
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class InvisibleForUsersRuleTest method should_add_filter_if_user_is_not_logged_in.
@Test
public void should_add_filter_if_user_is_not_logged_in() {
LoggedUser user = new LoggedUser(null, null);
InvisibleForUsersRule invisibleForUsersRule = new InvisibleForUsersRule(user);
invisibleForUsersRule.addFilter("x", criteria);
verify(criteria, only()).add(Mockito.any(Criterion.class));
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class QuestionDAOTest method setup.
@Before
public void setup() {
author = user("Leonardo", "leo@leo");
moderator = user("Leonardo", "leo@leo").asModerator();
anyone = user("Leonardo", "leo@leo");
session.save(author);
session.save(moderator);
session.save(anyone);
session.save(java);
session.save(defaultTag);
this.questionsBeingAuthor = new QuestionDAO(session, new InvisibleForUsersRule(new LoggedUser(author, null)));
this.questionsBeingModerator = new QuestionDAO(session, new InvisibleForUsersRule(new LoggedUser(moderator, null)));
this.questionsForAnyone = new QuestionDAO(session, new InvisibleForUsersRule(new LoggedUser(anyone, null)));
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class EditAnswerRuleTest method loggedUser_with_low_karma_should_not_be_allowed_to_edit.
@Test
public void loggedUser_with_low_karma_should_not_be_allowed_to_edit() throws IOException {
LoggedUser other = loggedUser("other", "other@brutal.com", NOT_AUTHOR);
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertFalse(new EditAnswerRule(other, env).isAllowed(answer));
}
use of org.mamute.model.LoggedUser in project mamute by caelum.
the class EditQuestionRuleTest method moderator_should_be_allowed_to_edit.
@Test
public void moderator_should_be_allowed_to_edit() throws IOException {
LoggedUser moderator = loggedUser("moderator", "moderator@brutal.com", 2l);
moderator.getCurrent().asModerator();
ServletContext ctx = mock(ServletContext.class);
EnvironmentKarma env = new EnvironmentKarma(new MamuteEnvironment(ctx));
assertTrue(new EditQuestionRule(moderator, env).isAllowed(question));
}
Aggregations