From 5d937942170c81bcb2304cab1c71eefda48e4e35 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 21 Feb 2014 07:04:37 -0700 Subject: move status filtering behaviour to separate status classes. --- spec/models/company_spec.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/models/company_spec.rb b/spec/models/company_spec.rb index f9e0a61..4b5f7ce 100644 --- a/spec/models/company_spec.rb +++ b/spec/models/company_spec.rb @@ -4,14 +4,23 @@ describe Company do describe ".status" do let(:company) { Company.create } let(:today) { DateTime.now } - let(:active_license) { company.licenses.create(issued_at: 1.day.ago, expired_at: 1.day.from_now) } - let(:expired_license) { company.licenses.create(issued_at: 2.days.ago, expired_at: 1.day.ago ) } - let(:pending_license) { company.licenses.create(issued_at: 2.days.from_now, expired_at: 3.days.from_now ) } + let!(:active_license) { company.licenses.create(issued_at: 1.day.ago, expired_at: 1.day.from_now) } + let!(:expired_license) { company.licenses.create(issued_at: 2.days.ago, expired_at: 1.day.ago ) } + let!(:pending_license) { company.licenses.create(issued_at: 2.days.from_now, expired_at: 3.days.from_now ) } it "returns all the licenses that are active" do licenses = company.status(LicenseStatus::ACTIVE) - licenses.count.should == 0 + licenses.count.should == 1 licenses.should include(active_license) end + + it "returns all expired licenses" do + licenses = company.status(LicenseStatus::EXPIRED) + licenses.count.should == 1 + licenses.should include(expired_license) + end + + pending "returns all confidential licenses" do + end end end -- cgit v1.2.3