Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -49,7 +49,6 @@ describe Article do
|
|||
expect(article.in_open_order).to eq(order)
|
||||
end
|
||||
|
||||
|
||||
it 'has no shared article by default' do
|
||||
expect(article.shared_article).to be_nil
|
||||
end
|
||||
|
|
@ -72,8 +71,8 @@ describe Article do
|
|||
it 'can be synchronised' do
|
||||
# TODO move article sync from supplier to article
|
||||
article # need to reference for it to exist when syncing
|
||||
updated_article = supplier.sync_all[0].select{|s| s[0].id==article.id}.first[0]
|
||||
article.update_attributes updated_article.attributes.reject{|k,v| k=='id' or k=='type'}
|
||||
updated_article = supplier.sync_all[0].select { |s| s[0].id == article.id }.first[0]
|
||||
article.update_attributes updated_article.attributes.reject { |k, v| k == 'id' or k == 'type' }
|
||||
expect(article.name).to eq(shared_article.name)
|
||||
# now synchronising shouldn't change anything anymore
|
||||
expect(article.shared_article_changed?).to be_falsey
|
||||
|
|
@ -95,11 +94,11 @@ describe Article do
|
|||
article.shared_updated_on -= 1 # to make update do something
|
||||
article.save!
|
||||
# TODO get sync functionality in article
|
||||
updated_article = supplier.sync_all[0].select{|s| s[0].id==article.id}.first[0]
|
||||
article.update_attributes! updated_article.attributes.reject{|k,v| k=='id' or k=='type'}
|
||||
updated_article = supplier.sync_all[0].select { |s| s[0].id == article.id }.first[0]
|
||||
article.update_attributes! updated_article.attributes.reject { |k, v| k == 'id' or k == 'type' }
|
||||
expect(article.unit).to eq '200g'
|
||||
expect(article.unit_quantity).to eq 5
|
||||
expect(article.price).to be_within(0.005).of(shared_article.price/5)
|
||||
expect(article.price).to be_within(0.005).of(shared_article.price / 5)
|
||||
end
|
||||
|
||||
it 'does not synchronise when it has no order number' do
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ describe BankTransaction do
|
|||
expect(invoice5.paid_on).to eq bank_transaction4.date
|
||||
expect(invoice5.financial_link).to eq bank_transaction4.financial_link
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'ordergroup' do
|
||||
|
|
@ -102,7 +101,5 @@ describe BankTransaction do
|
|||
it 'ignores transaction with invalid short name' do
|
||||
expect(bank_transaction8.assign_to_ordergroup).to be false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,5 +60,4 @@ describe GroupOrderArticle do
|
|||
expect(res).to eq(quantity: 4, tolerance: 0, total: 4)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ describe GroupOrder do
|
|||
|
||||
# the following two tests are currently disabled - https://github.com/foodcoops/foodsoft/issues/158
|
||||
|
||||
#it 'needs an order' do
|
||||
# expect(FactoryBot.build(:group_order, ordergroup: user.ordergroup)).to be_invalid
|
||||
#end
|
||||
# it 'needs an order' do
|
||||
# expect(FactoryBot.build(:group_order, ordergroup: user.ordergroup)).to be_invalid
|
||||
# end
|
||||
|
||||
#it 'needs an ordergroup' do
|
||||
# expect(FactoryBot.build(:group_order, order: order)).to be_invalid
|
||||
#end
|
||||
# it 'needs an ordergroup' do
|
||||
# expect(FactoryBot.build(:group_order, order: order)).to be_invalid
|
||||
# end
|
||||
|
||||
describe do
|
||||
let(:go) { create :group_order, order: order, ordergroup: user.ordergroup }
|
||||
|
|
@ -21,5 +21,4 @@ describe GroupOrder do
|
|||
expect(go.price).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ describe OrderArticle do
|
|||
end
|
||||
|
||||
[:units_to_order, :units_billed, :units_received].each do |units|
|
||||
|
||||
it "is ordered when there are #{units.to_s.gsub '_', ' '}" do
|
||||
oa.update_attribute units, rand(1..99)
|
||||
expect(OrderArticle.ordered.count).to eq 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'knows how many items there are' do
|
||||
|
|
@ -48,7 +46,7 @@ describe OrderArticle do
|
|||
end
|
||||
|
||||
describe 'redistribution' do
|
||||
let(:admin) { create :user, groups:[create(:workgroup, role_finance: true)] }
|
||||
let(:admin) { create :user, groups: [create(:workgroup, role_finance: true)] }
|
||||
let(:article) { create :article, unit_quantity: 3 }
|
||||
let(:order) { create :order, article_ids: [article.id] }
|
||||
let(:go1) { create :group_order, order: order }
|
||||
|
|
@ -74,34 +72,34 @@ describe OrderArticle do
|
|||
end
|
||||
|
||||
it 'has expected units_to_order' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
expect(oa.units*oa.article.unit_quantity).to eq 6
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.units * oa.article.unit_quantity).to eq 6
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [4, 1, 1]
|
||||
end
|
||||
|
||||
it 'does nothing when nothing has changed' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 6, [:tolerance, nil]).to eq [1, 0]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result).map(&:to_i)).to eq [4, 1, 1]
|
||||
end
|
||||
|
||||
it 'works when there is nothing to distribute' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 0, [:tolerance, nil]).to eq [0, 0]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [0, 0, 0]
|
||||
end
|
||||
|
||||
it 'works when quantity needs to be reduced' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 4, [:tolerance, nil]).to eq [0, 0]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [3, 1, 0]
|
||||
end
|
||||
|
||||
it 'works when quantity is increased within quantity' do
|
||||
set_quantities [3,0], [2,0], [2,0]
|
||||
set_quantities [3, 0], [2, 0], [2, 0]
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [3, 2, 1]
|
||||
expect(oa.redistribute 7, [:tolerance, nil]).to eq [0, 0]
|
||||
goa_reload
|
||||
|
|
@ -109,26 +107,25 @@ describe OrderArticle do
|
|||
end
|
||||
|
||||
it 'works when there is just one for the first' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 1, [:tolerance, nil]).to eq [0, 0]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [1, 0, 0]
|
||||
end
|
||||
|
||||
it 'works when there is tolerance and left-over' do
|
||||
set_quantities [3,2], [1,1], [1,0]
|
||||
set_quantities [3, 2], [1, 1], [1, 0]
|
||||
expect(oa.redistribute 10, [:tolerance, nil]).to eq [3, 2]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [5, 2, 1]
|
||||
end
|
||||
|
||||
it 'works when redistributing without tolerance' do
|
||||
set_quantities [3,2], [1,3], [1,0]
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 8, [nil]).to eq [3]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [3, 1, 1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'boxfill' do
|
||||
|
|
@ -173,38 +170,37 @@ describe OrderArticle do
|
|||
context 'before the date' do
|
||||
let(:boxfill_from) { 1.hour.from_now }
|
||||
context 'decreasing the missing units' do
|
||||
include_examples "boxfill", true, [6,0]=>[5,0], [6,0,0]=>[5,0,1]
|
||||
include_examples "boxfill", true, [6, 0] => [5, 0], [6, 0, 0] => [5, 0, 1]
|
||||
end
|
||||
context 'decreasing the tolerance' do
|
||||
include_examples "boxfill", true, [1,2]=>[1,1], [1,2,3]=>[1,1,4]
|
||||
include_examples "boxfill", true, [1, 2] => [1, 1], [1, 2, 3] => [1, 1, 4]
|
||||
end
|
||||
end
|
||||
|
||||
context 'after the date' do
|
||||
let(:boxfill_from) { 1.second.ago }
|
||||
context 'changing nothing in particular' do
|
||||
include_examples "boxfill", true, [4,1]=>[4,1], [4,1,1]=>[4,1,1]
|
||||
include_examples "boxfill", true, [4, 1] => [4, 1], [4, 1, 1] => [4, 1, 1]
|
||||
end
|
||||
context 'increasing missing units' do
|
||||
include_examples "boxfill", false, [3,0]=>[2,0], [3,0,3]=>[3,0,3]
|
||||
include_examples "boxfill", false, [3, 0] => [2, 0], [3, 0, 3] => [3, 0, 3]
|
||||
end
|
||||
context 'increasing tolerance' do
|
||||
include_examples "boxfill", true, [2,1]=>[2,2], [2,1,3]=>[2,2,2]
|
||||
include_examples "boxfill", true, [2, 1] => [2, 2], [2, 1, 3] => [2, 2, 2]
|
||||
end
|
||||
context 'decreasing quantity to fix missing units' do
|
||||
include_examples "boxfill", true, [7,0]=>[6,0], [7,0,5]=>[6,0,0]
|
||||
include_examples "boxfill", true, [7, 0] => [6, 0], [7, 0, 5] => [6, 0, 0]
|
||||
end
|
||||
context 'decreasing quantity keeping missing units equal' do
|
||||
include_examples "boxfill", false, [7,0]=>[1,0], [7,0,5]=>[7,0,5]
|
||||
include_examples "boxfill", false, [7, 0] => [1, 0], [7, 0, 5] => [7, 0, 5]
|
||||
end
|
||||
context 'moving tolerance to quantity' do
|
||||
include_examples "boxfill", true, [4,2]=>[6,0], [4,2,0]=>[6,0,0]
|
||||
include_examples "boxfill", true, [4, 2] => [6, 0], [4, 2, 0] => [6, 0, 0]
|
||||
end
|
||||
# @todo enable test when tolerance doesn't count in missing_units
|
||||
#context 'decreasing tolerance' do
|
||||
# include_examples "boxfill", false, [0,2]=>[0,0], [0,2,0]=>[0,2,0]
|
||||
#end
|
||||
# context 'decreasing tolerance' do
|
||||
# include_examples "boxfill", false, [0,2]=>[0,0], [0,2,0]=>[0,2,0]
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ describe Order do
|
|||
it 'is not closed by default' do expect(order).to_not be_closed end
|
||||
|
||||
it 'has valid order articles' do
|
||||
order.order_articles.each {|oa| expect(oa).to be_valid }
|
||||
order.order_articles.each { |oa| expect(oa).to be_valid }
|
||||
end
|
||||
|
||||
it 'can be finished' do
|
||||
|
|
@ -117,13 +117,12 @@ describe Order do
|
|||
expect(order).to_not be_open
|
||||
expect(order).to be_closed
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'with a default end date' do
|
||||
let(:order) { create :order }
|
||||
before do
|
||||
FoodsoftConfig[:order_schedule] = {ends: {recurr: 'FREQ=WEEKLY;BYDAY=MO', time: '9:00'}}
|
||||
FoodsoftConfig[:order_schedule] = { ends: { recurr: 'FREQ=WEEKLY;BYDAY=MO', time: '9:00' } }
|
||||
order.init_dates
|
||||
end
|
||||
|
||||
|
|
@ -134,7 +133,6 @@ describe Order do
|
|||
it 'to have a correct time' do
|
||||
expect(order.ends.strftime('%H:%M')).to eq '09:00'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'mapped to GroupOrders' do
|
||||
|
|
@ -153,5 +151,4 @@ describe Order do
|
|||
expect(orders[1][:group_order]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe Ordergroup do
|
|||
let(:ftt1) { create :financial_transaction_type, financial_transaction_class: ftc1 }
|
||||
let(:ftt2) { create :financial_transaction_type, financial_transaction_class: ftc2 }
|
||||
let(:ftt3) { create :financial_transaction_type, financial_transaction_class: ftc2 }
|
||||
let(:user) { create :user, groups:[create(:ordergroup)] }
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
|
||||
context 'with financial transactions' do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe Supplier do
|
|||
|
||||
it 'has valid articles' do
|
||||
supplier = create :supplier, article_count: true
|
||||
supplier.articles.each {|a| expect(a).to be_valid }
|
||||
supplier.articles.each { |a| expect(a).to be_valid }
|
||||
end
|
||||
|
||||
context 'connected to a shared supplier' do
|
||||
|
|
@ -91,5 +91,4 @@ describe Supplier do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe User do
|
||||
|
||||
it 'is correctly created' do
|
||||
user = create :user,
|
||||
nick: 'johnnydoe', first_name: 'Johnny', last_name: 'DoeBar',
|
||||
email: 'johnnydoe@foodcoop.test', phone: '+1234567890'
|
||||
nick: 'johnnydoe', first_name: 'Johnny', last_name: 'DoeBar',
|
||||
email: 'johnnydoe@foodcoop.test', phone: '+1234567890'
|
||||
expect(user.nick).to eq('johnnydoe')
|
||||
expect(user.first_name).to eq('Johnny')
|
||||
expect(user.last_name).to eq('DoeBar')
|
||||
|
|
@ -71,5 +70,4 @@ describe User do
|
|||
let(:user) { create :admin }
|
||||
it 'default admin role' do expect(user.role_admin?).to be_truthy end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue