diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index c95f401..7ba1232 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -1,5 +1,21 @@ require 'rails_helper' RSpec.describe TransactionsController, type: :controller do + describe "creating transaction" do + before :each do + @debtor = create(:user) + @creditor = create(:user) + sign_in @debtor + end + it "should create a valid transaction" do + expect do + put :create, { transaction: { + creditor: @creditor.name, + amount: 20, + message: "hoi" + }} + end.to change {Transaction.count}.by(1) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 87ddb8c..fa3ad6a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,8 +17,10 @@ # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration require 'factory_girl' +require 'devise' RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods + config.include Devise::TestHelpers, type: :controller # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer.