请教下面的这个方法的测试函数怎么写?

# POST /bumons
def create
@bumon = Bumon.new(params[:bumon])
bumonsyozoku = Bumonsyozoku.new

respond_to do |format|
if @bumon.save
bumonsyozoku.bumon_id = @bumon.id
bumonsyozoku.syozokbumon_id = @bumon.id
bumonsyozoku.syozokulevel = 0
bumonsyozoku.save
flag = 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}
end
flash[:notice] = 'Bumon was successfully created.'
format.ext_json { render :json => @bumon.to_ext_json(:success => true) }
else
format.ext_json { render :json => @bumon.to_ext_json(:success => false) }
end
end
end

皈依舞
浏览 56回答 1
1回答

吃鸡游戏

rsepc 的话describe 'bumons测试' dobefore dopost :bumons,{ #你的测试数据}endit '逻辑测试' do#你的逻辑endit '返回数据测试' do#你期待的返回数据endend
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Ruby