add order uuid generation spec, add skeleton for PreorderController spec

This commit is contained in:
Nikalyukin Mikhail
2012-12-01 14:08:23 +02:00
parent 34f7a42b51
commit c67e5ec5bf
3 changed files with 22 additions and 9 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ config/settings/*.local.yml
config/environments/*.local.yml
*.sublime-workspace
.rvmrc

View File

@@ -0,0 +1,10 @@
require 'spec_helper'
describe PreorderController do
[:index, :checkout].each do |method|
it "should get #{method}" do
get method
response.should be_success
end
end
end

View File

@@ -2,17 +2,19 @@ describe Order do
context "attributes" do
[:address_one, :address_two, :city, :country, :number, :state, :status,
:token, :transaction_id, :zip, :shipping, :tracking_number, :name,
[:address_one, :address_two, :city, :country, :number, :state, :status,
:token, :transaction_id, :zip, :shipping, :tracking_number, :name,
:price, :phone, :expiration
].each do |property|
it { should allow_mass_assignment_of property }
end
it { should allow_mass_assignment_of property }
end
it { should_not allow_mass_assignment_of :uuid }
it "generates UUID before validation on_create" do
# TODO
@order = Order.new
@order.valid?
@order.uuid.should_not be_nil
end
it { Order.primary_key.should == 'uuid' }
@@ -140,16 +142,16 @@ describe Order do
end
context "no orders" do
before do
ActiveRecord::Relation.any_instance.stub(:first).and_return(nil)
Order.stub!(:count).and_return(0)
end
it "doesn't break if there's no orders" do
expect { Order.next_order_number }.to_not raise_error
end
it "returns 1 if there's no orders" do
Order.next_order_number.should == 1
end
@@ -177,7 +179,7 @@ describe Order do
it "multiplies the #current with price from Settings" do
Order.stub(:current).and_return(4)
Settings.stub(:price).and_return(6)
Order.revenue.should == 24
end
end