debian-mirror-gitlab/spec/requests/api/task_completion_status_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.5 KiB
Ruby
Raw Permalink Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'task completion status response', features: :team_planning do
2020-03-09 13:42:32 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project) do
2019-09-04 21:01:54 +05:30
create(:project, :public, creator_id: user.id, namespace: user.namespace)
end
shared_examples 'taskable completion status provider' do |path|
samples = [
2023-03-04 22:38:38 +05:30
{
description: '',
expected_count: 0,
expected_completed_count: 0
},
{
description: 'Lorem ipsum',
expected_count: 0,
expected_completed_count: 0
},
{
description: %{- [ ] task 1
2019-09-04 21:01:54 +05:30
- [x] task 2 },
2023-03-04 22:38:38 +05:30
expected_count: 2,
expected_completed_count: 1
},
{
description: %{- [ ] task 1
2019-09-04 21:01:54 +05:30
- [ ] task 2 },
2023-03-04 22:38:38 +05:30
expected_count: 2,
expected_completed_count: 0
},
{
description: %{- [x] task 1
2019-09-04 21:01:54 +05:30
- [x] task 2 },
2023-03-04 22:38:38 +05:30
expected_count: 2,
expected_completed_count: 2
},
{
description: %{- [ ] task 1},
expected_count: 1,
expected_completed_count: 0
},
{
description: %{- [x] task 1},
expected_count: 1,
expected_completed_count: 1
}
2019-09-04 21:01:54 +05:30
]
samples.each do |sample_data|
context "with a description of #{sample_data[:description].inspect}" do
before do
taskable.update!(description: sample_data[:description])
get api("#{path}?iids[]=#{taskable.iid}", user)
end
2020-04-08 14:13:33 +05:30
it { expect(response).to have_gitlab_http_status(:ok) }
2019-09-04 21:01:54 +05:30
it 'returns the expected results' do
expect(json_response).to be_an Array
expect(json_response).not_to be_empty
task_completion_status = json_response.first['task_completion_status']
expect(task_completion_status['count']).to eq(sample_data[:expected_count])
expect(task_completion_status['completed_count']).to eq(sample_data[:expected_completed_count])
end
end
end
end
context 'task list completion status for issues' do
it_behaves_like 'taskable completion status provider', '/issues' do
let(:taskable) { create(:issue, project: project, author: user) }
end
end
context 'task list completion status for merge_requests' do
it_behaves_like 'taskable completion status provider', '/merge_requests' do
let(:taskable) { create(:merge_request, source_project: project, target_project: project, author: user) }
end
end
end