Ludovic 'Archivist' Lagouardette пре 6 година
родитељ
комит
c648844d08
3 измењених фајлова са 19 додато и 1 уклоњено
  1. +6
    -0
      spec/sales_backend_spec.cr
  2. +6
    -0
      src/sales_backend/address.cr
  3. +7
    -1
      src/sales_backend/http/user.cr

+ 6
- 0
spec/sales_backend_spec.cr Прегледај датотеку

@ -83,6 +83,12 @@ describe SalesBackend do
address_state = Array(Address).from_json(Global.response.not_nil!.body)
expected_address_state = Array(Address).from_json(new_address_str)
(address_state.to_json == expected_address_state.to_json).should be_true
delete "/user/address", headers, new_address_str
Global.response.not_nil!.status_code.should eq(200)
get "/user/address", headers
Global.response.not_nil!.status_code.should eq(200)
address_state = Array(Address).from_json(Global.response.not_nil!.body)
address_state.size.should eq(0)
get "/user/tokens", headers
Global.response.not_nil!.status_code.should eq(200)

+ 6
- 0
src/sales_backend/address.cr Прегледај датотеку

@ -48,4 +48,10 @@ class Address
end
return cmp
end
def == (other : Address)
0==(self<=>other)
end
def != (other : Address)
0!=(self<=>other)
end
end

+ 7
- 1
src/sales_backend/http/user.cr Прегледај датотеку

@ -153,7 +153,13 @@ delete "/user/address" do |context|
if old_list.nil?
addresses=Array(Address).new
else
addresses=old_list-addresses
addresses=old_list.select do |v|
isin=false
addresses.each do |va|
isin |= v==va
end
!isin
end
end
user_file.addresses=addresses
File.write(Statics.data_path+"user/"+user.email,user_file.to_json)

Loading…
Откажи
Сачувај