diff options
author | Brendan Deere <brendangdeere@gmail.com> | 2016-10-07 11:17:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 11:17:21 -0700 |
commit | 7b87a666bf9542df95a82c076c1fa1fe07230a52 (patch) | |
tree | 5804d5fe9f8f3558f3b302df5de7dbb219910974 /spec | |
parent | 165af7ad539286ea398f1097d2e8f0dd51d2c1a9 (diff) | |
parent | 9a7ae3051564ff336da6b10c4557b8b6c0678adb (diff) |
Merge pull request #87 from brendandeere/subs_search
Subs search
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/solidus_subscriptions/subscription_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/solidus_subscriptions/subscription_spec.rb b/spec/models/solidus_subscriptions/subscription_spec.rb index 37dd31a..69ca11b 100644 --- a/spec/models/solidus_subscriptions/subscription_spec.rb +++ b/spec/models/solidus_subscriptions/subscription_spec.rb @@ -171,4 +171,37 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do it { is_expected.to eq 'success' } end end + + describe '.ransackable_scopes' do + subject { described_class.ransackable_scopes } + it { is_expected.to match_array [:in_processing_state] } + end + + describe '.in_processing_state' do + subject { described_class.in_processing_state(state) } + + let!(:new_subs) { create_list :subscription, 2 } + let!(:failed_subs) { create_list(:installment, 2, :failed).map(&:subscription) } + let!(:success_subs) { create_list(:installment, 2, :success).map(&:subscription) } + + context 'successfull subscriptions' do + let(:state) { :success } + it { is_expected.to match_array success_subs } + end + + context 'failed subscriptions' do + let(:state) { :failed } + it { is_expected.to match_array failed_subs } + end + + context 'new subscriptions' do + let(:state) { :pending } + it { is_expected.to match_array new_subs } + end + end + + describe '.processing_states' do + subject { described_class.processing_states } + it { is_expected.to match_array [:pending, :success, :failed] } + end end |