Commit 478c1c41 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'issue_270408' into 'master'

Move quality_test_cases factory to EE folder

See merge request gitlab-org/gitlab!47829
parents 0eb5df12 df08b4ff
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe DashboardController do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
context 'signed in' do
before do
project.add_developer(user)
sign_in(user)
end
describe 'GET issues' do
it 'does not list test cases' do
issue = create(:incident, project: project, author: user)
incident = create(:incident, project: project, author: user)
create(:quality_test_case, project: project, author: user)
get :issues, params: { author_id: user.id }
expect(assigns(:issues)).to match_array([issue, incident])
end
end
end
end
...@@ -19,6 +19,18 @@ RSpec.describe GroupsController do ...@@ -19,6 +19,18 @@ RSpec.describe GroupsController do
it_behaves_like 'namespace storage limit alert' it_behaves_like 'namespace storage limit alert'
end end
describe 'GET #issues' do
it 'does not list test cases' do
issue = create(:issue, project: project, title: 'foo')
incident = create(:incident, project: project)
create(:quality_test_case, project: project)
get :issues, params: { id: group.to_param }
expect(assigns(:issues)).to match_array([issue, incident])
end
end
describe 'GET #activity' do describe 'GET #activity' do
render_views render_views
......
...@@ -9,3 +9,9 @@ FactoryBot.modify do ...@@ -9,3 +9,9 @@ FactoryBot.modify do
end end
end end
end end
FactoryBot.define do
factory :quality_test_case, parent: :issue do
issue_type { :test_case }
end
end
...@@ -1006,4 +1006,20 @@ RSpec.describe Issue do ...@@ -1006,4 +1006,20 @@ RSpec.describe Issue do
end end
end end
end end
describe '.with_issue_type' do
let_it_be(:project) { create(:project) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:test_case) { create(:quality_test_case, project: project) }
it 'gives issues with test case type' do
expect(described_class.with_issue_type('test_case'))
.to contain_exactly(test_case)
end
it 'gives issues with the given issue types list' do
expect(described_class.with_issue_type(%w(issue test_case)))
.to contain_exactly(issue, test_case)
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_caching do
let(:project) { create(:project) }
describe '#count' do
it 'does not count test cases' do
create(:issue, :opened, project: project)
create(:incident, :opened, project: project)
create(:quality_test_case, :opened, project: project)
expect(described_class.new(project).count).to eq(2)
end
end
end
...@@ -15,16 +15,6 @@ RSpec.describe DashboardController do ...@@ -15,16 +15,6 @@ RSpec.describe DashboardController do
describe 'GET issues' do describe 'GET issues' do
it_behaves_like 'issuables list meta-data', :issue, :issues it_behaves_like 'issuables list meta-data', :issue, :issues
it_behaves_like 'issuables requiring filter', :issues it_behaves_like 'issuables requiring filter', :issues
it 'lists only incidents and issues' do
issue = create(:incident, project: project, author: user)
incident = create(:incident, project: project, author: user)
create(:quality_test_case, project: project, author: user)
get :issues, params: { author_id: user.id }
expect(assigns(:issues)).to match_array([issue, incident])
end
end end
describe 'GET merge requests' do describe 'GET merge requests' do
......
...@@ -400,15 +400,6 @@ RSpec.describe GroupsController, factory_default: :keep do ...@@ -400,15 +400,6 @@ RSpec.describe GroupsController, factory_default: :keep do
sign_in(user) sign_in(user)
end end
it 'lists only incidents and issues' do
incident = create(:incident, project: project)
create(:quality_test_case, project: project)
get :issues, params: { id: group.to_param }
expect(assigns(:issues)).to match_array([issue_1, issue_2, incident])
end
context 'sorting by votes' do context 'sorting by votes' do
it 'sorts most popular issues' do it 'sorts most popular issues' do
get :issues, params: { id: group.to_param, sort: 'upvotes_desc' } get :issues, params: { id: group.to_param, sort: 'upvotes_desc' }
......
...@@ -52,9 +52,5 @@ FactoryBot.define do ...@@ -52,9 +52,5 @@ FactoryBot.define do
factory :incident do factory :incident do
issue_type { :incident } issue_type { :incident }
end end
factory :quality_test_case do
issue_type { :test_case }
end
end end
end end
...@@ -141,7 +141,6 @@ RSpec.describe Issue do ...@@ -141,7 +141,6 @@ RSpec.describe Issue do
describe '.with_issue_type' do describe '.with_issue_type' do
let_it_be(:issue) { create(:issue, project: reusable_project) } let_it_be(:issue) { create(:issue, project: reusable_project) }
let_it_be(:incident) { create(:incident, project: reusable_project) } let_it_be(:incident) { create(:incident, project: reusable_project) }
let_it_be(:test_case) { create(:quality_test_case, project: reusable_project) }
it 'gives issues with the given issue type' do it 'gives issues with the given issue type' do
expect(described_class.with_issue_type('issue')) expect(described_class.with_issue_type('issue'))
...@@ -149,8 +148,8 @@ RSpec.describe Issue do ...@@ -149,8 +148,8 @@ RSpec.describe Issue do
end end
it 'gives issues with the given issue type' do it 'gives issues with the given issue type' do
expect(described_class.with_issue_type(%w(issue incident test_case))) expect(described_class.with_issue_type(%w(issue incident)))
.to contain_exactly(issue, incident, test_case) .to contain_exactly(issue, incident)
end end
end end
......
...@@ -10,14 +10,6 @@ RSpec.describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_c ...@@ -10,14 +10,6 @@ RSpec.describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_c
it_behaves_like 'a counter caching service' it_behaves_like 'a counter caching service'
describe '#count' do describe '#count' do
it 'does not count test cases' do
create(:issue, :opened, project: project)
create(:incident, :opened, project: project)
create(:quality_test_case, :opened, project: project)
expect(described_class.new(project).count).to eq(2)
end
context 'when user is nil' do context 'when user is nil' do
it 'does not include confidential issues in the issue count' do it 'does not include confidential issues in the issue count' do
create(:issue, :opened, project: project) create(:issue, :opened, project: project)
......
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