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:
parent
f6fb804bbe
commit
fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions
|
|
@ -1,17 +1,19 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe Supplier do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:supplier) { create(:supplier) }
|
||||
|
||||
context 'syncs from file' do
|
||||
it 'imports and updates articles' do
|
||||
article1 = create(:article, supplier: supplier, order_number: 177813, unit: '250 g', price: 0.1)
|
||||
article2 = create(:article, supplier: supplier, order_number: 12345)
|
||||
article1 = create(:article, supplier: supplier, order_number: 177_813, unit: '250 g', price: 0.1)
|
||||
article2 = create(:article, supplier: supplier, order_number: 12_345)
|
||||
supplier.articles = [article1, article2]
|
||||
options = { filename: 'foodsoft_file_01.csv' }
|
||||
options[:outlist_absent] = true
|
||||
options[:convert_units] = true
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), options)
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(
|
||||
Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), options
|
||||
)
|
||||
expect(new_articles.length).to be > 0
|
||||
expect(updated_article_pairs.first[1][:name]).to eq 'Tomaten'
|
||||
expect(outlisted_articles.first).to eq article2
|
||||
|
|
@ -19,14 +21,16 @@ describe Supplier do
|
|||
end
|
||||
|
||||
it 'return correct tolerance' do
|
||||
supplier = create :supplier, articles: create_list(:article, 1, unit_quantity: 1)
|
||||
supplier = create(:supplier)
|
||||
supplier.articles = create_list(:article, 1, unit_quantity: 1)
|
||||
expect(supplier.has_tolerance?).to be false
|
||||
supplier2 = create :supplier, articles: create_list(:article, 1, unit_quantity: 2)
|
||||
supplier2 = create(:supplier)
|
||||
supplier2.articles = create_list(:article, 1, unit_quantity: 2)
|
||||
expect(supplier2.has_tolerance?).to be true
|
||||
end
|
||||
|
||||
it 'deletes the supplier and its articles' do
|
||||
supplier = create :supplier, article_count: 3
|
||||
supplier = create(:supplier, article_count: 3)
|
||||
supplier.articles.each { |a| allow(a).to receive(:mark_as_deleted) }
|
||||
supplier.mark_as_deleted
|
||||
supplier.articles.each { |a| expect(a).to have_received(:mark_as_deleted) }
|
||||
|
|
@ -34,29 +38,29 @@ describe Supplier do
|
|||
end
|
||||
|
||||
it 'has a unique name' do
|
||||
supplier2 = build :supplier, name: supplier.name
|
||||
supplier2 = build(:supplier, name: supplier.name)
|
||||
expect(supplier2).to be_invalid
|
||||
end
|
||||
|
||||
it 'has valid articles' do
|
||||
supplier = create :supplier, article_count: true
|
||||
supplier = create(:supplier, article_count: true)
|
||||
supplier.articles.each { |a| expect(a).to be_valid }
|
||||
end
|
||||
|
||||
context 'connected to a shared supplier' do
|
||||
let(:shared_sync_method) { nil }
|
||||
let(:shared_supplier) { create :shared_supplier }
|
||||
let(:supplier) { create :supplier, shared_supplier: shared_supplier, shared_sync_method: shared_sync_method }
|
||||
let(:shared_supplier) { create(:shared_supplier) }
|
||||
let(:supplier) { create(:supplier, shared_supplier: shared_supplier, shared_sync_method: shared_sync_method) }
|
||||
|
||||
let!(:synced_shared_article) { create :shared_article, shared_supplier: shared_supplier }
|
||||
let!(:updated_shared_article) { create :shared_article, shared_supplier: shared_supplier }
|
||||
let!(:new_shared_article) { create :shared_article, shared_supplier: shared_supplier }
|
||||
let!(:synced_shared_article) { create(:shared_article, shared_supplier: shared_supplier) }
|
||||
let!(:updated_shared_article) { create(:shared_article, shared_supplier: shared_supplier) }
|
||||
let!(:new_shared_article) { create(:shared_article, shared_supplier: shared_supplier) }
|
||||
|
||||
let!(:removed_article) { create :article, supplier: supplier, order_number: '10001-ABC' }
|
||||
let!(:removed_article) { create(:article, supplier: supplier, order_number: '10001-ABC') }
|
||||
let!(:updated_article) do
|
||||
updated_shared_article.build_new_article(supplier).tap do |article|
|
||||
article.article_category = create :article_category
|
||||
article.origin = "FubarX1"
|
||||
article.origin = 'FubarX1'
|
||||
article.shared_updated_on = 1.day.ago
|
||||
article.save!
|
||||
end
|
||||
|
|
@ -75,7 +79,7 @@ describe Supplier do
|
|||
it 'returns the expected articles' do
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_all
|
||||
|
||||
expect(updated_article_pairs).to_not be_empty
|
||||
expect(updated_article_pairs).not_to be_empty
|
||||
expect(updated_article_pairs[0][0].id).to eq updated_article.id
|
||||
expect(updated_article_pairs[0][1].keys).to include :origin
|
||||
|
||||
|
|
@ -91,13 +95,13 @@ describe Supplier do
|
|||
it 'returns the expected articles' do
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_all
|
||||
|
||||
expect(updated_article_pairs).to_not be_empty
|
||||
expect(updated_article_pairs).not_to be_empty
|
||||
expect(updated_article_pairs[0][0].id).to eq updated_article.id
|
||||
expect(updated_article_pairs[0][1].keys).to include :origin
|
||||
|
||||
expect(outlisted_articles).to eq [removed_article]
|
||||
|
||||
expect(new_articles).to_not be_empty
|
||||
expect(new_articles).not_to be_empty
|
||||
expect(new_articles[0].order_number).to eq new_shared_article.number
|
||||
expect(new_articles[0].availability?).to be true
|
||||
end
|
||||
|
|
@ -109,13 +113,13 @@ describe Supplier do
|
|||
it 'returns the expected articles' do
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_all
|
||||
|
||||
expect(updated_article_pairs).to_not be_empty
|
||||
expect(updated_article_pairs).not_to be_empty
|
||||
expect(updated_article_pairs[0][0].id).to eq updated_article.id
|
||||
expect(updated_article_pairs[0][1].keys).to include :origin
|
||||
|
||||
expect(outlisted_articles).to eq [removed_article]
|
||||
|
||||
expect(new_articles).to_not be_empty
|
||||
expect(new_articles).not_to be_empty
|
||||
expect(new_articles[0].order_number).to eq new_shared_article.number
|
||||
expect(new_articles[0].availability?).to be false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue