foodsoft/spec/controllers/finance/base_controller_spec.rb
Philipp Rothmann d7591d46b9 Add controller tests
Co-authored-by: viehlieb <pf@pragma-shift.net>
Co-authored-by: Tobias Kneuker <tk@pragma-shift.net>

seperate expects

refactor login user calls

add more articles to test sorting with

fix: fix test for rails upgrade
2023-01-17 16:09:52 +01:00

30 lines
900 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Finance::BaseController, type: :controller do
let(:user) { create :user, :role_finance, :role_orders, :ordergroup }
before { login user }
describe 'GET index' do
let(:fin_trans) { create_list :financial_transaction, 3, user: user, ordergroup: user.ordergroup }
let(:orders) { create_list :order, 2, state: 'finished' }
let(:invoices) { create_list :invoice, 4 }
before do
fin_trans
orders
invoices
end
it 'renders index page' do
get_with_defaults :index
expect(response).to have_http_status(:success)
expect(response).to render_template('finance/index')
expect(assigns(:financial_transactions).size).to eq(fin_trans.size)
expect(assigns(:orders).size).to eq(orders.size)
expect(assigns(:unpaid_invoices).size).to eq(invoices.size)
end
end
end