barcode model test
This commit is contained in:
parent
8906ca7e39
commit
539b65b75f
3 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
class BarcodesController < ApplicationController
|
||||
load_and_authorize_resource :product, only: :create
|
||||
load_and_authorize_resource :barcode, through: :product, shallow: true
|
||||
|
||||
def create
|
||||
@barcode.save
|
||||
redirect_to barcode_products_path, notice: "Barcode successfully linked!"
|
||||
|
|
|
@ -15,6 +15,6 @@ class Barcode < ActiveRecord::Base
|
|||
|
||||
belongs_to :product
|
||||
|
||||
# validates :product, presence: true
|
||||
validates :product, presence: true
|
||||
validates :code, presence: true, uniqueness: true
|
||||
end
|
||||
|
|
|
@ -23,5 +23,12 @@ describe Barcode do
|
|||
expect(barcode).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe 'product' do
|
||||
it 'should be present' do
|
||||
@barcode.product = nil
|
||||
expect(@barcode).to_not be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue