Sha256: 7e7d344ec0a97b9060189ec7f8e390a88560b9c5e22d832b557e8860d75e7b55
Contents?: true
Size: 1.99 KB
Versions: 17
Compression:
Stored size: 1.99 KB
Contents
require 'test_helper' class OrderTest < Test::Unit::TestCase context 'Order' do should 'generate a collection of GeoCerts::Warnings' do order = Factory.build(:order, { :warnings => { :warning => [ {:code => '123', :message => 'testing'} ]} }) assert !order.warnings.empty? assert_equal 1, order.warnings.size assert order.warnings.all? { |warning| warning.kind_of?(GeoCerts::Warning) } end should 'accept a String for a CSR and assume it to be a CSR body when matches "-----BEGIN CERTIFICATE REQUEST-----"' do body = Factory.attributes_for(:csr)[:body] order = Factory.build(:order, :csr => body) assert_equal(body, order.csr.body) end should 'accept a String for a CSR and assume it to be a CSR body when matches "-----BEGIN NEW CERTIFICATE REQUEST-----"' do body = "-----BEGIN NEW CERTIFICATE REQUEST-----\nABCD1234\n-----END NEW CERTIFICATE REQUEST-----\n" order = Factory.build(:order, :csr => body) assert_equal(body, order.csr.body) end should 'raise an ArgumentError for an unrecognized CSR body string' do assert_raise(ArgumentError) do Factory.build(:order, :csr => 'BADBODY') end end should 'accept a GeoCerts::CSR for a CSR' do csr = Factory.build(:csr) order = Factory.build(:order, :csr => csr) assert_equal(csr, order.csr) end should 'accept a String for a Product and assume it to be a product SKU' do sku = Factory.attributes_for(:product)[:sku] GeoCerts::Product.stubs(:find).with(sku).returns(Factory.build(:product, :sku => sku)) order = Factory.build(:order, :product => sku) assert_not_nil(order.product) assert_equal(sku, order.product.sku) end should 'accept a GeoCerts::Product for a Product' do product = Factory.build(:product) order = Factory.build(:order, :product => product) assert_equal(product, order.product) end end end
Version data entries
17 entries across 17 versions & 1 rubygems