summaryrefslogtreecommitdiff
path: root/spec/models/design_management
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/models/design_management
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
downloadgitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/design_management')
-rw-r--r--spec/models/design_management/design_at_version_spec.rb2
-rw-r--r--spec/models/design_management/design_spec.rb52
-rw-r--r--spec/models/design_management/version_spec.rb2
3 files changed, 54 insertions, 2 deletions
diff --git a/spec/models/design_management/design_at_version_spec.rb b/spec/models/design_management/design_at_version_spec.rb
index 220de80a52a..a7cf6a9652b 100644
--- a/spec/models/design_management/design_at_version_spec.rb
+++ b/spec/models/design_management/design_at_version_spec.rb
@@ -185,7 +185,7 @@ RSpec.describe DesignManagement::DesignAtVersion do
end
describe 'validations' do
- subject(:design_at_version) { build(:design_at_version) }
+ subject(:design_at_version) { build_stubbed(:design_at_version) }
it { is_expected.to be_valid }
diff --git a/spec/models/design_management/design_spec.rb b/spec/models/design_management/design_spec.rb
index 2ce9f00a056..d3ce2f2d48f 100644
--- a/spec/models/design_management/design_spec.rb
+++ b/spec/models/design_management/design_spec.rb
@@ -11,6 +11,14 @@ RSpec.describe DesignManagement::Design do
let_it_be(:design3) { create(:design, :with_versions, issue: issue, versions_count: 1) }
let_it_be(:deleted_design) { create(:design, :with_versions, deleted: true) }
+ it_behaves_like 'AtomicInternalId', validate_presence: true do
+ let(:internal_id_attribute) { :iid }
+ let(:instance) { build(:design, issue: issue) }
+ let(:scope) { :project }
+ let(:scope_attrs) { { project: instance.project } }
+ let(:usage) { :design_management_designs }
+ end
+
it_behaves_like 'a class that supports relative positioning' do
let_it_be(:relative_parent) { create(:issue) }
@@ -23,8 +31,20 @@ RSpec.describe DesignManagement::Design do
it { is_expected.to belong_to(:issue) }
it { is_expected.to have_many(:actions) }
it { is_expected.to have_many(:versions) }
+ it { is_expected.to have_many(:authors) }
it { is_expected.to have_many(:notes).dependent(:delete_all) }
it { is_expected.to have_many(:user_mentions) }
+
+ describe '#authors' do
+ it 'returns unique version authors', :aggregate_failures do
+ author = create(:user)
+ create_list(:design_version, 2, designs: [design1], author: author)
+ version_authors = design1.versions.map(&:author)
+
+ expect(version_authors).to contain_exactly(issue.author, author, author)
+ expect(design1.authors).to contain_exactly(issue.author, author)
+ end
+ end
end
describe 'validations' do
@@ -326,6 +346,38 @@ RSpec.describe DesignManagement::Design do
end
end
+ describe '#participants' do
+ let_it_be_with_refind(:design) { create(:design, issue: issue) }
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:version_author) { create(:user) }
+ let_it_be(:note_author) { create(:user) }
+ let_it_be(:mentioned_user) { create(:user) }
+ let_it_be(:design_version) { create(:design_version, :committed, designs: [design], author: version_author) }
+ let_it_be(:note) do
+ create(:diff_note_on_design,
+ noteable: design,
+ issue: issue,
+ project: issue.project,
+ author: note_author,
+ note: mentioned_user.to_reference
+ )
+ end
+
+ subject { design.participants(current_user) }
+
+ it { is_expected.to be_empty }
+
+ context 'when participants can read the project' do
+ before do
+ design.project.add_guest(version_author)
+ design.project.add_guest(note_author)
+ design.project.add_guest(mentioned_user)
+ end
+
+ it { is_expected.to contain_exactly(version_author, note_author, mentioned_user) }
+ end
+ end
+
describe "#new_design?" do
let(:design) { design1 }
diff --git a/spec/models/design_management/version_spec.rb b/spec/models/design_management/version_spec.rb
index cd52f4129dc..e004ad024bc 100644
--- a/spec/models/design_management/version_spec.rb
+++ b/spec/models/design_management/version_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe DesignManagement::Version do
it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:sha) }
it { is_expected.to validate_presence_of(:designs) }
- it { is_expected.to validate_presence_of(:issue_id) }
+ it { is_expected.to validate_presence_of(:issue) }
it { is_expected.to validate_uniqueness_of(:sha).scoped_to(:issue_id).case_insensitive }
end