Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Last active August 29, 2015 14:11
Show Gist options
  • Save biscuitvile/a4177384761ca1a212f0 to your computer and use it in GitHub Desktop.
Save biscuitvile/a4177384761ca1a212f0 to your computer and use it in GitHub Desktop.
require "rails_helper"
describe Product do
it 'cannot associate with categories from other accounts' do
account = create :account
product = build :product, account: account
a = create :category, account: account
b = create :category, account: build(:account)
product.category_ids = [a.id, b.id]
expect(product.categories).to eq [a]
end
# def category_ids=(ids)
# safe_ids = Category.where(account: account, id: ids).pluck(:id)
# super(safe_ids)
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment