Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Chargify::Coupon.find_all_by_product_family_id
- Add coupon specs to cover some existing functionality
- Loading branch information
1 parent
f61987a
commit 5b8ef66
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
require 'spec_helper' | |||
|
|||
describe Chargify::Coupon do | |||
context '.find_by_product_family_id_and_code' do | |||
let(:existing_coupon) { Factory.build(:coupon, :code => '20OFF') } | |||
|
|||
before do | |||
FakeWeb.register_uri(:get, "#{test_domain}/product_families/10/coupons/lookup.xml?code=#{existing_coupon.code}", :body => existing_coupon.attributes.to_xml) | |||
end | |||
|
|||
it "finds the correct coupon by product family and code" do | |||
Chargify::Coupon.find_by_product_family_id_and_code(10, '20OFF').should == existing_coupon | |||
end | |||
|
|||
it "is an instance of Chargify::Coupon" do | |||
coupon = Chargify::Coupon.find_by_product_family_id_and_code(10, '20OFF') | |||
coupon.should be_instance_of(Chargify::Coupon) | |||
end | |||
end | |||
|
|||
context '.find_all_by_product_family_id' do | |||
let(:coupon_1) { Factory.build(:coupon, :product_family_id => 5) } | |||
let(:coupon_2) { Factory.build(:coupon, :product_family_id => 5) } | |||
|
|||
before do | |||
FakeWeb.register_uri(:get, "#{test_domain}/product_families/5/coupons.xml", :body => [coupon_1.attributes, coupon_2.attributes].to_xml) | |||
end | |||
|
|||
it "returns all of the coupons for a product family" do | |||
coupons = Chargify::Coupon.find_all_by_product_family_id(5) | |||
coupons.count.should == 2 | |||
coupons.map{|c| c.should be_instance_of(Chargify::Coupon)} | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters