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
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe HomeController, type: :controller do
|
||||
let(:user) { create :user }
|
||||
describe HomeController do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'GET index' do
|
||||
describe 'NOT logged in' do
|
||||
|
|
@ -45,7 +45,7 @@ describe HomeController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'with ordergroup user' do
|
||||
let(:og_user) { create :user, :ordergroup }
|
||||
let(:og_user) { create(:user, :ordergroup) }
|
||||
|
||||
before { login og_user }
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ describe HomeController, type: :controller do
|
|||
describe 'GET update_profile' do
|
||||
describe 'with simple user' do
|
||||
let(:unchanged_attributes) { user.attributes.slice('first_name', 'last_name', 'email') }
|
||||
let(:changed_attributes) { attributes_for :user }
|
||||
let(:changed_attributes) { attributes_for(:user) }
|
||||
let(:invalid_attributes) { { email: 'e.mail.com' } }
|
||||
|
||||
before { login user }
|
||||
|
|
@ -80,12 +80,13 @@ describe HomeController, type: :controller do
|
|||
expect(response).to have_http_status(:redirect)
|
||||
expect(response).to redirect_to(my_profile_path)
|
||||
expect(flash[:notice]).to match(/#{I18n.t('home.changes_saved')}/)
|
||||
expect(user.reload.attributes.slice(:first_name, :last_name, :email)).to eq(changed_attributes.slice('first_name', 'last_name', 'email'))
|
||||
expect(user.reload.attributes.slice(:first_name, :last_name,
|
||||
:email)).to eq(changed_attributes.slice('first_name', 'last_name', 'email'))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with ordergroup user' do
|
||||
let(:og_user) { create :user, :ordergroup }
|
||||
let(:og_user) { create(:user, :ordergroup) }
|
||||
let(:unchanged_attributes) { og_user.attributes.slice('first_name', 'last_name', 'email') }
|
||||
let(:changed_attributes) { unchanged_attributes.merge({ ordergroup: { contact_address: 'new Adress 7' } }) }
|
||||
|
||||
|
|
@ -112,7 +113,7 @@ describe HomeController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'with ordergroup user' do
|
||||
let(:og_user) { create :user, :ordergroup }
|
||||
let(:og_user) { create(:user, :ordergroup) }
|
||||
|
||||
before { login og_user }
|
||||
|
||||
|
|
@ -132,13 +133,13 @@ describe HomeController, type: :controller do
|
|||
get_with_defaults :cancel_membership
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect do
|
||||
get_with_defaults :cancel_membership, params: { membership_id: 424242 }
|
||||
get_with_defaults :cancel_membership, params: { membership_id: 424_242 }
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with ordergroup user' do
|
||||
let(:fin_user) { create :user, :role_finance }
|
||||
let(:fin_user) { create(:user, :role_finance) }
|
||||
|
||||
before { login fin_user }
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'factory_bot'
|
|||
|
||||
FactoryBot.define do
|
||||
factory :delivery do
|
||||
supplier { create :supplier }
|
||||
supplier { create(:supplier) }
|
||||
date { Time.now }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ FactoryBot.define do
|
|||
# requires order
|
||||
factory :group_order do
|
||||
ordergroup { create(:user, groups: [FactoryBot.create(:ordergroup)]).ordergroup }
|
||||
updated_by { create :user }
|
||||
updated_by { create(:user) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ require 'factory_bot'
|
|||
FactoryBot.define do
|
||||
factory :invoice do
|
||||
supplier
|
||||
number { rand(1..99999) }
|
||||
number { rand(1..99_999) }
|
||||
amount { rand(0.1..26.0).round(2) }
|
||||
created_by { create :user }
|
||||
created_by { create(:user) }
|
||||
|
||||
after :create do |invoice|
|
||||
invoice.supplier.reload
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ require 'factory_bot'
|
|||
FactoryBot.define do
|
||||
factory :order do
|
||||
starts { Time.now }
|
||||
supplier { create :supplier, article_count: (article_count.nil? ? true : article_count) }
|
||||
supplier { create(:supplier, article_count: (article_count.nil? ? true : article_count)) }
|
||||
article_ids { supplier.articles.map(&:id) unless supplier.nil? }
|
||||
created_by { create :user }
|
||||
updated_by { create :user }
|
||||
created_by { create(:user) }
|
||||
updated_by { create(:user) }
|
||||
|
||||
transient do
|
||||
article_count { true }
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ FactoryBot.define do
|
|||
article_count { 0 }
|
||||
end
|
||||
|
||||
before :create do |supplier, evaluator|
|
||||
next if supplier.class == SharedSupplier
|
||||
before :create do |supplier, _evaluator|
|
||||
next if supplier.instance_of?(SharedSupplier)
|
||||
next if supplier.supplier_category_id?
|
||||
|
||||
supplier.supplier_category = create :supplier_category
|
||||
|
|
@ -20,7 +20,7 @@ FactoryBot.define do
|
|||
after :create do |supplier, evaluator|
|
||||
article_count = evaluator.article_count
|
||||
article_count = rand(1..99) if article_count == true
|
||||
create_list :article, article_count, supplier: supplier
|
||||
create_list(:article, article_count, supplier: supplier)
|
||||
end
|
||||
|
||||
factory :shared_supplier, class: 'SharedSupplier'
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ FactoryBot.define do
|
|||
factory :admin do
|
||||
sequence(:nick) { |n| "admin#{n}" }
|
||||
first_name { 'Administrator' }
|
||||
after :create do |user, evaluator|
|
||||
create :workgroup, role_admin: true, user_ids: [user.id]
|
||||
after :create do |user, _evaluator|
|
||||
create(:workgroup, role_admin: true, user_ids: [user.id])
|
||||
end
|
||||
end
|
||||
|
||||
trait :ordergroup do
|
||||
after :create do |user, evaluator|
|
||||
create :ordergroup, user_ids: [user.id]
|
||||
after :create do |user, _evaluator|
|
||||
create(:ordergroup, user_ids: [user.id])
|
||||
end
|
||||
end
|
||||
|
||||
[:ordergroup, :finance, :invoices, :article_meta, :suppliers, :pickups, :orders].each do |role|
|
||||
%i[ordergroup finance invoices article_meta suppliers pickups orders].each do |role|
|
||||
trait "role_#{role}".to_sym do
|
||||
after :create do |user, evaluator|
|
||||
create :workgroup, "role_#{role}" => true, user_ids: [user.id]
|
||||
after :create do |user, _evaluator|
|
||||
create(:workgroup, "role_#{role}" => true, user_ids: [user.id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -37,7 +37,7 @@ FactoryBot.define do
|
|||
type { 'Workgroup' }
|
||||
end
|
||||
|
||||
factory :ordergroup, class: "Ordergroup" do
|
||||
factory :ordergroup, class: 'Ordergroup' do
|
||||
type { 'Ordergroup' }
|
||||
sequence(:name) { |n| "Order group ##{n}" }
|
||||
# workaround to avoid needing to save the ordergroup
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'settling an order', js: true do
|
||||
let(:ftt) { create :financial_transaction_type }
|
||||
let(:admin) { create :user, groups: [create(:workgroup, role_finance: true)] }
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:supplier) { create :supplier }
|
||||
let(:article) { create :article, supplier: supplier, unit_quantity: 1 }
|
||||
let(:order) { create :order, supplier: supplier, article_ids: [article.id] } # need to ref article
|
||||
let(:go1) { create :group_order, order: order }
|
||||
let(:go2) { create :group_order, order: order }
|
||||
let(:ftt) { create(:financial_transaction_type) }
|
||||
let(:admin) { create(:user, groups: [create(:workgroup, role_finance: true)]) }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let(:article) { create(:article, supplier: supplier, unit_quantity: 1) }
|
||||
let(:order) { create(:order, supplier: supplier, article_ids: [article.id]) } # need to ref article
|
||||
let(:go1) { create(:group_order, order: order) }
|
||||
let(:go2) { create(:group_order, order: order) }
|
||||
let(:oa) { order.order_articles.find_by_article_id(article.id) }
|
||||
let(:goa1) { create :group_order_article, group_order: go1, order_article: oa }
|
||||
let(:goa2) { create :group_order_article, group_order: go2, order_article: oa }
|
||||
let(:goa1) { create(:group_order_article, group_order: go1, order_article: oa) }
|
||||
let(:goa2) { create(:group_order_article, group_order: go2, order_article: oa) }
|
||||
|
||||
before do
|
||||
goa1.update_quantities(3, 0)
|
||||
|
|
@ -22,6 +22,9 @@ feature 'settling an order', js: true do
|
|||
goa2.reload
|
||||
end
|
||||
|
||||
before { visit new_finance_order_path(order_id: order.id) }
|
||||
before { login admin }
|
||||
|
||||
it 'has correct order result' do
|
||||
expect(oa.quantity).to eq(4)
|
||||
expect(oa.tolerance).to eq(0)
|
||||
|
|
@ -29,10 +32,6 @@ feature 'settling an order', js: true do
|
|||
expect(goa2.result).to eq(1)
|
||||
end
|
||||
|
||||
before { login admin }
|
||||
|
||||
before { visit new_finance_order_path(order_id: order.id) }
|
||||
|
||||
it 'has product ordered visible' do
|
||||
expect(page).to have_content(article.name)
|
||||
expect(page).to have_selector("#order_article_#{oa.id}")
|
||||
|
|
@ -59,7 +58,7 @@ feature 'settling an order', js: true do
|
|||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(page).not_to have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
oa.reload
|
||||
expect(oa.quantity).to eq(4)
|
||||
|
|
@ -77,7 +76,7 @@ feature 'settling an order', js: true do
|
|||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(page).not_to have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be false
|
||||
end
|
||||
|
||||
|
|
@ -87,7 +86,7 @@ feature 'settling an order', js: true do
|
|||
within("#group_order_article_#{goa1.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(page).not_to have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be true
|
||||
goa1.reload
|
||||
|
|
@ -103,7 +102,7 @@ feature 'settling an order', js: true do
|
|||
within("#group_order_article_#{goa1.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(page).not_to have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be false
|
||||
end
|
||||
|
|
@ -134,15 +133,15 @@ feature 'settling an order', js: true do
|
|||
end
|
||||
expect(page).to have_selector('form#new_group_order_article')
|
||||
within('#new_group_order_article') do
|
||||
select user.ordergroup.name, :from => 'group_order_article_ordergroup_id'
|
||||
select user.ordergroup.name, from: 'group_order_article_ordergroup_id'
|
||||
find_by_id('group_order_article_result').set(8)
|
||||
sleep 0.25
|
||||
find('input[type="submit"]').click
|
||||
end
|
||||
expect(page).to_not have_selector('form#new_group_order_article')
|
||||
expect(page).not_to have_selector('form#new_group_order_article')
|
||||
expect(page).to have_content(user.ordergroup.name)
|
||||
goa = GroupOrderArticle.last
|
||||
expect(goa).to_not be_nil
|
||||
expect(goa).not_to be_nil
|
||||
expect(goa.result).to eq 8
|
||||
expect(page).to have_selector("#group_order_article_#{goa.id}")
|
||||
expect(find("#r_#{goa.id}").value.to_f).to eq 8
|
||||
|
|
@ -169,8 +168,8 @@ feature 'settling an order', js: true do
|
|||
end
|
||||
|
||||
it 'can add an article' do
|
||||
new_article = create :article, supplier: supplier
|
||||
expect(page).to_not have_content(new_article.name)
|
||||
new_article = create(:article, supplier: supplier)
|
||||
expect(page).not_to have_content(new_article.name)
|
||||
click_link I18n.t('finance.balancing.edit_results_by_articles.add_article')
|
||||
expect(page).to have_selector('form#new_order_article')
|
||||
within('#new_order_article') do
|
||||
|
|
@ -178,8 +177,8 @@ feature 'settling an order', js: true do
|
|||
sleep 0.25
|
||||
find('input[type="submit"]').click
|
||||
end
|
||||
expect(page).to_not have_selector('form#new_order_article')
|
||||
expect(page).not_to have_selector('form#new_order_article')
|
||||
expect(page).to have_content(new_article.name)
|
||||
expect(order.order_articles.where(article_id: new_article.id)).to_not be_nil
|
||||
expect(order.order_articles.where(article_id: new_article.id)).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ require_relative '../spec_helper'
|
|||
feature 'admin/configs' do
|
||||
let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') }
|
||||
let(:email) { Faker::Internet.email }
|
||||
let(:admin) { create :admin }
|
||||
let(:admin) { create(:admin) }
|
||||
|
||||
before { login admin }
|
||||
|
||||
|
|
@ -51,13 +51,13 @@ feature 'admin/configs' do
|
|||
end
|
||||
|
||||
def compact_hash_deep!(h)
|
||||
h.each do |k, v|
|
||||
h.each do |_k, v|
|
||||
if v.is_a? Hash
|
||||
compact_hash_deep!(v)
|
||||
v.reject! { |k, v| v.blank? }
|
||||
v.compact_blank!
|
||||
end
|
||||
end
|
||||
h.reject! { |k, v| v.blank? }
|
||||
h.compact_blank!
|
||||
h
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'my profile page' do
|
||||
let(:user) { create :user }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before { login user }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature LoginController do
|
||||
let(:user) { create :user }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'forgot password' do
|
||||
before { visit forgot_password_path }
|
||||
|
|
@ -36,7 +36,7 @@ feature LoginController do
|
|||
|
||||
it 'is not accessible' do
|
||||
expect(page).to have_selector '.alert-error'
|
||||
expect(page).to_not have_selector 'input[type=password]'
|
||||
expect(page).not_to have_selector 'input[type=password]'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature Order, js: true do
|
||||
let(:admin) { create :user, groups: [create(:workgroup, role_orders: true)] }
|
||||
let(:article) { create :article, unit_quantity: 1 }
|
||||
let(:order) { create :order, supplier: article.supplier, article_ids: [article.id] } # need to ref article
|
||||
let(:go1) { create :group_order, order: order }
|
||||
let(:admin) { create(:user, groups: [create(:workgroup, role_orders: true)]) }
|
||||
let(:article) { create(:article, unit_quantity: 1) }
|
||||
let(:order) { create(:order, supplier: article.supplier, article_ids: [article.id]) } # need to ref article
|
||||
let(:go1) { create(:group_order, order: order) }
|
||||
let(:oa) { order.order_articles.find_by_article_id(article.id) }
|
||||
let(:goa1) { create :group_order_article, group_order: go1, order_article: oa }
|
||||
let(:goa1) { create(:group_order_article, group_order: go1, order_article: oa) }
|
||||
|
||||
before { login admin }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'product distribution', js: true do
|
||||
let(:ftt) { create :financial_transaction_type }
|
||||
let(:admin) { create :admin }
|
||||
let(:user_a) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:user_b) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:supplier) { create :supplier }
|
||||
let(:article) { create :article, supplier: supplier, unit_quantity: 5 }
|
||||
let(:ftt) { create(:financial_transaction_type) }
|
||||
let(:admin) { create(:admin) }
|
||||
let(:user_a) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:user_b) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let(:article) { create(:article, supplier: supplier, unit_quantity: 5) }
|
||||
let(:order) { create(:order, supplier: supplier, article_ids: [article.id]) }
|
||||
let(:oa) { order.order_articles.first }
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ feature 'product distribution', js: true do
|
|||
expect(oa.quantity).to eq(6)
|
||||
expect(oa.tolerance).to eq(1)
|
||||
# Gruppe a bekommt 3 einheiten.
|
||||
goa_a = oa.group_order_articles.joins(:group_order).where(:group_orders => { :ordergroup_id => user_a.ordergroup.id }).first
|
||||
goa_a = oa.group_order_articles.joins(:group_order).where(group_orders: { ordergroup_id: user_a.ordergroup.id }).first
|
||||
expect(goa_a.result).to eq(3)
|
||||
# gruppe b bekommt 2 einheiten.
|
||||
goa_b = oa.group_order_articles.joins(:group_order).where(:group_orders => { :ordergroup_id => user_b.ordergroup.id }).first
|
||||
goa_b = oa.group_order_articles.joins(:group_order).where(group_orders: { ordergroup_id: user_b.ordergroup.id }).first
|
||||
expect(goa_b.result).to eq(2)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'receiving an order', js: true do
|
||||
let(:admin) { create :user, groups: [create(:workgroup, role_orders: true)] }
|
||||
let(:supplier) { create :supplier }
|
||||
let(:article) { create :article, supplier: supplier, unit_quantity: 3 }
|
||||
let(:order) { create :order, supplier: supplier, article_ids: [article.id] } # need to ref article
|
||||
let(:go1) { create :group_order, order: order }
|
||||
let(:go2) { create :group_order, order: order }
|
||||
let(:admin) { create(:user, groups: [create(:workgroup, role_orders: true)]) }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let(:article) { create(:article, supplier: supplier, unit_quantity: 3) }
|
||||
let(:order) { create(:order, supplier: supplier, article_ids: [article.id]) } # need to ref article
|
||||
let(:go1) { create(:group_order, order: order) }
|
||||
let(:go2) { create(:group_order, order: order) }
|
||||
let(:oa) { order.order_articles.find_by_article_id(article.id) }
|
||||
let(:goa1) { create :group_order_article, group_order: go1, order_article: oa }
|
||||
let(:goa2) { create :group_order_article, group_order: go2, order_article: oa }
|
||||
let(:goa1) { create(:group_order_article, group_order: go1, order_article: oa) }
|
||||
let(:goa2) { create(:group_order_article, group_order: go2, order_article: oa) }
|
||||
|
||||
# set quantities of group_order_articles
|
||||
def set_quantities(q1, q2)
|
||||
|
|
@ -46,7 +46,7 @@ feature 'receiving an order', js: true do
|
|||
it 'has product not ordered invisible' do
|
||||
set_quantities [0, 0], [0, 0]
|
||||
visit receive_order_path(id: order.id)
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(page).not_to have_selector("#order_article_#{oa.id}")
|
||||
end
|
||||
|
||||
it 'is not received by default' do
|
||||
|
|
@ -58,7 +58,7 @@ feature 'receiving an order', js: true do
|
|||
it 'does not change anything when received is ordered' do
|
||||
set_quantities [2, 0], [3, 2]
|
||||
visit receive_order_path(id: order.id)
|
||||
fill_in "order_articles_#{oa.id}_units_received", :with => oa.units_to_order
|
||||
fill_in "order_articles_#{oa.id}_units_received", with: oa.units_to_order
|
||||
find('input[type="submit"]').click
|
||||
expect(page).to have_selector('body')
|
||||
check_quantities 2, 2, 4
|
||||
|
|
@ -67,7 +67,7 @@ feature 'receiving an order', js: true do
|
|||
it 'redistributes properly when received is more' do
|
||||
set_quantities [2, 0], [3, 2]
|
||||
visit receive_order_path(id: order.id)
|
||||
fill_in "order_articles_#{oa.id}_units_received", :with => 3
|
||||
fill_in "order_articles_#{oa.id}_units_received", with: 3
|
||||
find('input[type="submit"]').click
|
||||
expect(page).to have_selector('body')
|
||||
check_quantities 3, 2, 5
|
||||
|
|
@ -76,7 +76,7 @@ feature 'receiving an order', js: true do
|
|||
it 'redistributes properly when received is less' do
|
||||
set_quantities [2, 0], [3, 2]
|
||||
visit receive_order_path(id: order.id)
|
||||
fill_in "order_articles_#{oa.id}_units_received", :with => 1
|
||||
fill_in "order_articles_#{oa.id}_units_received", with: 1
|
||||
find('input[type="submit"]').click
|
||||
expect(page).to have_selector('body')
|
||||
check_quantities 1, 2, 1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'the session' do
|
||||
let(:user) { create :user }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'login page' do
|
||||
it 'is accessible' do
|
||||
|
|
@ -11,7 +11,7 @@ feature 'the session' do
|
|||
|
||||
it 'logs me in' do
|
||||
login user
|
||||
expect(page).to_not have_selector('.alert-error')
|
||||
expect(page).not_to have_selector('.alert-error')
|
||||
end
|
||||
|
||||
it 'does not log me in with wrong password' do
|
||||
|
|
@ -21,10 +21,10 @@ feature 'the session' do
|
|||
|
||||
it 'can log me in using an email address' do
|
||||
visit login_path
|
||||
fill_in 'nick', :with => user.email
|
||||
fill_in 'password', :with => user.password
|
||||
fill_in 'nick', with: user.email
|
||||
fill_in 'password', with: user.password
|
||||
find('input[type=submit]').click
|
||||
expect(page).to_not have_selector('.alert-error')
|
||||
expect(page).not_to have_selector('.alert-error')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature 'supplier' do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:user) { create :user, :role_suppliers }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let(:user) { create(:user, :role_suppliers) }
|
||||
|
||||
before { login user }
|
||||
|
||||
describe 'create new' do
|
||||
it 'can be created' do
|
||||
create :supplier_category
|
||||
create(:supplier_category)
|
||||
visit new_supplier_path
|
||||
supplier = build :supplier
|
||||
supplier = build(:supplier)
|
||||
within('#new_supplier') do
|
||||
fill_in 'supplier_name', :with => supplier.name
|
||||
fill_in 'supplier_address', :with => supplier.address
|
||||
fill_in 'supplier_phone', :with => supplier.phone
|
||||
fill_in 'supplier_name', with: supplier.name
|
||||
fill_in 'supplier_address', with: supplier.address
|
||||
fill_in 'supplier_phone', with: supplier.phone
|
||||
find('input[type="submit"]').click
|
||||
end
|
||||
expect(page).to have_content(supplier.name)
|
||||
|
|
@ -38,7 +38,7 @@ feature 'supplier' do
|
|||
end
|
||||
|
||||
it 'can be updated' do
|
||||
new_supplier = build :supplier
|
||||
new_supplier = build(:supplier)
|
||||
supplier
|
||||
visit edit_supplier_path(id: supplier.id)
|
||||
fill_in 'supplier_name', with: new_supplier.name
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe BankTransaction do
|
||||
let(:bank_account) { create :bank_account }
|
||||
let(:bank_account) { create(:bank_account) }
|
||||
|
||||
it 'empty content' do
|
||||
content = ''
|
||||
|
|
@ -188,7 +188,7 @@ describe BankTransaction do
|
|||
expect(bt.date).to eq('2019-02-13'.to_date)
|
||||
expect(bt.text).to eq('Deutsche Bundesbahn')
|
||||
expect(bt.iban).to eq('DE72957284895783674747')
|
||||
expect(bt.reference).to eq("743574386368 Muenchen-Hamburg 27.03.2019")
|
||||
expect(bt.reference).to eq('743574386368 Muenchen-Hamburg 27.03.2019')
|
||||
expect(bt.receipt).to eq('Lastschrift')
|
||||
end
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ describe BankTransaction do
|
|||
expect(bt.date).to eq('2019-02-14'.to_date)
|
||||
expect(bt.text).to eq('superbank AG')
|
||||
expect(bt.iban).to be_nil
|
||||
expect(bt.reference).to eq("Überweisung US, Wechselspesen u Provision")
|
||||
expect(bt.reference).to eq('Überweisung US, Wechselspesen u Provision')
|
||||
expect(bt.receipt).to eq('Spesen/Gebühren')
|
||||
end
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ describe BankTransaction do
|
|||
expect(bank_account.last_transaction_date).to eq('2020-01-01'.to_date)
|
||||
expect(bank_account.balance).to eq(22)
|
||||
|
||||
bt1 = bank_account.bank_transactions.find_by_external_id("T1")
|
||||
bt1 = bank_account.bank_transactions.find_by_external_id('T1')
|
||||
expect(bt1.amount).to eq(11)
|
||||
expect(bt1.date).to eq('2020-01-01'.to_date)
|
||||
expect(bt1.text).to eq('DN1')
|
||||
|
|
@ -392,7 +392,7 @@ describe BankTransaction do
|
|||
expect(bt1.reference).to eq('')
|
||||
expect(bt1.receipt).to eq('AI1')
|
||||
|
||||
bt2 = bank_account.bank_transactions.find_by_external_id("T2")
|
||||
bt2 = bank_account.bank_transactions.find_by_external_id('T2')
|
||||
expect(bt2.amount).to eq(-22)
|
||||
expect(bt2.date).to eq('2010-02-01'.to_date)
|
||||
expect(bt2.text).to eq('CN2')
|
||||
|
|
@ -400,7 +400,7 @@ describe BankTransaction do
|
|||
expect(bt2.reference).to eq('RI2')
|
||||
expect(bt2.receipt).to be_nil
|
||||
|
||||
bt3 = bank_account.bank_transactions.find_by_external_id("T3")
|
||||
bt3 = bank_account.bank_transactions.find_by_external_id('T3')
|
||||
expect(bt3.amount).to eq(33)
|
||||
expect(bt3.date).to eq('2000-03-01'.to_date)
|
||||
expect(bt3.text).to eq('DN3')
|
||||
|
|
|
|||
|
|
@ -34,62 +34,65 @@ describe BankTransactionReference do
|
|||
end
|
||||
|
||||
it 'returns correct value for FS1A1' do
|
||||
expect(BankTransactionReference.parse('FS1A1')).to match({ group: 1, parts: { "A" => 1 } })
|
||||
expect(BankTransactionReference.parse('FS1A1')).to match({ group: 1, parts: { 'A' => 1 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1.2A3' do
|
||||
expect(BankTransactionReference.parse('FS1.2A3')).to match({ group: 1, user: 2, parts: { "A" => 3 } })
|
||||
expect(BankTransactionReference.parse('FS1.2A3')).to match({ group: 1, user: 2, parts: { 'A' => 3 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2B3C4' do
|
||||
expect(BankTransactionReference.parse('FS1A2B3C4')).to match({ group: 1, parts: { "A" => 2, "B" => 3, "C" => 4 } })
|
||||
expect(BankTransactionReference.parse('FS1A2B3C4')).to match({ group: 1, parts: { 'A' => 2, 'B' => 3, 'C' => 4 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2B3A4' do
|
||||
expect(BankTransactionReference.parse('FS1A2B3A4')).to match({ group: 1, parts: { "A" => 6, "B" => 3 } })
|
||||
expect(BankTransactionReference.parse('FS1A2B3A4')).to match({ group: 1, parts: { 'A' => 6, 'B' => 3 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2.34B5.67C8.90' do
|
||||
expect(BankTransactionReference.parse('FS1A2.34B5.67C8.90')).to match({ group: 1, parts: { "A" => 2.34, "B" => 5.67, "C" => 8.90 } })
|
||||
expect(BankTransactionReference.parse('FS1A2.34B5.67C8.90')).to match({ group: 1,
|
||||
parts: { 'A' => 2.34, 'B' => 5.67,
|
||||
'C' => 8.90 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with comma-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x,FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x,FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with minus-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x-FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x-FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with semicolon-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x;FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x;FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with space-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with comma-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567,x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567,x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with minus-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with space-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567 x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567 x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with semicolon-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567;x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567;x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with minus-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS34.56A67.89 with prefix and suffix' do
|
||||
expect(BankTransactionReference.parse('prefix FS34.56A67.89, suffix')).to match({ group: 34, user: 56, parts: { "A" => 67.89 } })
|
||||
expect(BankTransactionReference.parse('prefix FS34.56A67.89, suffix')).to match({ group: 34, user: 56,
|
||||
parts: { 'A' => 67.89 } })
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,55 +6,6 @@ describe FoodsoftMailReceiver do
|
|||
@server.start
|
||||
end
|
||||
|
||||
it 'does not accept empty addresses' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'missing'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('invalid', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'has an invalid format'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid scope in address' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('invalid.invalid', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'could not be found'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept address without handler' do
|
||||
begin
|
||||
address = "#{FoodsoftConfig[:default_scope]}.invalid"
|
||||
FoodsoftMailReceiver.received(address, 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'invalid format for recipient'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect {
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
}.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect {
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
}.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
# TODO: Reanable this test.
|
||||
# It raised "Mysql2::Error: Lock wait timeout exceeded" at time of writing.
|
||||
# it 'accepts bounce mails via SMTP' do
|
||||
|
|
@ -74,4 +25,45 @@ describe FoodsoftMailReceiver do
|
|||
after :all do
|
||||
@server.shutdown
|
||||
end
|
||||
|
||||
it 'does not accept empty addresses' do
|
||||
FoodsoftMailReceiver.received('', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'missing'
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses' do
|
||||
FoodsoftMailReceiver.received('invalid', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'has an invalid format'
|
||||
end
|
||||
|
||||
it 'does not accept invalid scope in address' do
|
||||
FoodsoftMailReceiver.received('invalid.invalid', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'could not be found'
|
||||
end
|
||||
|
||||
it 'does not accept address without handler' do
|
||||
address = "#{FoodsoftConfig[:default_scope]}.invalid"
|
||||
FoodsoftMailReceiver.received(address, 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'invalid format for recipient'
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect do
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
end.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect do
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
end.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ describe TokenVerifier do
|
|||
let(:msg) { v.generate }
|
||||
|
||||
it 'validates' do
|
||||
expect { v.verify(msg) }.to_not raise_error
|
||||
expect { v.verify(msg) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'validates when recreated' do
|
||||
v2 = TokenVerifier.new(prefix)
|
||||
expect { v2.verify(msg) }.to_not raise_error
|
||||
expect { v2.verify(msg) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'does not validate with a different prefix' do
|
||||
|
|
@ -32,7 +32,9 @@ describe TokenVerifier do
|
|||
end
|
||||
|
||||
it 'does not validate a random string' do
|
||||
expect { v.verify(Faker::Lorem.characters(number: 100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature)
|
||||
expect do
|
||||
v.verify(Faker::Lorem.characters(number: 100))
|
||||
end.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature)
|
||||
end
|
||||
|
||||
it 'returns the message' do
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe Article do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:article) { create :article, supplier: supplier }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let(:article) { create(:article, supplier: supplier) }
|
||||
|
||||
it 'has a unique name' do
|
||||
article2 = build :article, supplier: supplier, name: article.name
|
||||
article2 = build(:article, supplier: supplier, name: article.name)
|
||||
expect(article2).to be_invalid
|
||||
end
|
||||
|
||||
|
|
@ -21,21 +21,21 @@ describe Article do
|
|||
end
|
||||
|
||||
it 'returns false when invalid unit' do
|
||||
article1 = build :article, supplier: supplier, unit: 'invalid'
|
||||
article1 = build(:article, supplier: supplier, unit: 'invalid')
|
||||
expect(article.convert_units(article1)).to be false
|
||||
end
|
||||
|
||||
it 'converts from ST to KI (german foodcoops legacy)' do
|
||||
article1 = build :article, supplier: supplier, unit: 'ST'
|
||||
article2 = build :article, supplier: supplier, name: 'banana 10-12 St', price: 12.34, unit: 'KI'
|
||||
article1 = build(:article, supplier: supplier, unit: 'ST')
|
||||
article2 = build(:article, supplier: supplier, name: 'banana 10-12 St', price: 12.34, unit: 'KI')
|
||||
new_price, new_unit_quantity = article1.convert_units(article2)
|
||||
expect(new_unit_quantity).to eq 10
|
||||
expect(new_price).to eq 1.23
|
||||
end
|
||||
|
||||
it 'converts from g to kg' do
|
||||
article1 = build :article, supplier: supplier, unit: 'kg'
|
||||
article2 = build :article, supplier: supplier, unit: 'g', price: 0.12, unit_quantity: 1500
|
||||
article1 = build(:article, supplier: supplier, unit: 'kg')
|
||||
article2 = build(:article, supplier: supplier, unit: 'g', price: 0.12, unit_quantity: 1500)
|
||||
new_price, new_unit_quantity = article1.convert_units(article2)
|
||||
expect(new_unit_quantity).to eq 1.5
|
||||
expect(new_price).to eq 120
|
||||
|
|
@ -43,7 +43,7 @@ describe Article do
|
|||
end
|
||||
|
||||
it 'computes changed article attributes' do
|
||||
article2 = build :article, supplier: supplier, name: 'banana'
|
||||
article2 = build(:article, supplier: supplier, name: 'banana')
|
||||
expect(article.unequal_attributes(article2)[:name]).to eq 'banana'
|
||||
end
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ describe Article do
|
|||
end
|
||||
|
||||
it 'is knows its open order' do
|
||||
order = create :order, supplier: supplier, article_ids: [article.id]
|
||||
order = create(:order, supplier: supplier, article_ids: [article.id])
|
||||
expect(article.in_open_order).to eq(order)
|
||||
end
|
||||
|
||||
|
|
@ -91,26 +91,26 @@ describe Article do
|
|||
expect(article.shared_article).to be_nil
|
||||
end
|
||||
|
||||
describe 'connected to a shared database', :type => :feature do
|
||||
let(:shared_article) { create :shared_article }
|
||||
let(:supplier) { create :supplier, shared_supplier_id: shared_article.supplier_id }
|
||||
let(:article) { create :article, supplier: supplier, order_number: shared_article.order_number }
|
||||
describe 'connected to a shared database', type: :feature do
|
||||
let(:shared_article) { create(:shared_article) }
|
||||
let(:supplier) { create(:supplier, shared_supplier_id: shared_article.supplier_id) }
|
||||
let(:article) { create(:article, supplier: supplier, order_number: shared_article.order_number) }
|
||||
|
||||
it 'can be found in the shared database' do
|
||||
expect(article.shared_article).to_not be_nil
|
||||
expect(article.shared_article).not_to be_nil
|
||||
end
|
||||
|
||||
it 'can find updates' do
|
||||
changed = article.shared_article_changed?
|
||||
expect(changed).to_not be_falsey
|
||||
expect(changed).not_to be_falsey
|
||||
expect(changed.length).to be > 1
|
||||
end
|
||||
|
||||
it 'can be synchronised' do
|
||||
# TODO move article sync from supplier to article
|
||||
# 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(updated_article.attributes.reject { |k, v| k == 'id' or k == 'type' })
|
||||
article.update(updated_article.attributes.reject { |k, _v| %w[id type].include?(k) })
|
||||
expect(article.name).to eq(shared_article.name)
|
||||
# now synchronising shouldn't change anything anymore
|
||||
expect(article.shared_article_changed?).to be_falsey
|
||||
|
|
@ -131,9 +131,9 @@ describe Article do
|
|||
article.unit = '200g'
|
||||
article.shared_updated_on -= 1 # to make update do something
|
||||
article.save!
|
||||
# TODO get sync functionality in article
|
||||
# TODO: get sync functionality in article
|
||||
updated_article = supplier.sync_all[0].select { |s| s[0].id == article.id }.first[0]
|
||||
article.update!(updated_article.attributes.reject { |k, v| k == 'id' or k == 'type' })
|
||||
article.update!(updated_article.attributes.reject { |k, _v| %w[id type].include?(k) })
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1,24 +1,32 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe BankTransaction do
|
||||
let(:bank_account) { create :bank_account }
|
||||
let(:ordergroup) { create :ordergroup }
|
||||
let(:supplier) { create :supplier, iban: Faker::Bank.iban }
|
||||
let!(:user) { create :user, groups: [ordergroup] }
|
||||
let!(:ftt_a) { create :financial_transaction_type, name_short: 'A' }
|
||||
let!(:ftt_b) { create :financial_transaction_type, name_short: 'B' }
|
||||
let(:bank_account) { create(:bank_account) }
|
||||
let(:ordergroup) { create(:ordergroup) }
|
||||
let(:supplier) { create(:supplier, iban: Faker::Bank.iban) }
|
||||
let!(:user) { create(:user, groups: [ordergroup]) }
|
||||
let!(:ftt_a) { create(:financial_transaction_type, name_short: 'A') }
|
||||
let!(:ftt_b) { create(:financial_transaction_type, name_short: 'B') }
|
||||
|
||||
describe 'supplier' do
|
||||
let!(:invoice1) { create :invoice, supplier: supplier, number: '11', amount: 10 }
|
||||
let!(:invoice2) { create :invoice, supplier: supplier, number: '22', amount: 20 }
|
||||
let!(:invoice3) { create :invoice, supplier: supplier, number: '33', amount: 30 }
|
||||
let!(:invoice4) { create :invoice, supplier: supplier, number: '44', amount: 40 }
|
||||
let!(:invoice5) { create :invoice, supplier: supplier, number: '55', amount: 50 }
|
||||
let!(:invoice1) { create(:invoice, supplier: supplier, number: '11', amount: 10) }
|
||||
let!(:invoice2) { create(:invoice, supplier: supplier, number: '22', amount: 20) }
|
||||
let!(:invoice3) { create(:invoice, supplier: supplier, number: '33', amount: 30) }
|
||||
let!(:invoice4) { create(:invoice, supplier: supplier, number: '44', amount: 40) }
|
||||
let!(:invoice5) { create(:invoice, supplier: supplier, number: '55', amount: 50) }
|
||||
|
||||
let!(:bank_transaction1) { create :bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '11', amount: 10 }
|
||||
let!(:bank_transaction2) { create :bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '22', amount: -20 }
|
||||
let!(:bank_transaction3) { create :bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '33,44', amount: -70 }
|
||||
let!(:bank_transaction4) { create :bank_transaction, bank_account: bank_account, iban: supplier.iban, text: '55', amount: -50 }
|
||||
let!(:bank_transaction1) do
|
||||
create(:bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '11', amount: 10)
|
||||
end
|
||||
let!(:bank_transaction2) do
|
||||
create(:bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '22', amount: -20)
|
||||
end
|
||||
let!(:bank_transaction3) do
|
||||
create(:bank_transaction, bank_account: bank_account, iban: supplier.iban, reference: '33,44', amount: -70)
|
||||
end
|
||||
let!(:bank_transaction4) do
|
||||
create(:bank_transaction, bank_account: bank_account, iban: supplier.iban, text: '55', amount: -50)
|
||||
end
|
||||
|
||||
it 'ignores invoices with invalid amount' do
|
||||
expect(bank_transaction1.assign_to_invoice).to be false
|
||||
|
|
@ -49,14 +57,26 @@ describe BankTransaction do
|
|||
end
|
||||
|
||||
describe 'ordergroup' do
|
||||
let!(:bank_transaction1) { create :bank_transaction, bank_account: bank_account, reference: "invalid", amount: 10 }
|
||||
let!(:bank_transaction2) { create :bank_transaction, bank_account: bank_account, reference: "FS99A10", amount: 10 }
|
||||
let!(:bank_transaction3) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}.99A10", amount: 10 }
|
||||
let!(:bank_transaction4) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10", amount: 99 }
|
||||
let!(:bank_transaction5) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10", amount: 10 }
|
||||
let!(:bank_transaction6) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10B20", amount: 30 }
|
||||
let!(:bank_transaction7) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}.#{user.id}A10", amount: 10 }
|
||||
let!(:bank_transaction8) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}X10", amount: 10 }
|
||||
let!(:bank_transaction1) { create(:bank_transaction, bank_account: bank_account, reference: 'invalid', amount: 10) }
|
||||
let!(:bank_transaction2) { create(:bank_transaction, bank_account: bank_account, reference: 'FS99A10', amount: 10) }
|
||||
let!(:bank_transaction3) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}.99A10", amount: 10)
|
||||
end
|
||||
let!(:bank_transaction4) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10", amount: 99)
|
||||
end
|
||||
let!(:bank_transaction5) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10", amount: 10)
|
||||
end
|
||||
let!(:bank_transaction6) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}A10B20", amount: 30)
|
||||
end
|
||||
let!(:bank_transaction7) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}.#{user.id}A10", amount: 10)
|
||||
end
|
||||
let!(:bank_transaction8) do
|
||||
create(:bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}X10", amount: 10)
|
||||
end
|
||||
|
||||
it 'ignores transaction with invalid reference' do
|
||||
expect(bank_transaction1.assign_to_ordergroup).to be_nil
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe Delivery do
|
||||
let(:delivery) { create :delivery }
|
||||
let(:stock_article) { create :stock_article, price: 3 }
|
||||
let(:delivery) { create(:delivery) }
|
||||
let(:stock_article) { create(:stock_article, price: 3) }
|
||||
|
||||
it 'creates new stock_changes' do
|
||||
delivery.new_stock_changes = ([
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe GroupOrderArticle do
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:order) { create(:order) }
|
||||
let(:go) { create :group_order, order: order, ordergroup: user.ordergroup }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: order.order_articles.first }
|
||||
let(:go) { create(:group_order, order: order, ordergroup: user.ordergroup) }
|
||||
let(:goa) { create(:group_order_article, group_order: go, order_article: order.order_articles.first) }
|
||||
|
||||
it 'has zero quantity by default' do expect(goa.quantity).to eq(0) end
|
||||
it 'has zero tolerance by default' do expect(goa.tolerance).to eq(0) end
|
||||
|
|
@ -12,9 +12,9 @@ describe GroupOrderArticle do
|
|||
it 'has zero total price by default' do expect(goa.total_price).to eq(0) end
|
||||
|
||||
describe do
|
||||
let(:article) { create :article, supplier: order.supplier, unit_quantity: 1 }
|
||||
let(:oa) { order.order_articles.create(:article => article) }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||
let(:article) { create(:article, supplier: order.supplier, unit_quantity: 1) }
|
||||
let(:oa) { order.order_articles.create(article: article) }
|
||||
let(:goa) { create(:group_order_article, group_order: go, order_article: oa) }
|
||||
|
||||
it 'can be ordered by piece' do
|
||||
goa.update_quantities(1, 0)
|
||||
|
|
@ -23,7 +23,8 @@ describe GroupOrderArticle do
|
|||
end
|
||||
|
||||
it 'can be ordered in larger amounts' do
|
||||
quantity, tolerance = rand(13..99), rand(0..99)
|
||||
quantity = rand(13..99)
|
||||
tolerance = rand(0..99)
|
||||
goa.update_quantities(quantity, tolerance)
|
||||
expect(goa.quantity).to eq(quantity)
|
||||
expect(goa.tolerance).to eq(tolerance)
|
||||
|
|
@ -52,10 +53,10 @@ describe GroupOrderArticle do
|
|||
end
|
||||
|
||||
describe 'distribution strategy' do
|
||||
let(:article) { create :article, supplier: order.supplier, unit_quantity: 1 }
|
||||
let(:oa) { order.order_articles.create(:article => article) }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||
let!(:goaq) { create :group_order_article_quantity, group_order_article: goa, quantity: 4, tolerance: 6 }
|
||||
let(:article) { create(:article, supplier: order.supplier, unit_quantity: 1) }
|
||||
let(:oa) { order.order_articles.create(article: article) }
|
||||
let(:goa) { create(:group_order_article, group_order: go, order_article: oa) }
|
||||
let!(:goaq) { create(:group_order_article_quantity, group_order_article: goa, quantity: 4, tolerance: 6) }
|
||||
|
||||
it 'can calculate the result for the distribution strategy "first order first serve"' do
|
||||
res = goa.calculate_result(2)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe GroupOrder do
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:order) { create :order }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:order) { create(:order) }
|
||||
|
||||
# the following two tests are currently disabled - https://github.com/foodcoops/foodsoft/issues/158
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ describe GroupOrder do
|
|||
# end
|
||||
|
||||
describe do
|
||||
let(:go) { create :group_order, order: order, ordergroup: user.ordergroup }
|
||||
let(:go) { create(:group_order, order: order, ordergroup: user.ordergroup) }
|
||||
|
||||
it 'has zero price initially' do
|
||||
expect(go.price).to eq(0)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe OrderArticle do
|
||||
let(:order) { create :order, article_count: 1 }
|
||||
let(:order) { create(:order, article_count: 1) }
|
||||
let(:oa) { order.order_articles.first }
|
||||
|
||||
it 'is not ordered by default' do
|
||||
expect(OrderArticle.ordered.count).to eq 0
|
||||
end
|
||||
|
||||
[:units_to_order, :units_billed, :units_received].each do |units|
|
||||
%i[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
|
||||
|
|
@ -46,15 +46,15 @@ describe OrderArticle do
|
|||
end
|
||||
|
||||
describe 'redistribution' do
|
||||
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 }
|
||||
let(:go2) { create :group_order, order: order }
|
||||
let(:go3) { create :group_order, order: order }
|
||||
let(:goa1) { create :group_order_article, group_order: go1, order_article: oa }
|
||||
let(:goa2) { create :group_order_article, group_order: go2, order_article: oa }
|
||||
let(:goa3) { create :group_order_article, group_order: go3, order_article: oa }
|
||||
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) }
|
||||
let(:go2) { create(:group_order, order: order) }
|
||||
let(:go3) { create(:group_order, order: order) }
|
||||
let(:goa1) { create(:group_order_article, group_order: go1, order_article: oa) }
|
||||
let(:goa2) { create(:group_order_article, group_order: go2, order_article: oa) }
|
||||
let(:goa3) { create(:group_order_article, group_order: go3, order_article: oa) }
|
||||
|
||||
# set quantities of group_order_articles
|
||||
def set_quantities(q1, q2, q3)
|
||||
|
|
@ -79,21 +79,21 @@ describe OrderArticle do
|
|||
|
||||
it 'does nothing when nothing has changed' do
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 6, [:tolerance, nil]).to eq [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]
|
||||
expect(oa.redistribute 0, [:tolerance, nil]).to eq [0, 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]
|
||||
expect(oa.redistribute 4, [:tolerance, nil]).to eq [0, 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
|
||||
|
|
@ -101,28 +101,28 @@ describe OrderArticle do
|
|||
it 'works when quantity is increased within quantity' do
|
||||
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]
|
||||
expect(oa.redistribute(7, [:tolerance, nil])).to eq [0, 0]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result).map(&:to_i)).to eq [3, 2, 2]
|
||||
end
|
||||
|
||||
it 'works when there is just one for the first' do
|
||||
set_quantities [3, 2], [1, 3], [1, 0]
|
||||
expect(oa.redistribute 1, [:tolerance, nil]).to eq [0, 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]
|
||||
expect(oa.redistribute 10, [:tolerance, nil]).to eq [3, 2]
|
||||
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]
|
||||
expect(oa.redistribute 8, [nil]).to eq [3]
|
||||
expect(oa.redistribute(8, [nil])).to eq [3]
|
||||
goa_reload
|
||||
expect([goa1, goa2, goa3].map(&:result)).to eq [3, 1, 1]
|
||||
end
|
||||
|
|
@ -131,17 +131,18 @@ describe OrderArticle do
|
|||
describe 'boxfill' do
|
||||
before { FoodsoftConfig[:use_boxfill] = true }
|
||||
|
||||
let(:article) { create :article, unit_quantity: 6 }
|
||||
let(:order) { create :order, article_ids: [article.id], starts: 1.week.ago }
|
||||
let(:article) { create(:article, unit_quantity: 6) }
|
||||
let(:order) { create(:order, article_ids: [article.id], starts: 1.week.ago) }
|
||||
let(:oa) { order.order_articles.first }
|
||||
let(:go) { create :group_order, order: order }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||
let(:go) { create(:group_order, order: order) }
|
||||
let(:goa) { create(:group_order_article, group_order: go, order_article: oa) }
|
||||
|
||||
shared_examples "boxfill" do |success, q|
|
||||
shared_examples 'boxfill' do |success, q|
|
||||
# initial situation
|
||||
before do
|
||||
goa.update_quantities(*q.keys[0])
|
||||
oa.update_results!; oa.reload
|
||||
oa.update_results!
|
||||
oa.reload
|
||||
end
|
||||
|
||||
# check starting condition
|
||||
|
|
@ -172,11 +173,11 @@ describe OrderArticle 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
|
||||
|
||||
|
|
@ -184,27 +185,27 @@ describe OrderArticle 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
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe Order do
|
||||
let!(:ftt) { create :financial_transaction_type }
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let!(:ftt) { create(:financial_transaction_type) }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
|
||||
it 'automaticly finishes ended' do
|
||||
create :order, created_by: user, starts: Date.yesterday, ends: 1.hour.from_now
|
||||
create :order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago
|
||||
create :order, created_by: user, starts: Date.yesterday, ends: 1.hour.from_now, end_action: :auto_close
|
||||
order = create :order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago, end_action: :auto_close
|
||||
create(:order, created_by: user, starts: Date.yesterday, ends: 1.hour.from_now)
|
||||
create(:order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago)
|
||||
create(:order, created_by: user, starts: Date.yesterday, ends: 1.hour.from_now, end_action: :auto_close)
|
||||
order = create(:order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago, end_action: :auto_close)
|
||||
|
||||
Order.finish_ended!
|
||||
order.reload
|
||||
|
|
@ -19,10 +19,10 @@ describe Order do
|
|||
end
|
||||
|
||||
describe 'state scopes and boolean getters' do
|
||||
let!(:open_order) { create :order, state: 'open' }
|
||||
let!(:finished_order) { create :order, state: 'finished' }
|
||||
let!(:received_order) { create :order, state: 'received' }
|
||||
let!(:closed_order) { create :order, state: 'closed' }
|
||||
let!(:open_order) { create(:order, state: 'open') }
|
||||
let!(:finished_order) { create(:order, state: 'finished') }
|
||||
let!(:received_order) { create(:order, state: 'received') }
|
||||
let!(:closed_order) { create(:order, state: 'closed') }
|
||||
|
||||
it 'retrieves open orders in the "open" scope' do
|
||||
expect(Order.open.count).to eq(1)
|
||||
|
|
@ -72,8 +72,9 @@ describe Order do
|
|||
end
|
||||
|
||||
it 'sends mail if min_order_quantity has been reached' do
|
||||
create :user, groups: [create(:ordergroup)]
|
||||
create :order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago, end_action: :auto_close_and_send_min_quantity
|
||||
create(:user, groups: [create(:ordergroup)])
|
||||
create(:order, created_by: user, starts: Date.yesterday, ends: 1.hour.ago,
|
||||
end_action: :auto_close_and_send_min_quantity)
|
||||
|
||||
Order.finish_ended!
|
||||
expect(ActionMailer::Base.deliveries.count).to eq 1
|
||||
|
|
@ -84,7 +85,7 @@ describe Order do
|
|||
end
|
||||
|
||||
it 'needs order articles' do
|
||||
supplier = create :supplier, article_count: 0
|
||||
supplier = create(:supplier, article_count: 0)
|
||||
expect(build(:order, supplier: supplier)).to be_invalid
|
||||
end
|
||||
|
||||
|
|
@ -93,35 +94,35 @@ describe Order do
|
|||
end
|
||||
|
||||
describe 'with articles' do
|
||||
let(:order) { create :order }
|
||||
let(:order) { create(:order) }
|
||||
|
||||
it 'is open by default' do expect(order).to be_open end
|
||||
it 'is not finished by default' do expect(order).to_not be_finished end
|
||||
it 'is not closed by default' do expect(order).to_not be_closed end
|
||||
it 'is not finished by default' do expect(order).not_to be_finished end
|
||||
it 'is not closed by default' do expect(order).not_to be_closed end
|
||||
|
||||
it 'has valid order articles' do
|
||||
order.order_articles.each { |oa| expect(oa).to be_valid }
|
||||
end
|
||||
|
||||
it 'can be finished' do
|
||||
# TODO randomise user
|
||||
# TODO: randomise user
|
||||
order.finish!(user)
|
||||
expect(order).to_not be_open
|
||||
expect(order).not_to be_open
|
||||
expect(order).to be_finished
|
||||
expect(order).to_not be_closed
|
||||
expect(order).not_to be_closed
|
||||
end
|
||||
|
||||
it 'can be closed' do
|
||||
# TODO randomise user
|
||||
# TODO: randomise user
|
||||
order.finish!(user)
|
||||
order.close!(user)
|
||||
expect(order).to_not be_open
|
||||
expect(order).not_to be_open
|
||||
expect(order).to be_closed
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with a default end date' do
|
||||
let(:order) { create :order }
|
||||
let(:order) { create(:order) }
|
||||
|
||||
before do
|
||||
FoodsoftConfig[:order_schedule] = { ends: { recurr: 'FREQ=WEEKLY;BYDAY=MO', time: '9:00' } }
|
||||
|
|
@ -138,10 +139,10 @@ describe Order do
|
|||
end
|
||||
|
||||
describe 'mapped to GroupOrders' do
|
||||
let!(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let!(:order) { create :order }
|
||||
let!(:order2) { create :order }
|
||||
let!(:go) { create :group_order, order: order, ordergroup: user.ordergroup }
|
||||
let!(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let!(:order) { create(:order) }
|
||||
let!(:order2) { create(:order) }
|
||||
let!(:go) { create(:group_order, order: order, ordergroup: user.ordergroup) }
|
||||
|
||||
it 'to map a user\'s GroupOrders to a list of Orders' do
|
||||
orders = Order.ordergroup_group_orders_map(user.ordergroup)
|
||||
|
|
@ -156,10 +157,10 @@ describe Order do
|
|||
|
||||
describe 'balancing charges correct amounts' do
|
||||
let!(:transport) { rand(0.1..26.0).round(2) }
|
||||
let!(:order) { create :order, article_count: 1 }
|
||||
let!(:order) { create(:order, article_count: 1) }
|
||||
let!(:oa) { order.order_articles.first }
|
||||
let!(:go) { create :group_order, order: order, transport: transport }
|
||||
let!(:goa) { create :group_order_article, group_order: go, order_article: oa, quantity: 1 }
|
||||
let!(:go) { create(:group_order, order: order, transport: transport) }
|
||||
let!(:goa) { create(:group_order_article, group_order: go, order_article: oa, quantity: 1) }
|
||||
|
||||
before do
|
||||
goa.update_quantities(1, 0)
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe Ordergroup do
|
||||
let(:ftc1) { create :financial_transaction_class }
|
||||
let(:ftc2) { create :financial_transaction_class }
|
||||
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(:ftc1) { create(:financial_transaction_class) }
|
||||
let(:ftc2) { create(:financial_transaction_class) }
|
||||
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)]) }
|
||||
|
||||
it 'shows no active ordergroups when all orders are older than 3 months' do
|
||||
order = create :order, starts: 4.months.ago
|
||||
order = create(:order, starts: 4.months.ago)
|
||||
user.ordergroup.group_orders.create!(order: order)
|
||||
|
||||
expect(Ordergroup.active).to be_empty
|
||||
end
|
||||
|
||||
it 'shows active ordergroups when there are recent orders' do
|
||||
order = create :order, starts: 2.days.ago
|
||||
order = create(:order, starts: 2.days.ago)
|
||||
user.ordergroup.group_orders.create!(order: order)
|
||||
|
||||
expect(Ordergroup.active).not_to be_empty
|
||||
|
|
@ -24,17 +24,17 @@ describe Ordergroup do
|
|||
|
||||
describe 'sort correctly' do
|
||||
it 'by name' do
|
||||
group_b = create :ordergroup, name: 'bbb'
|
||||
group_a = create :ordergroup, name: 'aaa'
|
||||
group_c = create :ordergroup, name: 'ccc'
|
||||
group_b = create(:ordergroup, name: 'bbb')
|
||||
group_a = create(:ordergroup, name: 'aaa')
|
||||
group_c = create(:ordergroup, name: 'ccc')
|
||||
|
||||
expect(Ordergroup.sort_by_param('name')).to eq([group_a, group_b, group_c])
|
||||
end
|
||||
|
||||
it 'reverse by name' do
|
||||
group_b = create :ordergroup, name: 'bbb'
|
||||
group_a = create :ordergroup, name: 'aaa'
|
||||
group_c = create :ordergroup, name: 'ccc'
|
||||
group_b = create(:ordergroup, name: 'bbb')
|
||||
group_a = create(:ordergroup, name: 'aaa')
|
||||
group_c = create(:ordergroup, name: 'ccc')
|
||||
|
||||
expect(Ordergroup.sort_by_param('name_reverse')).to eq([group_c, group_b, group_a])
|
||||
end
|
||||
|
|
@ -43,9 +43,9 @@ describe Ordergroup do
|
|||
users_b = [create(:user)]
|
||||
users_a = []
|
||||
users_c = [create(:user), create(:user), create(:user)]
|
||||
group_b = create :ordergroup, name: 'bbb', user_ids: users_b.map(&:id)
|
||||
group_a = create :ordergroup, name: 'aaa', user_ids: users_a.map(&:id)
|
||||
group_c = create :ordergroup, name: 'ccc', user_ids: users_c.map(&:id)
|
||||
group_b = create(:ordergroup, name: 'bbb', user_ids: users_b.map(&:id))
|
||||
group_a = create(:ordergroup, name: 'aaa', user_ids: users_a.map(&:id))
|
||||
group_c = create(:ordergroup, name: 'ccc', user_ids: users_c.map(&:id))
|
||||
|
||||
expect(Ordergroup.sort_by_param('members_count')).to eq([group_a, group_b, group_c])
|
||||
end
|
||||
|
|
@ -54,39 +54,39 @@ describe Ordergroup do
|
|||
users_b = [create(:user)]
|
||||
users_a = []
|
||||
users_c = [create(:user), create(:user), create(:user)]
|
||||
group_b = create :ordergroup, name: 'bbb', user_ids: users_b.map(&:id)
|
||||
group_a = create :ordergroup, name: 'aaa', user_ids: users_a.map(&:id)
|
||||
group_c = create :ordergroup, name: 'ccc', user_ids: users_c.map(&:id)
|
||||
group_b = create(:ordergroup, name: 'bbb', user_ids: users_b.map(&:id))
|
||||
group_a = create(:ordergroup, name: 'aaa', user_ids: users_a.map(&:id))
|
||||
group_c = create(:ordergroup, name: 'ccc', user_ids: users_c.map(&:id))
|
||||
|
||||
expect(Ordergroup.sort_by_param('members_count_reverse')).to eq([group_c, group_b, group_a])
|
||||
end
|
||||
|
||||
it 'by last_user_activity' do
|
||||
user_b = create :user, last_activity: 3.days.ago
|
||||
user_a = create :user, last_activity: 5.days.ago
|
||||
user_c = create :user, last_activity: Time.now
|
||||
group_b = create :ordergroup, name: 'bbb', user_ids: [user_b.id]
|
||||
group_a = create :ordergroup, name: 'aaa', user_ids: [user_a.id]
|
||||
group_c = create :ordergroup, name: 'ccc', user_ids: [user_c.id]
|
||||
user_b = create(:user, last_activity: 3.days.ago)
|
||||
user_a = create(:user, last_activity: 5.days.ago)
|
||||
user_c = create(:user, last_activity: Time.now)
|
||||
group_b = create(:ordergroup, name: 'bbb', user_ids: [user_b.id])
|
||||
group_a = create(:ordergroup, name: 'aaa', user_ids: [user_a.id])
|
||||
group_c = create(:ordergroup, name: 'ccc', user_ids: [user_c.id])
|
||||
|
||||
expect(Ordergroup.sort_by_param('last_user_activity')).to eq([group_a, group_b, group_c])
|
||||
end
|
||||
|
||||
it 'reverse by last_user_activity' do
|
||||
user_b = create :user, last_activity: 3.days.ago
|
||||
user_a = create :user, last_activity: 5.days.ago
|
||||
user_c = create :user, last_activity: Time.now
|
||||
group_b = create :ordergroup, name: 'bbb', user_ids: [user_b.id]
|
||||
group_a = create :ordergroup, name: 'aaa', user_ids: [user_a.id]
|
||||
group_c = create :ordergroup, name: 'ccc', user_ids: [user_c.id]
|
||||
user_b = create(:user, last_activity: 3.days.ago)
|
||||
user_a = create(:user, last_activity: 5.days.ago)
|
||||
user_c = create(:user, last_activity: Time.now)
|
||||
group_b = create(:ordergroup, name: 'bbb', user_ids: [user_b.id])
|
||||
group_a = create(:ordergroup, name: 'aaa', user_ids: [user_a.id])
|
||||
group_c = create(:ordergroup, name: 'ccc', user_ids: [user_c.id])
|
||||
|
||||
expect(Ordergroup.sort_by_param('last_user_activity_reverse')).to eq([group_c, group_b, group_a])
|
||||
end
|
||||
|
||||
it 'by last_order' do
|
||||
group_b = create :ordergroup, name: 'bbb'
|
||||
group_a = create :ordergroup, name: 'aaa'
|
||||
group_c = create :ordergroup, name: 'ccc'
|
||||
group_b = create(:ordergroup, name: 'bbb')
|
||||
group_a = create(:ordergroup, name: 'aaa')
|
||||
group_c = create(:ordergroup, name: 'ccc')
|
||||
group_b.group_orders.create! order: create(:order, starts: 6.days.ago)
|
||||
group_a.group_orders.create! order: create(:order, starts: 4.months.ago)
|
||||
group_c.group_orders.create! order: create(:order, starts: Time.now)
|
||||
|
|
@ -95,9 +95,9 @@ describe Ordergroup do
|
|||
end
|
||||
|
||||
it 'reverse by last_order' do
|
||||
group_b = create :ordergroup, name: 'bbb'
|
||||
group_a = create :ordergroup, name: 'aaa'
|
||||
group_c = create :ordergroup, name: 'ccc'
|
||||
group_b = create(:ordergroup, name: 'bbb')
|
||||
group_a = create(:ordergroup, name: 'aaa')
|
||||
group_c = create(:ordergroup, name: 'ccc')
|
||||
group_b.group_orders.create! order: create(:order, starts: 6.days.ago)
|
||||
group_a.group_orders.create! order: create(:order, starts: 4.months.ago)
|
||||
group_c.group_orders.create! order: create(:order, starts: Time.now)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ require_relative '../spec_helper'
|
|||
|
||||
describe User do
|
||||
it 'is correctly created' do
|
||||
user = create :user,
|
||||
user = create(:user,
|
||||
nick: 'johnnydoe', first_name: 'Johnny', last_name: 'DoeBar',
|
||||
email: 'johnnydoe@foodcoop.test', phone: '+1234567890'
|
||||
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')
|
||||
|
|
@ -14,7 +14,7 @@ describe User do
|
|||
end
|
||||
|
||||
describe 'does not have the role' do
|
||||
let(:user) { create :user }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it 'admin' do expect(user.role_admin?).to be_falsey end
|
||||
it 'finance' do expect(user.role_finance?).to be_falsey end
|
||||
|
|
@ -24,7 +24,7 @@ describe User do
|
|||
end
|
||||
|
||||
describe do
|
||||
let(:user) { create :user, password: 'blahblahblah' }
|
||||
let(:user) { create(:user, password: 'blahblahblah') }
|
||||
|
||||
it 'can authenticate with correct password' do
|
||||
expect(User.authenticate(user.nick, 'blahblahblah')).to be_truthy
|
||||
|
|
@ -74,124 +74,124 @@ describe User do
|
|||
end
|
||||
|
||||
describe 'admin' do
|
||||
let(:user) { create :admin }
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
it 'default admin role' do expect(user.role_admin?).to be_truthy end
|
||||
end
|
||||
|
||||
describe 'sort correctly' do
|
||||
it 'by nick' do
|
||||
user_b = create :user, nick: 'bbb'
|
||||
user_a = create :user, nick: 'aaa'
|
||||
user_c = create :user, nick: 'ccc'
|
||||
user_b = create(:user, nick: 'bbb')
|
||||
user_a = create(:user, nick: 'aaa')
|
||||
user_c = create(:user, nick: 'ccc')
|
||||
|
||||
expect(User.sort_by_param('nick')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by nick' do
|
||||
user_b = create :user, nick: 'bbb'
|
||||
user_a = create :user, nick: 'aaa'
|
||||
user_c = create :user, nick: 'ccc'
|
||||
user_b = create(:user, nick: 'bbb')
|
||||
user_a = create(:user, nick: 'aaa')
|
||||
user_c = create(:user, nick: 'ccc')
|
||||
|
||||
expect(User.sort_by_param('nick_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'by name' do
|
||||
user_b = create :user, first_name: 'aaa', last_name: 'bbb'
|
||||
user_a = create :user, first_name: 'aaa', last_name: 'aaa'
|
||||
user_c = create :user, first_name: 'ccc', last_name: 'aaa'
|
||||
user_b = create(:user, first_name: 'aaa', last_name: 'bbb')
|
||||
user_a = create(:user, first_name: 'aaa', last_name: 'aaa')
|
||||
user_c = create(:user, first_name: 'ccc', last_name: 'aaa')
|
||||
|
||||
expect(User.sort_by_param('name')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by name' do
|
||||
user_b = create :user, first_name: 'aaa', last_name: 'bbb'
|
||||
user_a = create :user, first_name: 'aaa', last_name: 'aaa'
|
||||
user_c = create :user, first_name: 'ccc', last_name: 'aaa'
|
||||
user_b = create(:user, first_name: 'aaa', last_name: 'bbb')
|
||||
user_a = create(:user, first_name: 'aaa', last_name: 'aaa')
|
||||
user_c = create(:user, first_name: 'ccc', last_name: 'aaa')
|
||||
|
||||
expect(User.sort_by_param('name_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'by email' do
|
||||
user_b = create :user, email: 'bbb@dummy.com'
|
||||
user_a = create :user, email: 'aaa@dummy.com'
|
||||
user_c = create :user, email: 'ccc@dummy.com'
|
||||
user_b = create(:user, email: 'bbb@dummy.com')
|
||||
user_a = create(:user, email: 'aaa@dummy.com')
|
||||
user_c = create(:user, email: 'ccc@dummy.com')
|
||||
|
||||
expect(User.sort_by_param('email')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by email' do
|
||||
user_b = create :user, email: 'bbb@dummy.com'
|
||||
user_a = create :user, email: 'aaa@dummy.com'
|
||||
user_c = create :user, email: 'ccc@dummy.com'
|
||||
user_b = create(:user, email: 'bbb@dummy.com')
|
||||
user_a = create(:user, email: 'aaa@dummy.com')
|
||||
user_c = create(:user, email: 'ccc@dummy.com')
|
||||
|
||||
expect(User.sort_by_param('email_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'by phone' do
|
||||
user_b = create :user, phone: 'bbb'
|
||||
user_a = create :user, phone: 'aaa'
|
||||
user_c = create :user, phone: 'ccc'
|
||||
user_b = create(:user, phone: 'bbb')
|
||||
user_a = create(:user, phone: 'aaa')
|
||||
user_c = create(:user, phone: 'ccc')
|
||||
|
||||
expect(User.sort_by_param('phone')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by phone' do
|
||||
user_b = create :user, phone: 'bbb'
|
||||
user_a = create :user, phone: 'aaa'
|
||||
user_c = create :user, phone: 'ccc'
|
||||
user_b = create(:user, phone: 'bbb')
|
||||
user_a = create(:user, phone: 'aaa')
|
||||
user_c = create(:user, phone: 'ccc')
|
||||
|
||||
expect(User.sort_by_param('phone_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'by last_activity' do
|
||||
user_b = create :user, last_activity: 3.days.ago
|
||||
user_a = create :user, last_activity: 5.days.ago
|
||||
user_c = create :user, last_activity: Time.now
|
||||
user_b = create(:user, last_activity: 3.days.ago)
|
||||
user_a = create(:user, last_activity: 5.days.ago)
|
||||
user_c = create(:user, last_activity: Time.now)
|
||||
|
||||
expect(User.sort_by_param('last_activity')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by last_activity' do
|
||||
user_b = create :user, last_activity: 3.days.ago
|
||||
user_a = create :user, last_activity: 5.days.ago
|
||||
user_c = create :user, last_activity: Time.now
|
||||
user_b = create(:user, last_activity: 3.days.ago)
|
||||
user_a = create(:user, last_activity: 5.days.ago)
|
||||
user_c = create(:user, last_activity: Time.now)
|
||||
|
||||
expect(User.sort_by_param('last_activity_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'by ordergroup' do
|
||||
user_b = create :user, groups: [create(:workgroup, name: 'a'), create(:ordergroup, name: 'bb')]
|
||||
user_a = create :user, groups: [create(:workgroup, name: 'b'), create(:ordergroup, name: 'aa')]
|
||||
user_c = create :user, groups: [create(:workgroup, name: 'c'), create(:ordergroup, name: 'cc')]
|
||||
user_b = create(:user, groups: [create(:workgroup, name: 'a'), create(:ordergroup, name: 'bb')])
|
||||
user_a = create(:user, groups: [create(:workgroup, name: 'b'), create(:ordergroup, name: 'aa')])
|
||||
user_c = create(:user, groups: [create(:workgroup, name: 'c'), create(:ordergroup, name: 'cc')])
|
||||
|
||||
expect(User.sort_by_param('ordergroup')).to eq([user_a, user_b, user_c])
|
||||
end
|
||||
|
||||
it 'reverse by ordergroup' do
|
||||
user_b = create :user, groups: [create(:workgroup, name: 'a'), create(:ordergroup, name: 'bb')]
|
||||
user_a = create :user, groups: [create(:workgroup, name: 'b'), create(:ordergroup, name: 'aa')]
|
||||
user_c = create :user, groups: [create(:workgroup, name: 'c'), create(:ordergroup, name: 'cc')]
|
||||
user_b = create(:user, groups: [create(:workgroup, name: 'a'), create(:ordergroup, name: 'bb')])
|
||||
user_a = create(:user, groups: [create(:workgroup, name: 'b'), create(:ordergroup, name: 'aa')])
|
||||
user_c = create(:user, groups: [create(:workgroup, name: 'c'), create(:ordergroup, name: 'cc')])
|
||||
|
||||
expect(User.sort_by_param('ordergroup_reverse')).to eq([user_c, user_b, user_a])
|
||||
end
|
||||
|
||||
it 'and users are only listed once' do
|
||||
create :user
|
||||
create(:user)
|
||||
|
||||
expect(User.sort_by_param('ordergroup').size).to eq(1)
|
||||
end
|
||||
|
||||
it 'and users belonging to a workgroup are only listed once' do
|
||||
create :admin
|
||||
create(:admin)
|
||||
|
||||
expect(User.sort_by_param('ordergroup').size).to eq(1)
|
||||
end
|
||||
|
||||
it 'and users belonging to 2 ordergroups are only listed once' do
|
||||
user = create :user
|
||||
create :ordergroup, user_ids: [user.id]
|
||||
create :ordergroup, user_ids: [user.id]
|
||||
user = create(:user)
|
||||
create(:ordergroup, user_ids: [user.id])
|
||||
create(:ordergroup, user_ids: [user.id])
|
||||
|
||||
expect(User.sort_by_param('ordergroup').size).to eq(1)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Article Categories', type: :request do
|
||||
describe Api::V1::ArticleCategoriesController do
|
||||
include ApiHelper
|
||||
|
||||
path '/article_categories' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Config', type: :request do
|
||||
describe Api::V1::ConfigsController do
|
||||
include ApiHelper
|
||||
|
||||
path '/config' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Financial Transaction Classes', type: :request do
|
||||
describe Api::V1::FinancialTransactionClassesController do
|
||||
include ApiHelper
|
||||
|
||||
path '/financial_transaction_classes' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Financial Transaction types', type: :request do
|
||||
describe Api::V1::FinancialTransactionTypesController do
|
||||
include ApiHelper
|
||||
|
||||
path '/financial_transaction_types' do
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Financial Transaction', type: :request do
|
||||
describe Api::V1::FinancialTransactionsController do
|
||||
include ApiHelper
|
||||
let!(:finance_user) { create(:user, groups: [create(:workgroup, role_finance: true)]) }
|
||||
let!(:api_scopes) { ['finance:read', 'finance:write'] }
|
||||
let(:api_access_token) { create(:oauth2_access_token, resource_owner_id: finance_user.id, scopes: api_scopes&.join(' ')).token }
|
||||
let(:api_access_token) do
|
||||
create(:oauth2_access_token, resource_owner_id: finance_user.id, scopes: api_scopes&.join(' ')).token
|
||||
end
|
||||
let(:financial_transaction) { create(:financial_transaction, user: user) }
|
||||
|
||||
path '/financial_transactions' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Navigation', type: :request do
|
||||
describe Api::V1::NavigationsController do
|
||||
include ApiHelper
|
||||
|
||||
path '/navigation' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Order Articles', type: :request do
|
||||
describe Api::V1::OrderArticlesController do
|
||||
include ApiHelper
|
||||
|
||||
path '/order_articles' do
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Orders', type: :request do
|
||||
describe Api::V1::OrdersController do
|
||||
include ApiHelper
|
||||
let(:api_scopes) { ['orders:read'] }
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'User', type: :request do
|
||||
describe 'User' do
|
||||
include ApiHelper
|
||||
|
||||
let(:api_scopes) { ['finance:user'] }
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:other_user2) { create :user }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:other_user2) { create(:user) }
|
||||
let(:ft) { create(:financial_transaction, user: user, ordergroup: user.ordergroup) }
|
||||
|
||||
before do
|
||||
|
|
@ -27,7 +27,9 @@ describe 'User', type: :request do
|
|||
}
|
||||
}
|
||||
|
||||
let(:financial_transaction) { { amount: 3, financial_transaction_type_id: create(:financial_transaction_type).id, note: 'lirum larum' } }
|
||||
let(:financial_transaction) do
|
||||
{ amount: 3, financial_transaction_type_id: create(:financial_transaction_type).id, note: 'lirum larum' }
|
||||
end
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'User', type: :request do
|
||||
describe 'User' do
|
||||
include ApiHelper
|
||||
|
||||
let(:api_scopes) { ['group_orders:user'] }
|
||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||
let(:other_user2) { create :user }
|
||||
let(:user) { create(:user, groups: [create(:ordergroup)]) }
|
||||
let(:other_user2) { create(:user) }
|
||||
let(:order) { create(:order, article_count: 4) }
|
||||
let(:order_articles) { order.order_articles }
|
||||
let(:group_order) { create :group_order, ordergroup: user.ordergroup, order_id: order.id }
|
||||
let(:goa) { create :group_order_article, group_order: group_order, order_article: order_articles.first }
|
||||
let(:group_order) { create(:group_order, ordergroup: user.ordergroup, order_id: order.id) }
|
||||
let(:goa) { create(:group_order_article, group_order: group_order, order_article: order_articles.first) }
|
||||
|
||||
before do
|
||||
goa
|
||||
|
|
@ -134,11 +134,12 @@ describe 'User', type: :request do
|
|||
|
||||
response 401, 'not logged-in' do
|
||||
schema '$ref' => '#/components/schemas/Error401'
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName
|
||||
run_test!
|
||||
end
|
||||
|
||||
response 403, 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
|
||||
response 403,
|
||||
'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
|
||||
let(:api_scopes) { ['none'] }
|
||||
schema '$ref' => '#/components/schemas/Error403'
|
||||
run_test!
|
||||
|
|
@ -180,7 +181,8 @@ describe 'User', type: :request do
|
|||
|
||||
it_handles_invalid_token_with_id
|
||||
|
||||
response 403, 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
|
||||
response 403,
|
||||
'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
|
||||
let(:api_scopes) { ['none'] }
|
||||
schema '$ref' => '#/components/schemas/Error403'
|
||||
run_test!
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'User', type: :request do
|
||||
describe 'User' do
|
||||
include ApiHelper
|
||||
|
||||
path '/user' do
|
||||
|
|
@ -8,9 +8,9 @@ describe 'User', type: :request do
|
|||
tags 'User'
|
||||
produces 'application/json'
|
||||
let(:api_scopes) { ['user:read'] }
|
||||
let(:other_user1) { create :user }
|
||||
let(:user) { create :user }
|
||||
let(:other_user2) { create :user }
|
||||
let(:other_user1) { create(:user) }
|
||||
let(:user) { create(:user) }
|
||||
let(:other_user2) { create(:user) }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object,
|
||||
|
|
@ -52,7 +52,7 @@ describe 'User', type: :request do
|
|||
get 'financial summary about the currently logged-in user' do
|
||||
tags 'User', 'Financial Transaction'
|
||||
produces 'application/json'
|
||||
let(:user) { create :user, :ordergroup }
|
||||
let(:user) { create(:user, :ordergroup) }
|
||||
let(:api_scopes) { ['finance:user'] }
|
||||
FinancialTransactionClass.create(name: 'TestTransaction')
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
ENV["FOODSOFT_APP_CONFIG"] ||= 'spec/app_config.yml' # load special foodsoft config
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
ENV['FOODSOFT_APP_CONFIG'] ||= 'spec/app_config.yml' # load special foodsoft config
|
||||
require_relative 'support/coverage' # needs to be first
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require File.expand_path('../config/environment', __dir__)
|
||||
require 'rspec/rails'
|
||||
require 'capybara/rails'
|
||||
require 'capybara/apparition'
|
||||
|
|
@ -17,17 +17,17 @@ end
|
|||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
RSpec.configure do |config|
|
||||
# We use capybara with webkit, and need database_cleaner
|
||||
config.before(:each) do
|
||||
config.before do
|
||||
DatabaseCleaner.strategy = (RSpec.current_example.metadata[:js] ? :truncation : :transaction)
|
||||
DatabaseCleaner.start
|
||||
# clean slate mail queues, not sure why needed - https://github.com/rspec/rspec-rails/issues/661
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
config.after(:each) do
|
||||
config.after do
|
||||
DatabaseCleaner.clean
|
||||
# Need to clear cache for RailsSettings::CachedSettings
|
||||
Rails.cache.clear
|
||||
|
|
@ -35,7 +35,7 @@ RSpec.configure do |config|
|
|||
|
||||
# reload foodsoft configuration, so that tests can use FoodsoftConfig.config[:foo]=x
|
||||
# without messing up tests run after that
|
||||
config.before(:each) do
|
||||
config.before do
|
||||
FoodsoftConfig.init
|
||||
FoodsoftConfig.init_mailing
|
||||
end
|
||||
|
|
@ -49,7 +49,7 @@ RSpec.configure do |config|
|
|||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = "random"
|
||||
config.order = 'random'
|
||||
|
||||
config.include SpecTestHelper, type: :controller
|
||||
config.include SessionHelper, type: :feature
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ module ApiHelper
|
|||
included do
|
||||
let(:user) { create(:user) }
|
||||
let(:api_scopes) { [] } # empty scopes for stricter testing (in reality this would be default_scopes)
|
||||
let(:api_access_token) { create(:oauth2_access_token, resource_owner_id: user.id, scopes: api_scopes&.join(' ')).token }
|
||||
let(:Authorization) { "Bearer #{api_access_token}" }
|
||||
let(:api_access_token) do
|
||||
create(:oauth2_access_token, resource_owner_id: user.id, scopes: api_scopes&.join(' ')).token
|
||||
end
|
||||
let(:Authorization) { "Bearer #{api_access_token}" } # rubocop:disable RSpec/VariableName
|
||||
|
||||
def self.it_handles_invalid_token
|
||||
context 'with invalid access token' do
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName
|
||||
|
||||
response 401, 'not logged-in' do
|
||||
schema '$ref' => '#/components/schemas/Error401'
|
||||
|
|
@ -20,7 +22,7 @@ module ApiHelper
|
|||
|
||||
def self.it_handles_invalid_token_with_id
|
||||
context 'with invalid access token' do
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName
|
||||
let(:id) { 42 } # id doesn't matter here
|
||||
|
||||
response 401, 'not logged-in' do
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module ApiOAuth
|
|||
included do
|
||||
let(:user) { build(:user) }
|
||||
let(:api_scopes) { [] } # empty scopes for stricter testing (in reality this would be default_scopes)
|
||||
let(:api_access_token) { double(:acceptable? => true, :accessible? => true, scopes: api_scopes) }
|
||||
let(:api_access_token) { double(acceptable?: true, accessible?: true, scopes: api_scopes) }
|
||||
before { allow(controller).to receive(:doorkeeper_token) { api_access_token } }
|
||||
|
||||
before { allow(controller).to receive(:current_user) { user } }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ if ENV['COVERAGE'] or ENV['COVERALLS']
|
|||
|
||||
# slightly tweaked coverage reporting
|
||||
def cov_no_plugins(source_file, path)
|
||||
source_file.filename =~ /#{path}/ and not source_file.filename =~ /\/lib\/foodsoft_.*\//
|
||||
source_file.filename =~ /#{path}/ and !(source_file.filename =~ %r{/lib/foodsoft_.*/})
|
||||
end
|
||||
SimpleCov.start do
|
||||
add_filter '/spec/'
|
||||
|
|
@ -21,6 +21,6 @@ if ENV['COVERAGE'] or ENV['COVERALLS']
|
|||
add_group 'Helpers' do |s| cov_no_plugins s, '/app/helpers/' end
|
||||
add_group 'Documents' do |s| cov_no_plugins s, '/app/documents/' end
|
||||
add_group 'Libraries' do |s| cov_no_plugins s, '/lib/' end
|
||||
add_group 'Plugins' do |s| s.filename =~ /\/lib\/foodsoft_.*\// end
|
||||
add_group 'Plugins' do |s| s.filename =~ %r{/lib/foodsoft_.*/} end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module Faker
|
|||
class Unit
|
||||
class << self
|
||||
def unit
|
||||
['kg', '1L', '100ml', 'piece', 'bunch', '500g'].sample
|
||||
%w[kg 1L 100ml piece bunch 500g].sample
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# @see http://stackoverflow.com/a/11048669/2866660
|
||||
def scrolldown
|
||||
page.execute_script "window.scrollBy(0,10000)"
|
||||
page.execute_script 'window.scrollBy(0,10000)'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
module SessionHelper
|
||||
def login(user = nil, password = nil)
|
||||
visit login_path
|
||||
user = FactoryBot.create :user if user.nil?
|
||||
user = FactoryBot.create(:user) if user.nil?
|
||||
if user.instance_of? ::User
|
||||
nick, password = user.nick, user.password
|
||||
nick = user.nick
|
||||
password = user.password
|
||||
else
|
||||
nick = user
|
||||
end
|
||||
fill_in 'nick', :with => nick
|
||||
fill_in 'password', :with => password
|
||||
fill_in 'nick', with: nick
|
||||
fill_in 'password', with: password
|
||||
find('input[type=submit]').click
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ ActiveSupport.on_load(:after_initialize) do
|
|||
# But take care when designing tests using the shared database.
|
||||
SharedSupplier.establish_connection Rails.env.to_sym
|
||||
SharedArticle.establish_connection Rails.env.to_sym
|
||||
# hack for different structure of shared database
|
||||
# HACK: for different structure of shared database
|
||||
SharedArticle.class_eval do
|
||||
belongs_to :supplier, class_name: 'SharedSupplier'
|
||||
alias_attribute :number, :order_number
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ RSpec.configure do |config|
|
|||
currentPage: { type: :integer },
|
||||
pageSize: { type: :integer }
|
||||
},
|
||||
required: %w(recordCount pageCount currentPage pageSize)
|
||||
required: %w[recordCount pageCount currentPage pageSize]
|
||||
},
|
||||
Order: {
|
||||
type: :object,
|
||||
|
|
@ -127,7 +127,8 @@ RSpec.configure do |config|
|
|||
description: 'number of units available (only present on stock articles)'
|
||||
}
|
||||
},
|
||||
required: %w[id name supplier_id supplier_name unit unit_quantity note manufacturer origin article_category_id]
|
||||
required: %w[id name supplier_id supplier_name unit unit_quantity note manufacturer origin
|
||||
article_category_id]
|
||||
},
|
||||
OrderArticle: {
|
||||
type: :object,
|
||||
|
|
@ -396,7 +397,7 @@ RSpec.configure do |config|
|
|||
description: 'link'
|
||||
},
|
||||
items: {
|
||||
'$ref': "#/components/schemas/Navigation"
|
||||
'$ref': '#/components/schemas/Navigation'
|
||||
}
|
||||
},
|
||||
required: ['name'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue