From 2e5b3add3c7572a3bd09d3a57f699c323d54708d Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Mon, 1 Dec 2014 18:46:05 -0600 Subject: [PATCH] VRFS-2480: Recurly specs to verify placing an order. --- web/spec/managers/recurly_client_spec.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/web/spec/managers/recurly_client_spec.rb b/web/spec/managers/recurly_client_spec.rb index e15b5fb6e..8b1825cba 100644 --- a/web/spec/managers/recurly_client_spec.rb +++ b/web/spec/managers/recurly_client_spec.rb @@ -5,11 +5,12 @@ describe RecurlyClient do #let(:client) { RecurlyClient.new } before :all do - @client = RecurlyClient.new - @user = FactoryGirl.create(:user) + @client = RecurlyClient.new + @jamtrack = FactoryGirl.create(:jam_track) end before(:each) do + @user = FactoryGirl.create(:user) @billing_info = {} @billing_info[:first_name] = @user.first_name @billing_info[:last_name] = @user.last_name @@ -85,5 +86,22 @@ describe RecurlyClient do found.should_not be_nil found.state.should eq('closed') end + + it "can place order" do + @client.find_or_create_account(@user, @billing_info) + expect{@client.place_order(@user, @jamtrack)}.not_to raise_error() + subs = @client.get_account(@user).subscriptions + subs.should_not be_nil + subs.should have(1).items + @user.jam_track_rights.should_not be_nil + @user.jam_track_rights.should have(1).items + @user.jam_track_rights.last.jam_track.id.should eq(@jamtrack.id) + end + + it "detects error on double order" do + @client.find_or_create_account(@user, @billing_info) + expect{@client.place_order(@user, @jamtrack)}.not_to raise_error() + expect{@client.place_order(@user, @jamtrack)}.to raise_error(RecurlyClientError) + end end