Skip to content

Commit 1dfe9e7

Browse files
committed
fix: when a paid user adds a series to a collection, price must always be specified together with currency
Fix #886
1 parent 417f8df commit 1dfe9e7

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

Diff for: src/main/java/ru/mystamps/web/feature/collection/AddToCollectionForm.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import lombok.Getter;
2121
import lombok.Setter;
2222
import ru.mystamps.web.common.Currency;
23+
import ru.mystamps.web.support.beanvalidation.BothOrNoneRequired;
2324

2425
import javax.validation.constraints.Min;
2526
import javax.validation.constraints.NotNull;
@@ -32,6 +33,11 @@
3233
@Getter
3334
@Setter
3435
@MaxNumberOfStamps
36+
@BothOrNoneRequired(
37+
first = "price",
38+
second = "currency",
39+
message = "{price.currency.both-required}"
40+
)
3541
public class AddToCollectionForm implements AddToCollectionDto {
3642

3743
@NotNull
@@ -41,7 +47,6 @@ public class AddToCollectionForm implements AddToCollectionDto {
4147
// @todo #663 /series/{id}(price): must be greater than zero
4248
private BigDecimal price;
4349

44-
// @todo #663 /series/{id}(currency): must be required when price is specified
4550
private Currency currency;
4651

4752
// In order to ensure that numberOfStamps <= series.quantity,

Diff for: src/main/resources/ru/mystamps/i18n/ValidationMessages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ password.login.match = Password and login must be different
5353
seller.buyer.match = Seller and buyer must be different
5454
currencies.prices.match = Price and alternative price must be in a different currencies
5555
altprice.altcurrency.both-required = Alternative price and currency must be specified or left empty, specifying only one of them makes no-sense
56+
price.currency.both-required = Price and currency must be specified or left empty, specifying only one of them makes no-sense
5657
5758
name.invalid = Name must consist only letters, hyphen or spaces
5859

Diff for: src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ password.login.match = Пароль и логин не должны совпад
5353
seller.buyer.match = Продавец и покупатель не должны совпадать
5454
currencies.prices.match = Цена и альтернативная цена должны быть в различных валютах
5555
altprice.altcurrency.both-required = Альтернативная цена и валюта должны быть указаны или оставлены пустыми, указание только одного поля не имеет смысла
56+
price.currency.both-required = Цена и валюта должны быть указаны или оставлены пустыми, указание только одного поля не имеет смысла
5657

5758
name.invalid = Имя может состоять только из букв, дефиса или пробелов
5859

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
*** Settings ***
2+
Documentation Verify validation of adding a series to collection for a paid user
3+
Library SeleniumLibrary
4+
Resource ../../auth.steps.robot
5+
Resource ../../selenium.utils.robot
6+
Suite Setup Before Test Suite
7+
Suite Teardown Close Browser
8+
Test Setup Disable Client Validation add-series-form
9+
Force Tags collection validation
10+
11+
*** Test Cases ***
12+
Add a series with price but without currency
13+
Input Text id:paid-price 20
14+
Select From List By Value id:paid-currency ${EMPTY}
15+
Submit Form id:add-series-form
16+
Element Text Should Be id:paid-currency.errors Price and currency must be specified or left empty, specifying only one of them makes no-sense
17+
18+
Add a series with currency but without price
19+
Input Text id:paid-price ${EMPTY}
20+
Select From List By Label id:paid-currency CZK
21+
Submit Form id:add-series-form
22+
Element Text Should Be id:paid-currency.errors Price and currency must be specified or left empty, specifying only one of them makes no-sense
23+
24+
*** Keywords ***
25+
Before Test Suite
26+
Open Browser ${SITE_URL}/account/auth ${BROWSER}
27+
Register Keyword To Run On Failure Log Source
28+
Log In As login=paid password=test
29+
Go To ${SITE_URL}/series/1

Diff for: src/test/robotframework/collection/add-series/validation.robot renamed to src/test/robotframework/collection/add-series/validation-user.robot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Documentation Verify validation of adding a series to collection
2+
Documentation Verify validation of adding a series to collection for a user
33
Library SeleniumLibrary
44
Resource ../../auth.steps.robot
55
Resource ../../selenium.utils.robot

0 commit comments

Comments
 (0)