diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-21 23:50:52 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-21 23:50:52 -0700 |
| commit | 842ee349392844ff08e818151a8eb5ca00b67d10 (patch) | |
| tree | df0566008cf97f05e45930e023106ea14646356e /spec | |
| parent | 39fc3e184c1c185ffc9fc1f17bd19c5a8d9d0106 (diff) | |
refactor specs to target the filter licenses method.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/company_spec.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/spec/models/company_spec.rb b/spec/models/company_spec.rb index 1acef1c..4f0a322 100644 --- a/spec/models/company_spec.rb +++ b/spec/models/company_spec.rb @@ -1,29 +1,31 @@ require "spec_helper" describe Company do - describe ".status" do + describe "#filter_licenses_using" do let(:company) { Company.create } - let(:today) { DateTime.now } + let(:calgary) { Location.create(township: 'calgary') } + let(:edmonton) { Location.create(township: 'edmonton') } 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!(:confidential_license) { company.licenses.create(issued_at: 2.days.from_now, expired_at: 3.days.from_now, confidential: true) } + let!(:expired_license) { company.licenses.create(issued_at: 2.days.ago, expired_at: 1.day.ago, location: calgary) } + let!(:other_expired_license) { company.licenses.create(issued_at: 2.days.ago, expired_at: 1.day.ago, location: edmonton) } it "returns all the licenses that are active" do - licenses = company.status(LicenseStatus::ACTIVE) - licenses.count.should == 1 - licenses.should include(active_license) + results = company.filter_licenses_using(status: LicenseStatus::ACTIVE) + results.count.should == 1 + results.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) + results = company.filter_licenses_using(status: LicenseStatus::EXPIRED) + results.count.should == 2 + results.should include(expired_license) + results.should include(other_expired_license) end - it "returns all confidential licenses" do - licenses = company.status(LicenseStatus::CONFIDENTIAL) - licenses.count.should == 1 - licenses.should include(confidential_license) + it "returns expired licenses in township" do + results = company.filter_licenses_using(status: LicenseStatus::EXPIRED, township: 'edmonton') + results.count.should == 1 + results.should include(other_expired_license) end end end |
