summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-13 13:32:33 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-14 13:39:08 +0100
commitca8f1ed9bbded05218c0d0398a1f96a6e03ecf53 (patch)
treecc88ccf8802c03c619e858e9b606fba280b92731 /spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
parent5ae91f323d054341c0d012de85835ef40f1bf9f8 (diff)
downloadgitlab-ce-ca8f1ed9bbded05218c0d0398a1f96a6e03ecf53.tar.gz
Import multiple issue assignees from GitLab export
When importing from a GitLab archive, an admin can carry over the assignations. Other users can not. When a regular user is importing an issue with multiple assignees, the assignee is replaced with the current user, meaning we would try to insert current user as an assignee multiple times. By filtering the array before storing it, the import becomes more robust.
Diffstat (limited to 'spec/lib/gitlab/import_export/project_tree_restorer_spec.rb')
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index f4e466d1296..13e930bafe3 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -4,7 +4,12 @@ include ImportExport::CommonUtil
describe Gitlab::ImportExport::ProjectTreeRestorer do
describe 'restore project tree' do
before(:context) do
- @user = create(:user)
+ # Using an admin for import, so we can check assignment of existing members
+ @user = create(:admin)
+ @existing_members = [
+ create(:user, username: 'bernard_willms'),
+ create(:user, username: 'saul_will')
+ ]
RSpec::Mocks.with_temporary_scope do
@project = create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project')
@@ -63,8 +68,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(issue.reload.updated_at.to_s).to eq('2016-06-14 15:02:47 UTC')
end
- it 'has issue assignees' do
- expect(Issue.where(title: 'Voluptatem').first.issue_assignees).not_to be_empty
+ it 'has multiple issue assignees' do
+ expect(Issue.find_by(title: 'Voluptatem').assignees).to contain_exactly(@user, *@existing_members)
+ expect(Issue.find_by(title: 'Issue without assignees').assignees).to be_empty
end
it 'contains the merge access levels on a protected branch' do