Skip to content

Instantly share code, notes, and snippets.

@ethangunderson
Created December 8, 2009 20:19
Show Gist options
  • Save ethangunderson/251961 to your computer and use it in GitHub Desktop.
Save ethangunderson/251961 to your computer and use it in GitHub Desktop.
def finalized?
clicked_finalized? && (total_final_invoice.blank? || charged_on)
end
describe Cart, 'when checking if a cart is finalized' do
before(:each) do
@cart = Cart.new
@cart.stub!(:clicked_finalized?).and_return(true)
@cart.stub!(:total_final_invoice).and_return("10.50")
end
it 'will not be finalized if the customer has not clicked finalized' do
@cart.stub!(:clicked_finalized?).and_return(false)
@cart.should_not be_finalized
end
it 'will not be finalized if the final price is more than zero and the customer has not been charged' do
@cart.should_not be_finalized
end
it 'will be finalized if finalized is clicked and price is zero' do
@cart.stub!(:total_final_invoice).and_return("")
@cart.should be_finalized
end
it 'will be finalized if finalized is clicked and the customer is charged' do
@cart.stub!(:charged_on).and_return(Time.now)
@cart.should be_finalized
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment