more spec'd
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Tobias Kneuker 2022-10-12 14:11:11 +02:00
parent d5b710dd9e
commit a72495b741
5 changed files with 95 additions and 5 deletions

View file

@ -5,7 +5,6 @@ require 'spec_helper'
class DummyAuthController < ApplicationController; end class DummyAuthController < ApplicationController; end
describe 'Auth concern', type: :controller do describe 'Auth concern', type: :controller do
controller DummyAuthController do controller DummyAuthController do
# Defining a dummy action for an anynomous controller which inherits from the described class. # Defining a dummy action for an anynomous controller which inherits from the described class.
def authenticate_blank def authenticate_blank

View file

@ -0,0 +1,30 @@
# 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 :index, params: { foodcoop: FoodsoftConfig[:default_scope] }
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

View file

@ -5,6 +5,7 @@ FactoryBot.define do
name { Faker::Company.name.truncate(30) } name { Faker::Company.name.truncate(30) }
phone { Faker::PhoneNumber.phone_number } phone { Faker::PhoneNumber.phone_number }
address { Faker::Address.street_address } address { Faker::Address.street_address }
email { Faker::Internet.email }
transient do transient do
article_count { 0 } article_count { 0 }

View file

@ -0,0 +1,29 @@
require_relative '../spec_helper'
feature Admin::BaseController do
let(:admin) { create :admin }
let(:users) { create_list :user, 2 }
let(:workgroups) { create_list :workgroup, 3 }
let(:groups) { create_list :group, 4 }
before { login admin }
describe 'base#index' do
before do
users
end
it 'is accessible with workgroups existing' do
workgroups
visit admin_root_path
expect(page).to have_content(I18n.t('admin.base.index.newest_users'))
expect(page).to have_content(users.first.name)
end
# TODO:
it 'raising error when groups existing' do
groups
expect{ visit admin_root_path }.to raise_error(ActionView::Template::Error)
end
end
end

View file

@ -2,12 +2,11 @@ require_relative '../spec_helper'
feature 'supplier' do feature 'supplier' do
let(:supplier) { create :supplier } let(:supplier) { create :supplier }
let(:user) { create :user, groups: [create(:workgroup, role_suppliers: true)] }
before { login user }
describe 'create new' do describe 'create new' do
let(:user) { create :user, groups: [create(:workgroup, role_suppliers: true)] }
before { login user }
it 'can be created' do it 'can be created' do
create :supplier_category create :supplier_category
visit suppliers_path visit suppliers_path
@ -28,4 +27,36 @@ feature 'supplier' do
expect(page).to have_content(supplier.name) expect(page).to have_content(supplier.name)
end end
end end
describe 'existing', js: true do
it 'can be shown' do
supplier
visit suppliers_path
click_link supplier.name
expect(page).to have_content(supplier.address)
expect(page).to have_content(supplier.phone)
expect(page).to have_content(supplier.email)
end
it 'can be updated' do
new_name = Faker::Company.name.truncate(30)
supplier
visit suppliers_path
click_link I18n.t('ui.edit')
fill_in I18n.t('activerecord.attributes.supplier.name'), with: new_name
click_button 'Update Supplier'
expect(supplier.reload.name).to eq new_name
end
it 'can be destroyed' do
supplier
visit suppliers_path
expect(page).to have_content(supplier.name)
accept_confirm do
click_link I18n.t('ui.delete')
end
expect(page).not_to have_content(supplier.name)
expect(supplier.reload.deleted?).to be true
end
end
end end