Sha256: 178778c99921f5c9362b58dc42d1f166e4b06305a9709cb2ad8700cacc741a42
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'spec_helper' describe UnscopedAssociations do context 'unscoped association omits default_scope' do it 'belongs_to' do user = User.create(active: false) comment = Comment.create(user_id: user.id) expect(comment.unscoped_user).to eq(user) end it 'has_many' do user = User.create comment = Comment.create(user_id: user.id, public: false) expect(user.unscoped_comments).to be_present end it 'has_one' do user = User.create comment = Comment.create(user_id: user.id, public: false) expect(user.unscoped_last_comment).to be_present end end context 'no unscoped association takes default_scope' do it 'belongs_to' do user = User.create(active: false) comment = Comment.create(user_id: user.id) expect(comment.user).to be_nil expect(comment.scoped_user).to be_nil end it 'has_many' do user = User.create comment = Comment.create(user_id: user.id, public: false) expect(user.comments).to be_empty end it 'has_one' do user = User.create comment = Comment.create(user_id: user.id, public: false) expect(user.last_comment).to be_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unscoped_associations-0.6.1 | spec/unscoped_associations_spec.rb |