Permalink
Browse files

add goods_cat_fee_config function

  • Loading branch information...
1 parent 4c49837 commit 4a65b3c8ddedb4f9670eb46f6341c4af995d0d8c @chengdh committed Apr 12, 2012
@@ -4,6 +4,7 @@ class GoodsCatFeeConfig < ActiveRecord::Base
belongs_to :from_org,:class_name => "Org"
belongs_to :to_org,:class_name => "Org"
has_many :goods_cat_fee_config_lines,:dependent => :destroy
- has_many :goods_cat,:through => :goos_cat_fee_config_lines
- validates :from_org,:to_org,:presence => true
+ has_many :goods_cats,:through => :goos_cat_fee_config_lines
+ validates :from_org,:to_org,:goods_cat_fee_config_lines,:presence => true
+ validates :to_org_id,:uniqueness => {:scope => :from_org_id}
end
@@ -3,5 +3,5 @@
class GoodsCatFeeConfigLine < ActiveRecord::Base
belongs_to :goods_cat_fee_config
belongs_to :goods_cat
- validates :goods_cat_fee_config,:goods_cat,:presence => true
+ validates :goods_cat,:presence => true
end
@@ -7,4 +7,103 @@
describe GoodsCatFeeConfigsController do
login_admin
render_views
+
+ describe "GET index" do
+ before(:each) do
+ @gc ||= Factory(:load_list_with_bills)
+ end
+
+ it "should be success" do
+ get :index
+ response.should be_success
+ end
+ end
+
+ describe "GET show" do
+ before(:each) do
+ @gc ||= Factory(:load_list_with_bills)
+ end
+
+ it "should render 'show'" do
+ get :show, :id => @gc
+ response.should render_template('show')
+ end
+ end
+
+ describe "GET new" do
+ it "should be sucesss" do
+ get :new
+ response.should be_success
+ end
+ it "should render template 'new'" do
+ get :new
+ response.should render_template('new')
+ end
+ end
+
+ describe "POST create" do
+ before(:each) do
+ @computer_bill = Factory(:computer_bill)
+ end
+ describe "with valid params" do
+ it "the gc should success create" do
+ lambda do
+ post :create,:gc => {:from_org_id => Factory(:zz),:to_org_id => Factory(:ay),:bill_no => "bill_no"},:bill_ids=> [@computer_bill.id]
+ end.should change(LoadList,:count).by(1)
+ end
+
+ it "redirects to the created gc" do
+ post :create,:gc => {:from_org_id => Factory(:zz),:to_org_id => Factory(:ay),:bill_no => "bill_no"},:bill_ids => [@computer_bill.id]
+ response.should redirect_to(assigns[:gc])
+ end
+ end
+
+ describe "with invalid params" do
+ it "re-renders the 'new' template" do
+ post :create, :gc => {:bill_no => "bill_no"},:bill_ids => [@computer_bill.id]
+ response.should render_template('new')
+ end
+ end
+ end
+
+
+ describe "DELETE destroy" do
+ before(:each) do
+ @gc ||= Factory(:load_list_with_bills)
+ end
+
+ it "destroys the requested gc" do
+ lambda do
+ delete :destroy ,:id => @gc
+ end.should change(LoadList,:count).by(-1)
+ end
+
+ it "redirects to the gcs list" do
+ delete :destroy, :id => @gc
+ response.should redirect_to(gcs_url)
+ end
+ end
+ #启动流程处理
+ describe "PUT process_handle" do
+ it "gc state should become shipped" do
+ @gc ||= Factory(:load_list_with_bills)
+ put :process_handle,:id =>@gc
+ response.should be_success
+ end
+
+ it "gc state should become 'reached' after reach process" do
+ shipped_list = Factory(:gc_shipped)
+ put :process_handle,:id =>shipped_list
+ response.should be_success
+ end
+ end
+ #创建实际装车清单
+ describe "GET build act_gc" do
+ it "should be success" do
+ @gc ||= Factory(:load_list_with_bills)
+ get :build_act_gc,:id => @load_list
+ response.should be_success
+ end
+ end
+
end
@@ -1,5 +1,4 @@
# -*- encoding : utf-8 -*-
-#coding: utf-8
require 'spec_helper'
describe LoadListsController do
View
@@ -605,3 +605,8 @@
gcfc.association :from_org,:factory => :zz
gcfc.association :to_org,:factory => :ay
end
+Factory.define :goods_cat_fee_config_line do |line|
+ line.bottom_price 11.12
+ line.unit_price 14
+ line.association :goods_cat,:factory => :goods_cat
+end
@@ -3,6 +3,7 @@
describe GoodsCatFeeConfig do
before :each do
@goods_cat_fee_config = Factory.build(:goods_cat_fee_config)
+ @goods_cat_fee_config.goods_cat_fee_config_lines << Factory.build(:goods_cat_fee_config_line)
end
it "should save goods_cat_fee_config success" do
@goods_cat_fee_config.save!

0 comments on commit 4a65b3c

Please sign in to comment.