chore: rubocop

chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
This commit is contained in:
Philipp Rothmann 2023-05-12 13:01:12 +02:00 committed by Philipp Rothmann
parent f6fb804bbe
commit fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions

View file

@ -1,9 +1,9 @@
require_relative '../spec_helper'
feature ArticlesController do
let(:user) { create :user, groups: [create(:workgroup, role_article_meta: true)] }
let(:supplier) { create :supplier }
let!(:article_category) { create :article_category }
let(:user) { create(:user, groups: [create(:workgroup, role_article_meta: true)]) }
let(:supplier) { create(:supplier) }
let!(:article_category) { create(:article_category) }
before { login user }
@ -18,15 +18,15 @@ feature ArticlesController do
it 'can create a new article' do
click_on I18n.t('articles.index.new')
expect(page).to have_selector('form#new_article')
article = build :article, supplier: supplier, article_category: article_category
article = build(:article, supplier: supplier, article_category: article_category)
within('#new_article') do
fill_in 'article_name', :with => article.name
fill_in 'article_unit', :with => article.unit
select article.article_category.name, :from => 'article_article_category_id'
fill_in 'article_price', :with => article.price
fill_in 'article_unit_quantity', :with => article.unit_quantity
fill_in 'article_tax', :with => article.tax
fill_in 'article_deposit', :with => article.deposit
fill_in 'article_name', with: article.name
fill_in 'article_unit', with: article.unit
select article.article_category.name, from: 'article_article_category_id'
fill_in 'article_price', with: article.price
fill_in 'article_unit_quantity', with: article.unit_quantity
fill_in 'article_tax', with: article.tax
fill_in 'article_deposit', with: article.deposit
# "Element cannot be scrolled into view" error, js as workaround
# find('input[type="submit"]').click
page.execute_script('$("form#new_article").submit();')
@ -50,22 +50,22 @@ feature ArticlesController do
it do
find('input[type="submit"]').click
expect(find("tr:nth-child(1) #new_articles__note").value).to eq "bio ◎"
expect(find("tr:nth-child(2) #new_articles__name").value).to eq "Pijnboompitten"
expect(find('tr:nth-child(1) #new_articles__note').value).to eq 'bio ◎'
expect(find('tr:nth-child(2) #new_articles__name').value).to eq 'Pijnboompitten'
4.times do |i|
all("tr:nth-child(#{i + 1}) select > option")[1].select_option
end
find('input[type="submit"]').click
expect(page).to have_content("Pijnboompitten")
expect(page).to have_content('Pijnboompitten')
expect(supplier.articles.count).to eq 4
end
end
end
describe "can update existing article" do
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g' }
describe 'can update existing article' do
let!(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g') }
it do
find('input[type="submit"]').click
@ -77,35 +77,35 @@ feature ArticlesController do
end
end
describe "handles missing data" do
describe 'handles missing data' do
it do
find('input[type="submit"]').click # to overview
find('input[type="submit"]').click # missing category, re-show form
expect(find('tr.alert')).to be_present
expect(supplier.articles.count).to eq 0
all("tr select > option")[1].select_option
all('tr select > option')[1].select_option
find('input[type="submit"]').click # now it should succeed
expect(supplier.articles.count).to eq 1
end
end
describe "can remove an existing article" do
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 99999 }
describe 'can remove an existing article' do
let!(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 99_999) }
it do
check('articles_outlist_absent')
find('input[type="submit"]').click
expect(find("#outlisted_articles_#{article.id}", visible: :all)).to be_present
all("tr select > option")[1].select_option
all('tr select > option')[1].select_option
find('input[type="submit"]').click
expect(article.reload.deleted?).to be true
end
end
describe "can convert units when updating" do
let!(:article) { create :article, supplier: supplier, order_number: 1, unit: '250 g' }
describe 'can convert units when updating' do
let!(:article) { create(:article, supplier: supplier, order_number: 1, unit: '250 g') }
it do
check('articles_convert_units')