Search in sources :

Example 1 with News

use of org.mamute.model.News in project mamute by caelum.

the class NewsController method newNews.

@Post
@CustomBrutauthRules({ LoggedRule.class, InputRule.class })
public void newNews(String title, MarkedText description) {
    NewsInformation information = new NewsInformation(title, description, currentUser, "new news");
    User author = currentUser.getCurrent();
    News news = new News(information, author);
    result.include("news", news);
    newses.save(news);
    result.redirectTo(this).showNews(news, news.getSluggedTitle());
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) News(org.mamute.model.News) NewsInformation(org.mamute.model.NewsInformation) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 2 with News

use of org.mamute.model.News in project mamute by caelum.

the class VoteDAOTest method should_find_news_from_votable.

@Test
public void should_find_news_from_votable() throws Exception {
    News news = new NewsBuilder().build();
    ReputationEventContext context = votes.contextOf(news);
    assertEquals(news, context);
}
Also used : NewsBuilder(org.mamute.builder.NewsBuilder) News(org.mamute.model.News) ReputationEventContext(org.mamute.model.ReputationEventContext) Test(org.junit.Test)

Example 3 with News

use of org.mamute.model.News in project mamute by caelum.

the class NewsTest method not_approved_news_should_be_visible_to_moderator.

@Test
public void not_approved_news_should_be_visible_to_moderator() {
    News news = news("news title", "news description", author);
    assertTrue(news.checkVisibilityFor(loggedUser(moderator)));
}
Also used : News(org.mamute.model.News) Test(org.junit.Test)

Example 4 with News

use of org.mamute.model.News in project mamute by caelum.

the class NewsTest method approved_news_should_be_visible.

@Test
public void approved_news_should_be_visible() {
    News news = news("news title", "news description", author).approved();
    news.checkVisibilityFor(loggedUser(regularUser));
    news.checkVisibilityFor(loggedUser(author));
    news.checkVisibilityFor(loggedUser(moderator));
}
Also used : News(org.mamute.model.News) Test(org.junit.Test)

Example 5 with News

use of org.mamute.model.News in project mamute by caelum.

the class PostViewCounterTest method should_increase_count_only_the_news_counter.

@Test
public void should_increase_count_only_the_news_counter() {
    Question question = new QuestionBuilder().withId(1l).build();
    News news = new NewsBuilder().withId(1l).build();
    questionViewCounter.ping(question);
    mockQuestionVisited(question);
    questionViewCounter.ping(news);
    assertEquals(1l, question.getViews());
    assertEquals(1l, news.getViews());
}
Also used : NewsBuilder(org.mamute.builder.NewsBuilder) QuestionBuilder(org.mamute.builder.QuestionBuilder) News(org.mamute.model.News) Question(org.mamute.model.Question) Test(org.junit.Test)

Aggregations

News (org.mamute.model.News)12 Test (org.junit.Test)7 LoggedUser (org.mamute.model.LoggedUser)3 NewsInformation (org.mamute.model.NewsInformation)3 User (org.mamute.model.User)3 DateTime (org.joda.time.DateTime)2 NewsBuilder (org.mamute.builder.NewsBuilder)2 Question (org.mamute.model.Question)2 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)1 Get (br.com.caelum.vraptor.Get)1 Post (br.com.caelum.vraptor.Post)1 Email (org.apache.commons.mail.Email)1 QuestionBuilder (org.mamute.builder.QuestionBuilder)1 ReputationEventContext (org.mamute.model.ReputationEventContext)1 LinkToHelper (org.mamute.notification.NotificationMailer.LinkToHelper)1