gitlab-org--gitlab-foss/spec/requests/api/user_counts_spec.rb
Tim Zallmann b9e52612fe Updates on success of an MR the count on top and in other tabs
New API endpoint for merge request count
Updates all open tabs at the same time with one call
Restructured API response

API response changed to 401 if no current_user

Added API + JS specs

Fix for Static Check

Updated Count on Open/Close, Assign/Unassign of MR's

Checking if MR Count is refreshed

Added # frozen_string_literal: true to spec

Added Changelog
2019-07-09 08:44:19 +00:00

40 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe API::UserCounts do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let!(:merge_request) { create(:merge_request, :simple, author: user, assignees: [user], source_project: project, title: "Test") }
describe 'GET /user_counts' do
context 'when unauthenticated' do
it 'returns authentication error' do
get api('/user_counts')
expect(response.status).to eq(401)
end
end
context 'when authenticated' do
it 'returns open counts for current user' do
get api('/user_counts', user)
expect(response.status).to eq(200)
expect(json_response).to be_a Hash
expect(json_response['merge_requests']).to eq(1)
end
it 'updates the mr count when a new mr is assigned' do
create(:merge_request, source_project: project, author: user, assignees: [user])
get api('/user_counts', user)
expect(response.status).to eq(200)
expect(json_response).to be_a Hash
expect(json_response['merge_requests']).to eq(2)
end
end
end
end