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)

Зареждане…
Отказ
Запис