Sha256: 211e682c95701c58c20bfaf937f6897ea7c83f81b27c6a977bfa0ebd92c4a994
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
require 'rails_helper' RSpec.describe TbCommerce::ProductsController, type: :controller do before(:each) do @category = FactoryGirl.create(:tb_commerce_category) end describe "GET #index" do it "returns http success" do get :index, :category_id => @category.slug expect(response).to have_http_status(:success) end it 'returns a 404' do get :index, :category_id => 'fail' expect(response.status).to eq(404) end end describe 'search' do it 'should search the products' do product = FactoryGirl.create(:tb_commerce_product) get :search, :search => product.title expect(assigns(:products)).to eq([product]) end end describe "GET #show" do it "returns http success" do product = FactoryGirl.create(:tb_commerce_product, :category => @category) get :show, :category_id => @category.slug, :id => product.slug expect(response).to have_http_status(:success) end it 'returns a 404' do get :show, :category_id => @category.slug, :id => 'fail' expect(response.status).to eq(404) end end end
Version data entries
3 entries across 3 versions & 1 rubygems