Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action JS allEntries, "$or" not working in wagon (but does in locomotive) #161

Open
proxygear opened this issue Nov 17, 2019 · 0 comments
Open

Comments

@proxygear
Copy link

In my wagon, in a .liquid file, I tried the following :

{% action 'custom query' %}
allEntries(
  myContentType, 
  {
    '$or': [ condition1, condition2]
  }
)
{% endaction %}

I seams $or is not implemented.

I added to locomotive/steam specs, into spec/unit/services/action_service_spec.rb, the following test. It's a copy of an existing spec named allEntries, but using the $or.

describe 'allEntries with an $or' do
        let(:now)     { Time.use_zone('America/Chicago') { Time.zone.local(2015, 'mar', 25, 10, 0) } }
        let(:assigns) { { 'now' => now } }
        let(:script) {
          <<-JS
            var entries = allEntries('bands', {
              '$or': [
                { featured: true },
                { leader: 'Eddie'}
              ]
            });
            var names = []

            for (var i = 0; i < entries.length; i++) {
              names.push(entries[i].name)
            }

            return names.join(', ')
          JS
        }

        before do
          expect(entry_service).to(
            receive(:all)
              .with(
                'bands',
                {
                  '$or' => [
                    { 'featured' => true },
                    { 'leader' => 'Eddie' }
                  ]
                },
                true
              )
              .and_return(
                [
                  { 'name' => 'Pearl Jam' },
                  { 'name' => 'The who' }
                ]
              )
          )
        end

        it { is_expected.to eq('Pearl Jam, The who') }
      end

This spec is passing, so I guess it used the mongoDB backend.

I dug more into steam, finding the lib/locomotive/steam/adapters/memory.rb.
I haven't found any trace of the $or in there.
I haven't been able to understand enough the spec/unit/adapters/memory_adapter_spec.rb and it's sub files to write a failing test for the or operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants