use of org.mamute.dto.UserPersonalInfo in project mamute by caelum.
the class UserProfileController method editProfile.
@Post
public void editProfile(@Load User user, SanitizedText name, String email, SanitizedText website, SanitizedText location, DateTime birthDate, MarkedText description, boolean isSubscribed, boolean receiveAllUpdates) {
if (!user.getId().equals(currentUser.getCurrent().getId())) {
result.redirectTo(ListController.class).home(null);
return;
}
if (website != null) {
website = correctWebsite(website);
}
UserPersonalInfo info = new UserPersonalInfo(user).withName(name).withEmail(email).withWebsite(website).withLocation(location).withBirthDate(birthDate).withAbout(description).withReceiveAllUpdates(receiveAllUpdates).withIsSubscribed(isSubscribed);
if (!infoValidator.validate(info)) {
infoValidator.onErrorRedirectTo(this).editProfile(user);
return;
}
users.updateLoginMethod(user, email);
user.setPersonalInformation(info);
result.redirectTo(this).showProfile(user, user.getSluggedName());
}
use of org.mamute.dto.UserPersonalInfo in project mamute by caelum.
the class UserPersonalInfoValidatorTest method should_not_validate_user_trying_to_update_name_before_allowed_time.
@Test
public void should_not_validate_user_trying_to_update_name_before_allowed_time() {
User artur = user("artur com seis caracteres", validEmail);
UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText("newName")).withEmail(artur.getEmail());
when(bundle.getMessage("date.joda.simple.pattern")).thenReturn("dd/MM/YYYY");
assertFalse(infoValidator.validate(info));
}
use of org.mamute.dto.UserPersonalInfo in project mamute by caelum.
the class UserPersonalInfoValidatorTest method should_pass_validation_with_not_required_elements_null.
@Test
public void should_pass_validation_with_not_required_elements_null() {
User artur = user("artur com seis caracteres", validEmail);
UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText(artur.getName())).withEmail(artur.getEmail());
assertTrue(infoValidator.validate(info));
}
use of org.mamute.dto.UserPersonalInfo in project mamute by caelum.
the class UserPersonalInfoValidatorTest method should_not_validate_null_user.
@Test
public void should_not_validate_null_user() {
UserPersonalInfo info = new UserPersonalInfo(null);
assertFalse(infoValidator.validate(info));
}
use of org.mamute.dto.UserPersonalInfo in project mamute by caelum.
the class UserPersonalInfoValidatorTest method should_not_validate_under_twelve_years_old_user.
@Test
public void should_not_validate_under_twelve_years_old_user() {
User artur = user("artur com seis caracteres", validEmail);
DateTime hoje = DateTime.now();
UserPersonalInfo info = new UserPersonalInfo(artur).withName(fromTrustedText(artur.getName())).withEmail(artur.getEmail()).withBirthDate(hoje);
assertFalse(infoValidator.validate(info));
}
Aggregations