Sha256: a6316ae605ed0c1c6f1b40261c2a66727c1ca03a9604fe95479d8e506e8ce881
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' describe Dune::Api::V1::UsersController do routes { Dune::Api::Engine.routes } let(:parsed_response) { JSON.parse(response.body) } let(:users_returned) do parsed_response.fetch('users').map { |t| t['id'] } end describe '#index', authorized: true, admin: true do let(:do_request) { get :index, format: :json } it_behaves_like 'paginating results' it 'filters by query' do FactoryGirl.create(:user, name: 'Ordinary user') _user = FactoryGirl.create(:user, name: 'Wonderful user') get :index, format: :json, query: 'wonderful' expect(users_returned).to eql([_user.id]) end end describe '#show', authorized: true do let(:do_request) { get :show, id: user.id, format: :json } it 'responds with 200' do do_request expect(response.status).to eql(200) end it 'has a top level element called user' do do_request expect(parsed_response.fetch('user')).to be_a(Hash) end it 'responds with data of the given user' do do_request expect( parsed_response.fetch('user') ).to have_key('id') end end end
Version data entries
3 entries across 3 versions & 1 rubygems