diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/models/work_item_spec.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/models/work_item_spec.rb')
-rw-r--r-- | spec/models/work_item_spec.rb | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb index 5e757c11f99..f33c8e0a186 100644 --- a/spec/models/work_item_spec.rb +++ b/spec/models/work_item_spec.rb @@ -3,7 +3,10 @@ require 'spec_helper' RSpec.describe WorkItem do + let_it_be(:reusable_project) { create(:project) } + describe 'associations' do + it { is_expected.to belong_to(:namespace) } it { is_expected.to have_one(:work_item_parent).class_name('WorkItem') } it 'has one `parent_link`' do @@ -38,7 +41,9 @@ RSpec.describe WorkItem do it 'returns instances of supported widgets' do is_expected.to match_array([instance_of(WorkItems::Widgets::Description), - instance_of(WorkItems::Widgets::Hierarchy)]) + instance_of(WorkItems::Widgets::Hierarchy), + instance_of(WorkItems::Widgets::Assignees), + instance_of(WorkItems::Widgets::Weight)]) end end @@ -52,5 +57,55 @@ RSpec.describe WorkItem do create(:work_item) end end + + context 'work item namespace' do + let(:work_item) { build(:work_item, project: reusable_project) } + + it 'sets the namespace_id' do + expect(work_item).to be_valid + expect(work_item.namespace).to eq(reusable_project.project_namespace) + end + + context 'when work item is saved' do + it 'sets the namespace_id' do + work_item.save! + expect(work_item.reload.namespace).to eq(reusable_project.project_namespace) + end + end + + context 'when existing work item is saved' do + let(:work_item) { create(:work_item) } + + before do + work_item.update!(namespace_id: nil) + end + + it 'sets the namespace id' do + work_item.update!(title: "#{work_item.title} and something extra") + + expect(work_item.namespace).to eq(work_item.project.project_namespace) + end + end + end + end + + describe 'validations' do + subject { work_item.valid? } + + describe 'issue_type' do + let(:work_item) { build(:work_item, issue_type: issue_type) } + + context 'when a valid type' do + let(:issue_type) { :issue } + + it { is_expected.to eq(true) } + end + + context 'empty type' do + let(:issue_type) { nil } + + it { is_expected.to eq(false) } + end + end end end |