Permalink
Browse files

More specs

  • Loading branch information...
1 parent 15d0eba commit 1f062a110c462f66dface72abfb6f6b148735220 @dim dim committed Jul 22, 2011
Showing with 18 additions and 2 deletions.
  1. +1 −1 Gemfile.lock
  2. +9 −1 spec/bsm/constrainable/model_spec.rb
  3. +7 −0 spec/fixtures/posts.yml
  4. +1 −0 spec/spec_helper.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- constrainable (0.3.0)
+ constrainable (0.3.1)
abstract
activerecord (~> 3.0.0)
activesupport (~> 3.0.0)
@@ -1,7 +1,7 @@
require "spec_helper"
describe Bsm::Constrainable::Model do
- fixtures :posts
+ fixtures :posts, :authors
let :model do
Class.new(ActiveRecord::Base)
@@ -35,10 +35,18 @@
it 'should retain relation scopes' do
Post.articles.should have(1).record
+ Post.articles.constrain(nil).should have(1).record
+ Post.constrain(nil).articles.should have(1).record
+
Post.articles.constrain(:author_id => {:in => 1}).should have(1).record
Post.articles.constrain(:author_id => {:in => 2}).should have(:no).records
Post.constrain(:author_id => {:in => 2}).should have(1).record
end
+ it 'should retain association scopes' do
+ authors(:alice).posts.articles.should have(1).record
+ authors(:alice).posts.constrain(nil).articles.should have(1).record
+ authors(:alice).posts.articles.constrain(nil).should have(1).record
+ end
end
View
@@ -5,6 +5,13 @@ article:
created_at: <%= 2.weeks.ago %>
updated_at: <%= 10.days.ago %>
category: article
+essay:
+ title: A Title
+ body: A Body
+ author_id: 1
+ created_at: <%= 2.weeks.ago %>
+ updated_at: <%= 2.weeks.ago %>
+ category: essay
opinion:
title: B Title
body: B Body
View
@@ -53,6 +53,7 @@ def clean_sql
end
class Author < ActiveRecord::Base
+ has_many :posts
end
class Post < ActiveRecord::Base

0 comments on commit 1f062a1

Please sign in to comment.