Commit c0c45c72 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'speed-up-api-projects-spec' into 'master'

Speed up specs for GET /projects/:id/events

## What does this MR do?

Just groups some expectations into a single `it` block. Reduce this particular tests block time by half.

See merge request !6778
parents d1eab555 4917bbd7
...@@ -588,37 +588,39 @@ describe API::API, api: true do ...@@ -588,37 +588,39 @@ describe API::API, api: true do
before do before do
note = create(:note_on_issue, note: 'What an awesome day!', project: project) note = create(:note_on_issue, note: 'What an awesome day!', project: project)
EventCreateService.new.leave_note(note, note.author) EventCreateService.new.leave_note(note, note.author)
get api("/projects/#{project.id}/events", user)
end end
it { expect(response).to have_http_status(200) } it 'returns all events' do
get api("/projects/#{project.id}/events", user)
context 'joined event' do expect(response).to have_http_status(200)
let(:json_event) { json_response[1] }
it { expect(json_event['action_name']).to eq('joined') } first_event = json_response.first
it { expect(json_event['project_id'].to_i).to eq(project.id) }
it { expect(json_event['author_username']).to eq(user3.username) }
it { expect(json_event['author']['name']).to eq(user3.name) }
end
context 'comment event' do expect(first_event['action_name']).to eq('commented on')
let(:json_event) { json_response.first } expect(first_event['note']['body']).to eq('What an awesome day!')
it { expect(json_event['action_name']).to eq('commented on') } last_event = json_response.last
it { expect(json_event['note']['body']).to eq('What an awesome day!') }
expect(last_event['action_name']).to eq('joined')
expect(last_event['project_id'].to_i).to eq(project.id)
expect(last_event['author_username']).to eq(user3.username)
expect(last_event['author']['name']).to eq(user3.name)
end end
end end
it 'returns a 404 error if not found' do it 'returns a 404 error if not found' do
get api('/projects/42/events', user) get api('/projects/42/events', user)
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
it 'returns a 404 error if user is not a member' do it 'returns a 404 error if user is not a member' do
other_user = create(:user) other_user = create(:user)
get api("/projects/#{project.id}/events", other_user) get api("/projects/#{project.id}/events", other_user)
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment