Sha256: 10041461eeb8ac2ebc866361282a8df0a1148e19daf56d10e8cef4858cd4e67c
Contents?: true
Size: 1.48 KB
Versions: 64
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' describe ActiveFedora::Scoping::Default do describe "when default_scope is overridden" do before do class Book < ActiveFedora::Base property :published, predicate: ::RDF::Vocab::EBUCore.pubStatus do |index| index.as :symbol end def self.default_scope where published_ssim: 'true' end end Book.destroy_all Book.create!(published: [true]) Book.create!(published: [true]) Book.create!(published: [false]) end after do Object.send(:remove_const, :Book) end it "returns only the scoped records" do expect(Book.all.size).to eq 2 end it "returns all the records" do Book.unscoped do expect(Book.all.size).to eq 3 end end end describe "when default_scope is called" do before do class Book < ActiveFedora::Base property :published, predicate: ::RDF::Vocab::EBUCore.pubStatus do |index| index.as :symbol end default_scope -> { where published_ssim: 'true' } end Book.destroy_all Book.create!(published: [true]) Book.create!(published: [true]) Book.create!(published: [false]) end after do Object.send(:remove_const, :Book) end it "returns only the scoped records" do expect(Book.all.size).to eq 2 end it "returns all the records" do Book.unscoped do expect(Book.all.size).to eq 3 end end end end
Version data entries
64 entries across 64 versions & 1 rubygems