make specs green
This commit is contained in:
@@ -19,7 +19,7 @@ describe Suppliers::ProductCategoriesController, type: :controller do
|
||||
it "does not include product_categories from another supplier" do
|
||||
product_category1 = create :product_category, supplier: @supplier
|
||||
product_category2 = create :product_category
|
||||
get :index
|
||||
get :index, format: :json
|
||||
assigns(:product_categories).should eq([product_category1])
|
||||
end
|
||||
|
||||
@@ -28,29 +28,22 @@ describe Suppliers::ProductCategoriesController, type: :controller do
|
||||
describe "GET #show" do
|
||||
it "assigns the requested product_category to @product_category" do
|
||||
product_category = create :product_category, supplier: @supplier
|
||||
get :show, id: product_category
|
||||
get :show, id: product_category, format: :json
|
||||
assigns(:product_category).should eq(product_category)
|
||||
end
|
||||
|
||||
it "should not display a product_category of another supplier" do
|
||||
product_category = create :product_category
|
||||
get :show, id: product_category
|
||||
get :show, id: product_category, format: :json
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new product_category to @product_category" do
|
||||
get :new
|
||||
assigns(:product_category).should be_a ProductCategory
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid attributes" do
|
||||
it "creates a new product_category" do
|
||||
expect{
|
||||
post :create, product_category: valid_attributes
|
||||
post :create, product_category: valid_attributes, format: :json
|
||||
}.to change(ProductCategory, :count).by(1)
|
||||
end
|
||||
|
||||
@@ -69,12 +62,12 @@ describe Suppliers::ProductCategoriesController, type: :controller do
|
||||
context "with invalid attributes" do
|
||||
it "does not save the new product_category" do
|
||||
expect{
|
||||
post :create, product_category: invalid_attributes
|
||||
post :create, product_category: invalid_attributes, format: :json
|
||||
}.not_to change{ ProductCategory.count }
|
||||
end
|
||||
|
||||
it 'returns an error object' do
|
||||
post :create, format: :json, product_category: invalid_attributes
|
||||
post :create, format: :json, product_category: invalid_attributes, format: :json
|
||||
expect( JSON.parse(response.body)['errors'] ).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user