编辑操作的测试用例错误参数 id 不存在

问题描述

这是 line_items_controller.rb

<prososition>

测试编辑操作

  before_action :set_line_item,only: [:show,:edit,:update,:destroy]

 def edit
  end
  private
    # Use callbacks to share common setup or constraints between actions.
    def set_line_item
      @line_item = LineItem.find(params[:id])
    end

错误

  describe "GET /edit" do
    let!(:user) { create(:user) }
    before do
      sign_in(user) # Factory Bot user
    end
    it "render a successful response" do
      line_item = build(:line_item)
      order = build(:order)   
      product = build(:product)
      line_item.order_id = order
      line_item.product_id = product
      line_item.cart_id = 1
      line_item.save
      get edit_line_item_url(line_item)
      expect(response).to be_successful
    end
  end

当我传入 url 时,id 166 存在。 谁能帮我解决这个问题。 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)