Skip to content

Commit

Permalink
Spree::OrderUpdateAttributes only defined for solidus 1.2+.
Browse files Browse the repository at this point in the history
  • Loading branch information
hectoregm committed May 5, 2016
1 parent c377dab commit 197599c
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions spec/solidus/gateway/braintree_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,39 +92,41 @@
end
end

context 'order gets updated with device_data' do
it 'order passes device_data to create_profile' do
order = FactoryGirl.create(:order_with_line_items, user: user)
if Spree.respond_to?(:solidus_version) && Spree.solidus_version > "1.1"
context 'order gets updated with device_data' do
it 'order passes device_data to create_profile' do
order = FactoryGirl.create(:order_with_line_items, user: user)

bill_address = order.bill_address
expected_address = payment_method.send(:map_address, bill_address.try(:active_merchant_hash))
expected_params = {
first_name: "John",
last_name: "Doe",
email: user.email,
credit_card: {
cardholder_name: "John Doe",
billing_address: expected_address,
payment_method_nonce: nonce,
options: {
verify_card: true
}
},
device_data: device_data
}

update_params = { braintree_device_data: device_data,
payments_attributes: [
{ amount: order.total,
payment_method_id: payment_method.id,
bill_address = order.bill_address
expected_address = payment_method.send(:map_address, bill_address.try(:active_merchant_hash))
expected_params = {
first_name: "John",
last_name: "Doe",
email: user.email,
credit_card: {
cardholder_name: "John Doe",
billing_address: expected_address,
payment_method_nonce: nonce,
source_attributes:
{ cc_type: "",
name: "John Doe",
address_attributes: bill_address.attributes.except("id", "created_at", "updated_at") }}]}
options: {
verify_card: true
}
},
device_data: device_data
}

expect_any_instance_of(::Braintree::CustomerGateway).to receive(:create).with(expected_params).and_call_original
Spree::OrderUpdateAttributes.new(order, update_params, request_env: nil).apply
update_params = { braintree_device_data: device_data,
payments_attributes: [
{ amount: order.total,
payment_method_id: payment_method.id,
payment_method_nonce: nonce,
source_attributes:
{ cc_type: "",
name: "John Doe",
address_attributes: bill_address.attributes.except("id", "created_at", "updated_at") }}]}

expect_any_instance_of(::Braintree::CustomerGateway).to receive(:create).with(expected_params).and_call_original
Spree::OrderUpdateAttributes.new(order, update_params, request_env: nil).apply
end
end
end

Expand Down

0 comments on commit 197599c

Please sign in to comment.