Bladeren bron

Fixed issue #1

master
Ludovic 'Archivist' Lagouardette 6 jaren geleden
bovenliggende
commit
c648844d08
3 gewijzigde bestanden met toevoegingen van 19 en 1 verwijderingen
  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 Bestand weergeven

@ -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 Bestand weergeven

@ -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 Bestand weergeven

@ -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)

Laden…
Annuleren
Opslaan