mirror of
https://github.com/apigy/selfstarter.git
synced 2026-01-09 06:17:55 -05:00
add order uuid generation spec, add skeleton for PreorderController spec
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ config/settings/*.local.yml
|
||||
config/environments/*.local.yml
|
||||
|
||||
*.sublime-workspace
|
||||
.rvmrc
|
||||
10
spec/controllers/preorder_controller_spec.rb
Normal file
10
spec/controllers/preorder_controller_spec.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user