Skip to content

Commit

Permalink
Merge pull request #1686 from jhawthorn/deprecate_address_empty_take_2
Browse files Browse the repository at this point in the history
Deprecate Address#empty?
  • Loading branch information
jhawthorn authored Jan 19, 2017
2 parents 1420aaa + 57b005a commit 92d2cca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
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

0 comments on commit 92d2cca

Please sign in to comment.