Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Add test for invalid address parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Luuk Veenis committed Sep 14, 2016
1 parent 505fe2f commit bb377c7
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
expect(order.payments.first.amount).to eq 55
end

context "and an address is provided" do
context "and a valid address is provided" do
it "creates a new address" do
# Creating the order also creates 3 addresses, we want to make sure
# the transaction import only creates 1 new one
Expand All @@ -51,6 +51,19 @@
end
end

context "and an invalid address is provided" do
before { params[:transaction][:address_attributes][:city] = nil }

it "raises a validation error" do
expect { post_create }.to raise_error(
ActiveRecord::RecordInvalid,
"Validation failed: " \
"Billing address city can't be blank, " \
"Shipping address city can't be blank"
)
end
end

context "and the transaction does not have an address" do
before { params[:transaction].delete(:address_attributes) }

Expand Down

0 comments on commit bb377c7

Please sign in to comment.