-
-
Notifications
You must be signed in to change notification settings - Fork 829
Milestone
Description
As demonstrated in https://github.com/runephilosof/ransack-scopes-or
The combinator :or does not work with scopes.
class Test < ActiveRecord::Base
scope :red, -> { where(color: :red) }
scope :green, -> { where(color: :green) }
def self.ransackable_scopes(a = nil)
[:red, :green]
end
end
RSpec.describe Test do
context "when conditions are two scopes" do
let(:ransack) { Test.ransack(red: true, green: true, m: :or) }
it "supports :or combinator" do
expect(ransack.base.combinator).to eq :or # Success
end
it "generates SQL containing OR" do
expect(ransack.result.to_sql).to include "OR" # Failure
end
end
context "when conditions are a scope and an attribute" do
let(:ransack) { Test.ransack(red: true, color_cont: "green", m: :or) }
it "supports :or combinator" do
expect(ransack.base.combinator).to eq :or # Success
end
it "generates SQL containing OR" do
expect(ransack.result.to_sql).to include "OR" # Failure
end
end
end
denisdenes, xeron and librod89Copilot