検索機能のRspecをテストしようとしています.
これは私がこれまでに持っているものです.
def product_search
filter = ""
filter = filter + " and B.sku like '#{params[:sku]}%'" if params[:sku] && params[:sku] != ""
filter = filter + " and A.name like '#{params[:name]}%'" if params[:name] && params[:name] != ""
filter = filter + " and D.name like '#{params[:store_name]}%'" if params[:store_name] && params[:store_name] != ""
if params[:approved] == "0"
filter= filter + "and (A.is_approved = false And A.approved_by is NULL) "
elsif params[:approved] == "1"
filter= filter + "and A.is_approved = true "
elsif params[:approved] == "2"
filter= filter + " and (A.is_approved = false And A.approved_by is NOT NULL) "
end
@products=Product.seller_product_search(filter,current_user.store.id).paginate(:page => params[:page], :per_page => 10)
respond_to do |format|
format.html
format.js
end
end
このコードの rspec はどのように記述すればよいですか?