Sha256: d1d63948a758dcb0e96f127cbd0b8f712f6be71baa749f276983d540aba03025

Contents?: true

Size: 922 Bytes

Versions: 37

Compression:

Stored size: 922 Bytes

Contents

RSpec.describe Symphonia::ModelFilters::Base do
  let(:query) { Symphonia::User.query.new }
  let!(:user) { FactoryBot.create :user, email: "sample@dummy.cz", status: "active" }

  describe "string" do
    subject { Symphonia::ModelFilters::StringFilter.new attribute, query }

    let(:attribute) { Symphonia::User.registered_attributes[:email] }
    it "simple filter" do
      subject.value = "~sample@dummy.cz"
      expect(subject.apply(Symphonia::User.all).count).to eq 1
    end

  end

  describe "status" do
    let(:attribute) { Symphonia::User.registered_attributes[:status] }
    subject { Symphonia::ModelFilters::SelectFilter.new attribute, query }

    it "simple filter" do
      subject.value = "1"
      expect(subject.apply(Symphonia::User.all).count).to eq 1
    end
    it "array filter" do
      subject.value = "1|2|3"
      expect(subject.apply(Symphonia::User.all).count).to eq 1
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
symphonia-6.0.6 spec/models/query/filters_spec.rb
symphonia-6.0.5 spec/models/query/filters_spec.rb
symphonia-6.0.2 spec/models/query/filters_spec.rb
symphonia-6.0.1 spec/models/query/filters_spec.rb
symphonia-6.0.0 spec/models/query/filters_spec.rb
symphonia-5.0.6 spec/models/query/filters_spec.rb
symphonia-5.0.5 spec/models/query/filters_spec.rb
symphonia-5.0.4 spec/models/query/filters_spec.rb
symphonia-5.0.3 spec/models/query/filters_spec.rb
symphonia-5.0.0 spec/models/query/filters_spec.rb
symphonia-4.2.0 spec/models/query/filters_spec.rb
symphonia-4.1.3 spec/models/query/filters_spec.rb
symphonia-4.1.2 spec/models/query/filters_spec.rb
symphonia-4.1.1 spec/models/query/filters_spec.rb
symphonia-4.1.0 spec/models/query/filters_spec.rb
symphonia-4.0.1 spec/models/query/filters_spec.rb
symphonia-4.0.0 spec/models/query/filters_spec.rb
symphonia-3.4.0 spec/models/query/filters_spec.rb
symphonia-3.3.4 spec/models/query/filters_spec.rb
symphonia-3.3.3 spec/models/query/filters_spec.rb