summaryrefslogtreecommitdiff
path: root/spec/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
commita9ced7da447785c57477b3d8dbccc73a78cface1 (patch)
tree5179d27ab9d801748ee4ed1c64c985974e799812 /spec/graphql
parentad0265eead72a624ce7a020847db4f0f0c877e57 (diff)
downloadgitlab-ce-a9ced7da447785c57477b3d8dbccc73a78cface1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb57
1 files changed, 29 insertions, 28 deletions
diff --git a/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb b/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb
index a5f17acce91..4d060d213ed 100644
--- a/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb
+++ b/spec/graphql/resolvers/projects/jira_imports_resolver_spec.rb
@@ -7,29 +7,16 @@ describe Resolvers::Projects::JiraImportsResolver do
describe '#resolve' do
let_it_be(:user) { create(:user) }
- let_it_be(:jira_import_data) do
- data = JiraImportData.new
- data << JiraImportData::JiraProjectDetails.new('AA', 2.days.ago.strftime('%Y-%m-%d %H:%M:%S'), { user_id: user.id, name: user.name })
- data << JiraImportData::JiraProjectDetails.new('BB', 5.days.ago.strftime('%Y-%m-%d %H:%M:%S'), { user_id: user.id, name: user.name })
- data
- end
-
- context 'when feature flag disabled' do
- let_it_be(:project) { create(:project, :private, import_data: jira_import_data) }
-
- before do
- stub_feature_flags(jira_issue_import: false)
- end
+ let_it_be(:project, reload: true) { create(:project, :public) }
- it_behaves_like 'no jira import access'
- end
-
- context 'when project does not have Jira import data' do
- let_it_be(:project) { create(:project, :private, import_data: nil) }
+ context 'when project does not have Jira imports' do
+ let(:current_user) { user }
- context 'when user cannot read Jira import data' do
+ context 'when user cannot read Jira imports' do
context 'when anonymous user' do
- it_behaves_like 'no jira import data present'
+ let(:current_user) { nil }
+
+ it_behaves_like 'no jira import access'
end
context 'when user developer' do
@@ -37,7 +24,7 @@ describe Resolvers::Projects::JiraImportsResolver do
project.add_developer(user)
end
- it_behaves_like 'no jira import data present'
+ it_behaves_like 'no jira import access'
end
end
@@ -50,11 +37,25 @@ describe Resolvers::Projects::JiraImportsResolver do
end
end
- context 'when project has Jira import data' do
- let_it_be(:project) { create(:project, :private, import_data: jira_import_data) }
+ context 'when project has Jira imports' do
+ let_it_be(:current_user) { user }
+ let_it_be(:jira_import1) { create(:jira_import_state, :finished, project: project, jira_project_key: 'AA', created_at: 2.days.ago) }
+ let_it_be(:jira_import2) { create(:jira_import_state, :finished, project: project, jira_project_key: 'BB', created_at: 5.days.ago) }
+
+ context 'when feature flag disabled' do
+ let(:current_user) { user }
+
+ before do
+ stub_feature_flags(jira_issue_import: false)
+ end
+
+ it_behaves_like 'no jira import access'
+ end
- context 'when user cannot read Jira import data' do
+ context 'when user cannot read Jira imports' do
context 'when anonymous user' do
+ let(:current_user) { nil }
+
it_behaves_like 'no jira import access'
end
@@ -67,22 +68,22 @@ describe Resolvers::Projects::JiraImportsResolver do
end
end
- context 'when user can access Jira import data' do
+ context 'when user can access Jira imports' do
before do
project.add_maintainer(user)
end
- it 'returns Jira imports sorted ascending by scheduledAt time' do
+ it 'returns Jira imports sorted ascending by created_at time' do
imports = resolve_imports
expect(imports.size).to eq 2
- expect(imports.map(&:key)).to eq %w(BB AA)
+ expect(imports.map(&:jira_project_key)).to eq %w(BB AA)
end
end
end
end
- def resolve_imports(args = {}, context = { current_user: user })
+ def resolve_imports(args = {}, context = { current_user: current_user })
resolve(described_class, obj: project, args: args, ctx: context)
end
end