# POST /bumonsdef create@bumon = Bumon.new(params[:bumon])bumonsyozoku = Bumonsyozoku.newrespond_to do |format|if @bumon.savebumonsyozoku.bumon_id = @bumon.idbumonsyozoku.syozokbumon_id = @bumon.idbumonsyozoku.syozokulevel = 0bumonsyozoku.saveflag = params[:bumonsyozoku]["syozokubumon_id"]if flag !=nil && flag !=""parent_bumon = Bumonsyozoku.find(:all, :conditions => "bumon_id = #{flag}")parent_bumon.each{|x| y=Bumonsyozoku.new ; y.bumon_id = @bumon.id; y.syozokulevel = x.syozokulevel + 1;y.syozokbumon_id=x.syozokbumon_id; y.save}endflash[:notice] = 'Bumon was successfully created.'format.ext_json { render :json => @bumon.to_ext_json(:success => true) }elseformat.ext_json { render :json => @bumon.to_ext_json(:success => false) }endendend
1 回答

吃雞游戲
TA貢獻(xiàn)1829條經(jīng)驗 獲得超7個贊
rsepc 的話
describe 'bumons測試' do
before do
post :bumons,{ #你的測試數(shù)據(jù)}
end
it '邏輯測試' do
#你的邏輯
end
it '返回數(shù)據(jù)測試' do
#你期待的返回數(shù)據(jù)
end
end
- 1 回答
- 0 關(guān)注
- 91 瀏覽
添加回答
舉報
0/150
提交
取消