mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 10:55:22 +00:00
HG-78: allow updates to pending or suspended shop (#49)
This commit is contained in:
parent
4905525c76
commit
8b3fcdbc2e
@ -314,7 +314,7 @@ handle_call({create_shop, Params, _UserInfo}, StEvents0) ->
|
||||
|
||||
handle_call({update_shop, ID, Update, _UserInfo}, StEvents0) ->
|
||||
ok = assert_operable(StEvents0),
|
||||
ok = assert_shop_operable(ID, StEvents0),
|
||||
ok = assert_shop_modification_allowed(ID, StEvents0),
|
||||
{ClaimID, StEvents1} = create_claim([?shop_modification(ID, {update, Update})], StEvents0),
|
||||
respond(get_claim_result(ClaimID, StEvents1), StEvents1);
|
||||
|
||||
@ -554,9 +554,10 @@ assert_suspension(#domain_Party{suspension = {Status, _}}, Status) ->
|
||||
assert_suspension(#domain_Party{suspension = Suspension}, _) ->
|
||||
raise(#payproc_InvalidPartyStatus{status = {suspension, Suspension}}).
|
||||
|
||||
assert_shop_operable(ID, StEvents) ->
|
||||
_ = assert_shop_unblocked(ID, StEvents),
|
||||
_ = assert_shop_active(ID, StEvents).
|
||||
assert_shop_modification_allowed(ID, {St, Events}) ->
|
||||
% We allow updates to pending shop
|
||||
PendingSt = get_pending_st(St),
|
||||
_ = assert_shop_unblocked(ID, {PendingSt, Events}).
|
||||
|
||||
assert_shop_unblocked(ID, {St, _}) ->
|
||||
Shop = get_shop(ID, get_party(St)),
|
||||
|
@ -39,6 +39,7 @@
|
||||
-export([shop_not_found_on_retrieval/1]).
|
||||
-export([shop_creation/1]).
|
||||
-export([shop_update/1]).
|
||||
-export([shop_update_before_confirm/1]).
|
||||
-export([shop_blocking/1]).
|
||||
-export([shop_unblocking/1]).
|
||||
-export([shop_already_blocked/1]).
|
||||
@ -110,6 +111,7 @@ groups() ->
|
||||
{shop_management, [sequence], [
|
||||
party_creation,
|
||||
shop_not_found_on_retrieval,
|
||||
shop_update_before_confirm,
|
||||
shop_creation,
|
||||
shop_activation,
|
||||
shop_update,
|
||||
@ -257,6 +259,7 @@ end_per_testcase(_Name, _C) ->
|
||||
-spec shop_not_found_on_retrieval(config()) -> _ | no_return().
|
||||
-spec shop_creation(config()) -> _ | no_return().
|
||||
-spec shop_update(config()) -> _ | no_return().
|
||||
-spec shop_update_before_confirm(config()) -> _ | no_return().
|
||||
-spec party_revisioning(config()) -> _ | no_return().
|
||||
-spec claim_already_accepted_on_revoke(config()) -> _ | no_return().
|
||||
-spec claim_already_accepted_on_accept(config()) -> _ | no_return().
|
||||
@ -362,6 +365,34 @@ shop_update(C) ->
|
||||
ok = accept_claim(Claim, Client),
|
||||
?shop_state(#domain_Shop{details = Details}) = hg_client_party:get_shop(ShopID, Client).
|
||||
|
||||
shop_update_before_confirm(C) ->
|
||||
Client = ?c(client, C),
|
||||
Params = #payproc_ShopParams{
|
||||
category = hg_ct_helper:make_category_ref(42),
|
||||
details = hg_ct_helper:make_shop_details(<<"THRIFT SHOP">>, <<"Hot. Fancy. Almost free.">>)
|
||||
},
|
||||
Result = hg_client_party:create_shop(Params, Client),
|
||||
Claim1 = assert_claim_pending(Result, Client),
|
||||
?claim(
|
||||
ClaimID1,
|
||||
?pending(),
|
||||
[
|
||||
{shop_creation, #domain_Shop{id = ShopID}},
|
||||
{shop_modification, #payproc_ShopModificationUnit{
|
||||
id = ShopID,
|
||||
modification = {accounts_created, _}
|
||||
}}
|
||||
]
|
||||
) = Claim1,
|
||||
?shop_not_found() = hg_client_party:get_shop(ShopID, Client),
|
||||
NewDetails = hg_ct_helper:make_shop_details(<<"BARBIES SHOP">>, <<"Hot. Short. Clean.">>),
|
||||
Update = #payproc_ShopUpdate{details = NewDetails},
|
||||
UpdateResult = hg_client_party:update_shop(ShopID, Update, Client),
|
||||
Claim2 = assert_claim_pending(UpdateResult, Client),
|
||||
?claim_status_changed(ClaimID1, ?revoked(_)) = next_event(Client),
|
||||
ok = accept_claim(Claim2, Client),
|
||||
?shop_state(#domain_Shop{details = NewDetails}) = hg_client_party:get_shop(ShopID, Client).
|
||||
|
||||
claim_acceptance(C) ->
|
||||
Client = ?c(client, C),
|
||||
#domain_Shop{id = ShopID} = get_last_shop(Client),
|
||||
|
Loading…
Reference in New Issue
Block a user