Sha256: ec6c0b968f2aba7d22292e396f73660b753a9b6db209f535c7bdaddbc7895f8c

Contents?: true

Size: 981 Bytes

Versions: 31

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true


require 'spec_helper'
describe V1::Controllers::Users do
  before do
    header 'X-API-Version', '1'
  end

  let(:response) { subject; last_response }
  let(:json_payload) { JSON.dump(payload) }
  let(:parsed_body) { JSON.parse(response.body, symbolize_names: true) }

  context 'index' do
    let(:filters_q) { '' }
    let(:fields_q) { 'id' }
    let(:query_string) do
      "filters=#{CGI.escape(filters_q)}&fields=#{CGI.escape(fields_q)}"
    end
    subject { get "/users?#{query_string}" }

    context 'without filters' do
      it { expect(response.status).to eq 200 }
      it 'returns all users' do
        expect(parsed_body.size).to eq(2+100)
      end
    end
    context 'using filters' do
      let(:filters_q) { 'first_name=Peter' }
      it 'returns only peter' do
        expect(parsed_body.size).to eq(1)
        # Peter has id 11 from our seeds
        expect(parsed_body.map{|u| u[:id]}).to eq([11])
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
praxis-2.0.0 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.40 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.39 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.38 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.37 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.36 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.35 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.34 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.33 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.32 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.31 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.30 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.29 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.28 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.27 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.26 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.25 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.24 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.23 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb
praxis-2.0.pre.22 tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb