Skip to content

Commit fa744ee

Browse files
committed
Series sales form: trim URL.
Fix #661
1 parent 8034083 commit fa744ee

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/main/java/ru/mystamps/web/controller/SeriesController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public class SeriesController {
112112
}
113113

114114
@InitBinder("addSeriesForm")
115-
protected void initBinder(WebDataBinder binder) {
115+
protected void initSeriesFormBinder(WebDataBinder binder) {
116116
StringTrimmerEditor editor = new StringTrimmerEditor(" ", true);
117117
binder.registerCustomEditor(String.class, "michelNumbers", editor);
118118
binder.registerCustomEditor(String.class, "scottNumbers", editor);
@@ -121,6 +121,11 @@ protected void initBinder(WebDataBinder binder) {
121121
binder.registerCustomEditor(String.class, "comment", new StringTrimmerEditor(true));
122122
}
123123

124+
@InitBinder("addSeriesSalesForm")
125+
protected void initSeriesSalesFormBinder(WebDataBinder binder) {
126+
binder.registerCustomEditor(String.class, "url", new StringTrimmerEditor(true));
127+
}
128+
124129
@GetMapping(Url.ADD_SERIES_PAGE)
125130
public void showForm(
126131
@Category @RequestParam(name = "category", required = false) LinkEntityDto category,

src/main/webapp/WEB-INF/views/series/info.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ <h5 th:text="|#{t_who_selling_series}:|">Who was selling/buying this series:</h5
370370
<div class="row" togglz:active="ADD_PURCHASES_AND_SALES" sec:authorize="hasAuthority('ADD_SERIES_SALES')">
371371
<div class="col-sm-12">
372372
<h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying this series:</h5>
373-
<form method="post" class="form-horizontal" action="info.html" th:action="@{${ADD_SERIES_ASK_PAGE}(id=${series.id})}" th:object="${addSeriesSalesForm}">
373+
<form id="add-series-sales-form"
374+
method="post"
375+
class="form-horizontal"
376+
action="info.html"
377+
th:action="@{${ADD_SERIES_ASK_PAGE}(id=${series.id})}"
378+
th:object="${addSeriesSalesForm}">
374379

375380
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('date') ? 'has-error' : ''}">
376381
<label for="date" class="control-label col-sm-3">
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
*** Settings ***
2+
Documentation Verify miscellaneous aspects of adding series sales
3+
Library Selenium2Library
4+
Resource ../../auth.steps.robot
5+
Suite Setup Before Test Suite
6+
Suite Teardown After Test Suite
7+
Force Tags series sales misc
8+
9+
*** Test Cases ***
10+
Url should be stripped from leading and trailing spaces
11+
[Documentation] Verify removing of leading and trailing spaces from a URL
12+
Input Text id=url ${SPACE * 2}bad-value${SPACE * 2}
13+
Submit Form id=add-series-sales-form
14+
# We can't use "Textfield Value Should Be" because it causes NPE:
15+
# https://github.com/MarkusBernhardt/robotframework-selenium2library-java/issues/92
16+
${value}= Get Value id=url
17+
Should Be Equal ${value} bad-value
18+
19+
*** Keywords ***
20+
Before Test Suite
21+
[Documentation] Login as admin and open a page with series
22+
Open Browser ${SITE_URL} ${BROWSER}
23+
Register Keyword To Run On Failure Log Source
24+
Log In As login=admin password=test
25+
Go To ${SITE_URL}/series/1
26+
27+
After Test Suite
28+
[Documentation] Log out and close browser
29+
Log Out
30+
Close Browser

0 commit comments

Comments
 (0)