Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Address#empty? #1686

Merged
merged 4 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<% if Spree::Config[:order_bill_address_used] %>
<div class="field" style="position: absolute;margin-top: -15px;left: 0;">
<span data-hook="use_billing">
<%= check_box_tag 'order[use_billing]', '1', ((@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address == @order.ship_address) %>
<%= check_box_tag 'order[use_billing]', '1', (@order.ship_address.new_record? && @order.bill_address == @order.ship_address) %>
<%= label_tag 'order[use_billing]', Spree.t(:use_billing_address) %>
</span>
</div>
Expand Down
8 changes: 4 additions & 4 deletions backend/spec/features/admin/orders/new_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
targetted_select2_search user.email, from: "#s2id_customer_search"
end

check "order_use_billing"
expect(page).to have_checked_field('order_use_billing')
fill_in_address
click_on "Update"

Expand Down Expand Up @@ -73,7 +73,7 @@
targetted_select2_search user.email, from: "#s2id_customer_search"
end

check "order_use_billing"
expect(page).to have_checked_field('order_use_billing')
fill_in_address
click_on "Update"

Expand Down Expand Up @@ -108,7 +108,7 @@
targetted_select2_search user.email, from: "#s2id_customer_search"
end

check "order_use_billing"
expect(page).to have_checked_field('order_use_billing')
fill_in_address
click_on "Update"

Expand Down Expand Up @@ -157,7 +157,7 @@
targetted_select2_search user.email, from: "#s2id_customer_search"
end

check "order_use_billing"
expect(page).to have_checked_field('order_use_billing')
fill_in_address
click_on "Update"

Expand Down
13 changes: 11 additions & 2 deletions core/app/models/spree/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,28 @@ def ==(other_address)
end

def same_as?(other_address)
Spree::Deprecation.warn("Address.same_as? is deprecated. It's equivalent to Address.==", caller)
Spree::Deprecation.warn("Address#same_as? is deprecated. It's equivalent to Address.==", caller)
self == other_address
end

def same_as(other_address)
Spree::Deprecation.warn("Address.same_as is deprecated. It's equivalent to Address.==", caller)
Spree::Deprecation.warn("Address#same_as is deprecated. It's equivalent to Address.==", caller)
self == other_address
end

# @deprecated Do not use this
def empty?
Spree::Deprecation.warn("Address#empty? is deprecated.", caller)
attributes.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, v| v.nil? }
end

# This exists because the default Object#blank?, checks empty? if it is
# defined, and we have defined empty.
# This should be removed once empty? is removed
def blank?
false
end

# @return [Hash] an ActiveMerchant compatible address hash
def active_merchant_hash
{
Expand Down