Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe 'GET /api/announcements' do
- let(:url) { '/api/announcements/' }
- before do
- create_list(:announcement, 2, user: author)
- get url, headers: author_header
- end
- it 'returns announcements' do
- expect(json).not_to be_empty
- expect(json.first.keys).to match_array(expected_keys)
- expect(json.size).to eq(3)
- json.each do |item|
- expect(item['user_id']).to eq(author.id)
- end
- end
- it 'returns status code 200' do
- expect(response).to have_http_status(200)
- end
- it_should_behave_like 'authenticable' do
- before { get url }
- end
- end
- describe 'GET /api/announcements/active' do
- let(:url) { '/api/announcements/active' }
- before do
- create_list(:announcement, 2, user: author)
- get url, headers: author_header
- end
- it 'returns announcements' do
- expect(json).not_to be_empty
- expect(json.first.keys).to match_array(expected_keys)
- expect(json.size).to eq(3)
- json.each do |item|
- expect(item['status']).to eq('active')
- end
- end
- it 'returns status code 200' do
- expect(response).to have_http_status(200)
- end
- it_should_behave_like 'authenticable' do
- before { get url }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement