2013-09-18 12:44:41 +02:00
|
|
|
require_relative '../spec_helper'
|
2013-07-24 21:25:57 +02:00
|
|
|
|
2015-04-24 15:19:57 +02:00
|
|
|
feature 'supplier' do
|
2023-05-12 13:01:12 +02:00
|
|
|
let(:supplier) { create(:supplier) }
|
|
|
|
let(:user) { create(:user, :role_suppliers) }
|
2013-07-24 21:25:57 +02:00
|
|
|
|
2022-10-31 16:36:06 +01:00
|
|
|
before { login user }
|
2013-07-24 21:25:57 +02:00
|
|
|
|
2022-10-31 16:36:06 +01:00
|
|
|
describe 'create new' do
|
2013-07-24 21:25:57 +02:00
|
|
|
it 'can be created' do
|
2023-05-12 13:01:12 +02:00
|
|
|
create(:supplier_category)
|
2022-10-31 16:36:06 +01:00
|
|
|
visit new_supplier_path
|
2023-05-12 13:01:12 +02:00
|
|
|
supplier = build(:supplier)
|
2013-07-24 21:25:57 +02:00
|
|
|
within('#new_supplier') do
|
2023-05-12 13:01:12 +02:00
|
|
|
fill_in 'supplier_name', with: supplier.name
|
|
|
|
fill_in 'supplier_address', with: supplier.address
|
|
|
|
fill_in 'supplier_phone', with: supplier.phone
|
2013-07-24 21:25:57 +02:00
|
|
|
find('input[type="submit"]').click
|
|
|
|
end
|
|
|
|
expect(page).to have_content(supplier.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is included in supplier list' do
|
|
|
|
supplier
|
|
|
|
visit suppliers_path
|
|
|
|
expect(page).to have_content(supplier.name)
|
|
|
|
end
|
|
|
|
end
|
2022-10-31 16:36:06 +01:00
|
|
|
|
|
|
|
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
|
2023-05-12 13:01:12 +02:00
|
|
|
new_supplier = build(:supplier)
|
2022-10-31 16:36:06 +01:00
|
|
|
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
|
2013-07-24 21:25:57 +02:00
|
|
|
end
|