Sha256: 75829c026f9797affae631991a3ee075188ce171c41cc1dd2c8337da7949459a
Contents?: true
Size: 1.18 KB
Versions: 7
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe DHS::Record do context 'order in where chains' do before do class Record < DHS::Record endpoint 'http://records' end end context 'single parameter for order' do before do stub_request(:get, 'http://records/?color=blue&order[created_at]=desc') .to_return(body: [{ name: 'ordered by created_at desc' }].to_json) end it 'allows to add order params with .order' do records = Record.where(color: 'blue').order(created_at: :desc) expect(records.first.name).to eq 'ordered by created_at desc' end end context 'multiple parameters for order' do before do stub_request(:get, 'http://records/?color=blue&order[name]=asc&order[created_at]=desc') .to_return(body: [{ name: 'ordered by name asc (implicitly) and created_at desc (explicitly)' }].to_json) end it 'allows to add order params with .order' do records = Record.where(color: 'blue').order(:name, created_at: :desc) expect(records.first.name).to eq 'ordered by name asc (implicitly) and created_at desc (explicitly)' end end end end
Version data entries
7 entries across 7 versions & 1 rubygems