From f3e790b4817279df9c967016746adaebc9c081f7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 5 Jun 2017 01:32:33 +0300 Subject: [PATCH] Refactor price statuses #522 --- app/models/billing/price.rb | 30 +++++++++++++-------------- spec/models/billing/price_spec.rb | 34 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/app/models/billing/price.rb b/app/models/billing/price.rb index fd8dc2275c..2475363b4c 100644 --- a/app/models/billing/price.rb +++ b/app/models/billing/price.rb @@ -23,27 +23,27 @@ def self.operation_categories def self.durations [ - '3 mons', - '6 mons', - '9 mons', - '1 year', - '2 years', - '3 years', - '4 years', - '5 years', - '6 years', - '7 years', - '8 years', - '9 years', - '10 years', + '3 mons', + '6 mons', + '9 mons', + '1 year', + '2 years', + '3 years', + '4 years', + '5 years', + '6 years', + '7 years', + '8 years', + '9 years', + '10 years', ] end def self.statuses - %w[pending effective expired] + %w[upcoming effective expired] end - def self.pending + def self.upcoming where("#{attribute_alias(:effect_time)} > ?", Time.zone.now) end diff --git a/spec/models/billing/price_spec.rb b/spec/models/billing/price_spec.rb index 744f2be26b..7ee2277cc9 100644 --- a/spec/models/billing/price_spec.rb +++ b/spec/models/billing/price_spec.rb @@ -24,19 +24,19 @@ describe '::durations', db: false do it 'returns durations' do durations = [ - '3 mons', - '6 mons', - '9 mons', - '1 year', - '2 years', - '3 years', - '4 years', - '5 years', - '6 years', - '7 years', - '8 years', - '9 years', - '10 years', + '3 mons', + '6 mons', + '9 mons', + '1 year', + '2 years', + '3 years', + '4 years', + '5 years', + '6 years', + '7 years', + '8 years', + '9 years', + '10 years', ] expect(described_class.durations).to eq(durations) @@ -45,11 +45,11 @@ describe '::statuses', db: false do it 'returns statuses' do - expect(described_class.statuses).to eq(%w[pending effective expired]) + expect(described_class.statuses).to eq(%w[upcoming effective expired]) end end - describe '::pending' do + describe '::upcoming' do before :example do travel_to Time.zone.parse('05.07.2010 00:00') @@ -57,8 +57,8 @@ create(:price, id: 2, effect_time: Time.zone.parse('05.07.2010 00:01')) end - it 'returns pending' do - expect(described_class.pending.ids).to eq([2]) + it 'returns upcoming' do + expect(described_class.upcoming.ids).to eq([2]) end end