osem-fcy/spec/controllers/api/v1/rooms_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

39 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::RoomsController do
let!(:conference) { create(:conference) }
let!(:venue) { create(:venue, conference: conference) }
let!(:conference_room) { create(:room, name: 'Conference Room', venue: venue) }
let!(:room) { create(:room, name: 'Test Room') }
describe 'GET #index' do
context 'without conference scope' do
it 'returns all rooms' do
get :index, params: { format: :json }
json = JSON.parse(response.body)['rooms']
expect(response).to be_success
expect(json.length).to eq(2)
expect(json[0]['name']).to eq('Conference Room')
expect(json[1]['name']).to eq('Test Room')
end
end
context 'with conference scope' do
it 'returns all rooms of conference' do
get :index, params: { conference_id: conference.short_title, format: :json }
json = JSON.parse(response.body)['rooms']
expect(response).to be_success
expect(json.length).to eq(1)
expect(json[0]['name']).to eq('Conference Room')
end
end
end
end