osem-fcy/spec/controllers/api/v1/conferences_controller_spec.rb
Ana María Martínez Gómez d1180e2767
Use keyword arguments in tests
Raisl 5.1 removes support for non-keyword arguments in `#process`,
`#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head` for the
`ActionDispatch::IntegrationTest` and `ActionController::TestCase`
classes. This means we have to add `params` everywhere in the controller
tests.
2019-05-14 14:10:36 +02:00

47 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::ConferencesController do
let!(:conf_one) { create(:conference, short_title: 'conf_one') }
let!(:conf_two) { create(:conference, short_title: 'conf_two') }
describe 'GET #index' do
before(:each) do
get :index, params: { format: :json }
@json = JSON.parse(response.body)['conferences']
end
it 'returns successful response' do
expect(response).to be_success
end
it 'returns all conferences' do
expect(@json.length).to eq(2)
end
it 'returns correct conferences' do
expect(@json[0]['short_title']).to eq('conf_one')
expect(@json[1]['short_title']).to eq('conf_two')
end
end
describe 'GET #show' do
before(:each) do
get :show, params: { id: 'conf_two', format: :json }
@json = JSON.parse(response.body)['conferences']
end
it 'returns successful response' do
expect(response).to be_success
end
it 'returns only one conference' do
expect(@json.length).to eq(1)
end
it 'returns the correct conference' do
expect(@json[0]['short_title']).to eq('conf_two')
end
end
end