From 028fc8c641cce61baeda8c79b187a3a7daae5e1e Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Wed, 9 Sep 2015 15:21:08 +0200 Subject: [PATCH] test transaction controller with invalid requests --- .../transactions_controller_spec.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index fd1135d..07f353a 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -40,5 +40,26 @@ RSpec.describe TransactionsController, type: :controller do expect(@transaction.issuer).to eq(@debtor) end end + + context "with negative amount" do + it "should be refused" do + expect do + post :create, transaction: attributes_for(:transaction, amount: -20) + end.not_to change {Transaction.count} + end + end + + context "for other user" do + it "should be refused" do + expect do + post :create, transaction: { + debtor: @creditor, + creditor: @debtor, + amount: 10000000000000, + message: 'DIT IS OVERVAL' + } + end.not_to change {Transaction.count} + end + end end end