为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

皈依舞 2023-03-15 19:15:42
# 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贡献1829条经验 获得超7个赞

rsepc 的话
describe 'bumons测试' do
before do
post :bumons,{ #你的测试数据}
end

it '逻辑测试' do
#你的逻辑
end

it '返回数据测试' do
#你期待的返回数据
end
end

查看完整回答
反对 回复 2023-03-18
  • 1 回答
  • 0 关注
  • 55 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信