Commit 6b6b2324 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'caalberts-todos-finder-spec-improvement' into 'master'

Use `let_it_be` in todos_finder_spec

See merge request gitlab-org/gitlab!39806
parents 0d661320 dbfd942b
......@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec.describe TodosFinder do
describe '#execute' do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :repository, namespace: group) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:merge_request) { create(:merge_request, source_project: project) }
let(:finder) { described_class }
before do
before_all do
group.add_developer(user)
end
......@@ -89,8 +89,6 @@ RSpec.describe TodosFinder do
end
it 'raises an argument error when invalid type is passed' do
create(:todo, user: user, group: group, target: create(:design))
todos_finder = finder.new(user, { type: %w[Issue MergeRequest NotAValidType] })
expect { todos_finder.execute }.to raise_error(ArgumentError)
......@@ -131,8 +129,8 @@ RSpec.describe TodosFinder do
end
context 'when filtering by author' do
let(:author1) { create(:user) }
let(:author2) { create(:user) }
let_it_be(:author1) { create(:user) }
let_it_be(:author2) { create(:user) }
let!(:todo1) { create(:todo, user: user, author: author1) }
let!(:todo2) { create(:todo, user: user, author: author2) }
......@@ -154,7 +152,7 @@ RSpec.describe TodosFinder do
context 'by groups' do
context 'with subgroups' do
let(:subgroup) { create(:group, parent: group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) }
it 'returns todos from subgroups when filtered by a group' do
......@@ -167,17 +165,14 @@ RSpec.describe TodosFinder do
context 'filtering for multiple groups' do
let_it_be(:group2) { create(:group) }
let_it_be(:group3) { create(:group) }
let_it_be(:subgroup1) { create(:group, parent: group) }
let_it_be(:subgroup2) { create(:group, parent: group2) }
let!(:todo1) { create(:todo, user: user, project: project, target: issue) }
let!(:todo2) { create(:todo, user: user, group: group, target: merge_request) }
let!(:todo3) { create(:todo, user: user, group: group2, target: merge_request) }
let(:subgroup1) { create(:group, parent: group) }
let!(:todo4) { create(:todo, user: user, group: subgroup1, target: issue) }
let(:subgroup2) { create(:group, parent: group2) }
let!(:todo5) { create(:todo, user: user, group: subgroup2, target: issue) }
let!(:todo6) { create(:todo, user: user, group: group3, target: issue) }
it 'returns the expected groups' do
......
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