add more transaction controller tests
This commit is contained in:
parent
7626bab22a
commit
484ecb5468
1 changed files with 28 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
require 'rails_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe TransactionsController, type: :controller do
|
||||
describe "creating transaction" do
|
||||
|
@ -8,14 +9,36 @@ RSpec.describe TransactionsController, type: :controller do
|
|||
sign_in @debtor
|
||||
end
|
||||
|
||||
it "should create a valid transaction" do
|
||||
expect do
|
||||
put :create, { transaction: {
|
||||
context "with valid attributes" do
|
||||
before :each do
|
||||
@attributes = { transaction: {
|
||||
creditor: @creditor.name,
|
||||
amount: 20,
|
||||
message: "hoi"
|
||||
message: 'hoi'
|
||||
}}
|
||||
end.to change {Transaction.count}.by(1)
|
||||
post :create, @attributes
|
||||
@transaction = Transaction.last
|
||||
end
|
||||
|
||||
it "should create a new transaction" do
|
||||
expect {post :create, @attributes}.to change {Transaction.count}.by(1)
|
||||
end
|
||||
|
||||
it "should set debtor" do
|
||||
expect(@transaction.debtor).to eq(@debtor)
|
||||
end
|
||||
|
||||
it "should set amount" do
|
||||
expect(@transaction.amount).to eq(20)
|
||||
end
|
||||
|
||||
it "should set creditor" do
|
||||
expect(@transaction.creditor).to eq(@creditor)
|
||||
end
|
||||
|
||||
it "should set issuer" do
|
||||
expect(@transaction.issuer).to eq(@debtor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue