private fun <T> verifySingleFieldCanBeChanged(fieldName: String, newValue: T, expectedValue: T = newValue, fieldAccessor: () -> T) {
request("", POST)
private fun <T> verifySingleFieldCanBeChanged(fieldName: String, newValue: T, expectedValue: T = newValue, fieldAccessor: () -> T) {
request("", POST)
- addHttpRequestParameter("save-profile", "true")
- addHttpRequestParameter(fieldName, newValue.toString())
+ addHttpRequestPart("save-profile", "true")
+ addHttpRequestPart(fieldName, newValue.toString())
verifyRedirect("editProfile.html") {
verify(core).touchConfiguration()
assertThat(fieldAccessor(), equalTo(expectedValue))
verifyRedirect("editProfile.html") {
verify(core).touchConfiguration()
assertThat(fieldAccessor(), equalTo(expectedValue))
fun `adding a field with a duplicate name sets error in template context`() {
request("", POST)
profile.addField("new-field")
fun `adding a field with a duplicate name sets error in template context`() {
request("", POST)
profile.addField("new-field")
- addHttpRequestParameter("add-field", "true")
- addHttpRequestParameter("field-name", "new-field")
+ addHttpRequestPart("add-field", "true")
+ addHttpRequestPart("field-name", "new-field")
page.processTemplate(freenetRequest, templateContext)
assertThat(templateContext["fieldName"], equalTo<Any>("new-field"))
assertThat(templateContext["duplicateFieldName"], equalTo<Any>(true))
page.processTemplate(freenetRequest, templateContext)
assertThat(templateContext["fieldName"], equalTo<Any>("new-field"))
assertThat(templateContext["duplicateFieldName"], equalTo<Any>(true))
- addHttpRequestParameter("add-field", "true")
- addHttpRequestParameter("field-name", "new-field")
+ addHttpRequestPart("add-field", "true")
+ addHttpRequestPart("field-name", "new-field")
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.getFieldByName("new-field"), notNullValue())
verify(currentSone).profile = profile
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.getFieldByName("new-field"), notNullValue())
verify(currentSone).profile = profile
verifyRedirect("deleteProfileField.html?field=${firstField.id}")
}
@Test
fun `moving a field up moves the field up and redirects to the edit profile page`() {
request("", POST)
verifyRedirect("deleteProfileField.html?field=${firstField.id}")
}
@Test
fun `moving a field up moves the field up and redirects to the edit profile page`() {
request("", POST)
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.fields, contains(secondField, firstField))
verify(currentSone).profile = profile
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.fields, contains(secondField, firstField))
verify(currentSone).profile = profile
page.processTemplate(freenetRequest, templateContext)
}
@Test
fun `moving a field down moves the field down and redirects to the edit profile page`() {
request("", POST)
page.processTemplate(freenetRequest, templateContext)
}
@Test
fun `moving a field down moves the field down and redirects to the edit profile page`() {
request("", POST)
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.fields, contains(secondField, firstField))
verify(currentSone).profile = profile
verifyRedirect("editProfile.html#profile-fields") {
assertThat(profile.fields, contains(secondField, firstField))
verify(currentSone).profile = profile
page.processTemplate(freenetRequest, templateContext)
}
@Test
fun `editing a field redirects to the edit profile page`() {
request("", POST)
page.processTemplate(freenetRequest, templateContext)
}
@Test
fun `editing a field redirects to the edit profile page`() {
request("", POST)