Merge branch 'master' of github.com:foodcoops/foodsoft into feature/tw_automatic_group_order_invoice_generation
This commit is contained in:
commit
d37a75262d
4 changed files with 19 additions and 1 deletions
2
Gemfile
2
Gemfile
|
@ -85,6 +85,8 @@ group :development do
|
||||||
|
|
||||||
# Get infos when not using proper eager loading
|
# Get infos when not using proper eager loading
|
||||||
gem 'bullet'
|
gem 'bullet'
|
||||||
|
# Display Active Record queries as tables in the console
|
||||||
|
gem 'table_print'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
|
@ -513,6 +513,7 @@ GEM
|
||||||
sqlite3 (1.3.13)
|
sqlite3 (1.3.13)
|
||||||
sqlite3-ruby (1.3.3)
|
sqlite3-ruby (1.3.3)
|
||||||
sqlite3 (>= 1.3.3)
|
sqlite3 (>= 1.3.3)
|
||||||
|
table_print (1.5.7)
|
||||||
temple (0.8.2)
|
temple (0.8.2)
|
||||||
therubyracer (0.12.3)
|
therubyracer (0.12.3)
|
||||||
libv8 (~> 3.16.14.15)
|
libv8 (~> 3.16.14.15)
|
||||||
|
@ -646,6 +647,7 @@ DEPENDENCIES
|
||||||
spreadsheet
|
spreadsheet
|
||||||
sprockets (< 4)
|
sprockets (< 4)
|
||||||
sqlite3 (~> 1.3.6)
|
sqlite3 (~> 1.3.6)
|
||||||
|
table_print
|
||||||
therubyracer
|
therubyracer
|
||||||
twitter-bootstrap-rails (~> 2.2.8)
|
twitter-bootstrap-rails (~> 2.2.8)
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Ordergroup < Group
|
||||||
|
|
||||||
after_create :update_stats!
|
after_create :update_stats!
|
||||||
|
|
||||||
scope :active, -> { joins(:orders).where(orders: { starts: (Time.now.months_ago(3)..) }).group(:id) }
|
scope :active, -> { joins(:orders).where(orders: { starts: (Time.now.months_ago(3)..Time.now) }).group(:id) }
|
||||||
|
|
||||||
def contact
|
def contact
|
||||||
"#{contact_phone} (#{contact_person})"
|
"#{contact_phone} (#{contact_person})"
|
||||||
|
|
|
@ -8,6 +8,20 @@ describe Ordergroup do
|
||||||
let(:ftt3) { create :financial_transaction_type, financial_transaction_class: ftc2 }
|
let(:ftt3) { create :financial_transaction_type, financial_transaction_class: ftc2 }
|
||||||
let(:user) { create :user, groups: [create(:ordergroup)] }
|
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||||
|
|
||||||
|
it 'shows no active ordergroups when all orders are older than 3 months' do
|
||||||
|
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
|
||||||
|
user.ordergroup.group_orders.create!(order: order)
|
||||||
|
|
||||||
|
expect(Ordergroup.active).not_to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
context 'with financial transactions' do
|
context 'with financial transactions' do
|
||||||
before do
|
before do
|
||||||
og = user.ordergroup
|
og = user.ordergroup
|
||||||
|
|
Loading…
Reference in a new issue