Sha256: 7ba17f2eb14d07459d2d27fa4df152ef4c1cb9f5b48b0746b4b190af4517746f

Contents?: true

Size: 648 Bytes

Versions: 23

Compression:

Stored size: 648 Bytes

Contents

require File.expand_path("../../spec_helper", __FILE__)
require "active_support/core_ext"

describe "Chaining scopes together" do
  describe "then calling #all" do
    before do
      User.all(:name => "Quagmire").each { |q| q.destroy }
      @users = (0...10).map do |i|
        User.create :name       => "Quagmire",
                    :created_at => i.hours.ago
      end
    end

    it "queries using a combination of both scopes" do
      User.named_quagmire.recent.all.should == @users.slice(0, 3)
    end

    it "gives scopes on the right priority" do
      User.named_joe.named_quagmire.first.name.should == "Quagmire"
    end
  end
end

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
ihoka-friendly-0.8.0.pre spec/integration/scope_chaining_spec.rb
ihoka-friendly-0.7.1.2 spec/integration/scope_chaining_spec.rb
ihoka-friendly-0.7.1.1 spec/integration/scope_chaining_spec.rb
ihoka-friendly-0.7.1 spec/integration/scope_chaining_spec.rb
ihoka-friendly-0.7.0 spec/integration/scope_chaining_spec.rb
friendly-0.6.0 spec/integration/scope_chaining_spec.rb
honkster-friendly-0.5.3 spec/integration/scope_chaining_spec.rb
honkster-friendly-0.5.2 spec/integration/scope_chaining_spec.rb
honkster-friendly-0.5.1 spec/integration/scope_chaining_spec.rb
wayne-friendly-0.5.1 spec/integration/scope_chaining_spec.rb
wego-friendly-0.5.1 spec/integration/scope_chaining_spec.rb
arunthampi-friendly-0.5.1 spec/integration/scope_chaining_spec.rb
friendly_postgres-0.5.1 spec/integration/scope_chaining_spec.rb
friendly-0.5.1 spec/integration/scope_chaining_spec.rb
friendly-0.5.0 spec/integration/scope_chaining_spec.rb
friendly_postgres-0.4.5 spec/integration/scope_chaining_spec.rb
friendly-0.4.5 spec/integration/scope_chaining_spec.rb
friendly-0.4.4 spec/integration/scope_chaining_spec.rb
friendly_postgres-0.4.3 spec/integration/scope_chaining_spec.rb
friendly-0.4.3 spec/integration/scope_chaining_spec.rb