summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-21 06:57:11 -0700
committermo khan <mo@mokhan.ca>2014-02-21 06:57:11 -0700
commitbd1b2145347c25ee6fba54e306d5e11749e511d0 (patch)
tree6e4f8b450cfdfb8f97ef3c1d024fa23f0822fa36 /spec
parentcaaba52706c1aaba8c0831256d597ec85c473dfc (diff)
define relationship between company and licenses and return active licenses.
Diffstat (limited to 'spec')
-rw-r--r--spec/models/company_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/company_spec.rb b/spec/models/company_spec.rb
new file mode 100644
index 0000000..f9e0a61
--- /dev/null
+++ b/spec/models/company_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+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 ) }
+
+ it "returns all the licenses that are active" do
+ licenses = company.status(LicenseStatus::ACTIVE)
+ licenses.count.should == 0
+ licenses.should include(active_license)
+ end
+ end
+end