Add additional model and integration tests
This commit adds new tests for a better coverage. integration/ * home * supplier models/ * article * delivery * group_order_article * supplier also adds a new factory for delivery Co-authored-by: viehlieb <pf@pragma-shift.net> Co-authored-by: Tobias Kneuker <tk@pragma-shift.net>
This commit is contained in:
parent
9a46640d3b
commit
c6560e0cea
8 changed files with 167 additions and 7 deletions
23
spec/integration/home_spec.rb
Normal file
23
spec/integration/home_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'my profile page' do
|
||||
let(:user) { create :user }
|
||||
|
||||
before { login user }
|
||||
|
||||
describe 'my profile' do
|
||||
before { visit my_profile_path }
|
||||
|
||||
it 'is accessible' do
|
||||
expect(page).to have_field 'user_first_name'
|
||||
expect(find_field('user_first_name').value).to eq user.first_name
|
||||
end
|
||||
|
||||
it 'updates first name' do
|
||||
fill_in 'user_first_name', with: 'foo'
|
||||
click_button I18n.t('ui.save')
|
||||
expect(User.find(user.id).first_name).to eq 'foo'
|
||||
expect(page).to have_selector '.alert-success'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,16 +2,14 @@ require_relative '../spec_helper'
|
|||
|
||||
feature 'supplier' do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:user) { create :user, :role_suppliers }
|
||||
|
||||
before { login user }
|
||||
|
||||
describe 'create new' do
|
||||
let(:user) { create :user, groups: [create(:workgroup, role_suppliers: true)] }
|
||||
|
||||
before { login user }
|
||||
|
||||
it 'can be created' do
|
||||
create :supplier_category
|
||||
visit suppliers_path
|
||||
click_on I18n.t('suppliers.index.action_new')
|
||||
visit new_supplier_path
|
||||
supplier = build :supplier
|
||||
within('#new_supplier') do
|
||||
fill_in 'supplier_name', :with => supplier.name
|
||||
|
|
@ -28,4 +26,35 @@ feature 'supplier' do
|
|||
expect(page).to have_content(supplier.name)
|
||||
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_supplier = build :supplier
|
||||
supplier
|
||||
visit edit_supplier_path(id: supplier.id)
|
||||
fill_in 'supplier_name', with: new_supplier.name
|
||||
find('input[type="submit"]').click
|
||||
expect(supplier.reload.name).to eq new_supplier.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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue