summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-02 22:16:54 +0000
committerDouwe Maan <douwe@gitlab.com>2017-06-02 22:16:54 +0000
commit70b927a55ca62f1219464182660877bcdefd55b0 (patch)
tree23aa15039675ed3c9e536a739b74f6c2ed2e53ff
parent8f7fc44b63f728d4de9c2e57a1452c53fa02a642 (diff)
parentc2516115e391360055f733d40af8aff2af52196b (diff)
downloadgitlab-ce-70b927a55ca62f1219464182660877bcdefd55b0.tar.gz
Merge branch 'projects-api-import-status' into 'master'
Expose import_status in Projects API Closes #19646 See merge request !11851
-rw-r--r--changelogs/unreleased/projects-api-import-status.yml4
-rw-r--r--doc/api/projects.md11
-rw-r--r--lib/api/entities.rb2
-rw-r--r--spec/requests/api/projects_spec.rb20
4 files changed, 37 insertions, 0 deletions
diff --git a/changelogs/unreleased/projects-api-import-status.yml b/changelogs/unreleased/projects-api-import-status.yml
new file mode 100644
index 00000000000..06603c0adec
--- /dev/null
+++ b/changelogs/unreleased/projects-api-import-status.yml
@@ -0,0 +1,4 @@
+---
+title: Expose import_status in Projects API
+merge_request: 11851
+author: Robin Bobbitt
diff --git a/doc/api/projects.md b/doc/api/projects.md
index 62c78ddc32e..70cad8a6025 100644
--- a/doc/api/projects.md
+++ b/doc/api/projects.md
@@ -81,6 +81,7 @@ Parameters:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
"archived": false,
"avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png",
"shared_runners_enabled": true,
@@ -138,6 +139,8 @@ Parameters:
"kind": "group",
"full_path": "brightbox"
},
+ "import_status": "none",
+ "import_error": null,
"permissions": {
"project_access": {
"access_level": 10,
@@ -225,6 +228,8 @@ Parameters:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
+ "import_error": null,
"permissions": {
"project_access": {
"access_level": 10,
@@ -611,6 +616,7 @@ Example response:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
"archived": true,
"avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
"shared_runners_enabled": true,
@@ -676,6 +682,7 @@ Example response:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
"archived": true,
"avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
"shared_runners_enabled": true,
@@ -747,6 +754,8 @@ Example response:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
+ "import_error": null,
"permissions": {
"project_access": {
"access_level": 10,
@@ -829,6 +838,8 @@ Example response:
"kind": "group",
"full_path": "diaspora"
},
+ "import_status": "none",
+ "import_error": null,
"permissions": {
"project_access": {
"access_level": 10,
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 31da85e9917..ded5c65e303 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -100,6 +100,8 @@ module API
expose :creator_id
expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
+ expose :import_status
+ expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :avatar_url do |user, options|
user.avatar_url(only_path: false)
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 40bfc0c636b..5c13cea69fb 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -635,6 +635,8 @@ describe API::Projects do
expect(json_response['shared_runners_enabled']).to be_present
expect(json_response['creator_id']).to be_present
expect(json_response['namespace']).to be_present
+ expect(json_response['import_status']).to be_present
+ expect(json_response).to include("import_error")
expect(json_response['avatar_url']).to be_nil
expect(json_response['star_count']).to be_present
expect(json_response['forks_count']).to be_present
@@ -702,6 +704,20 @@ describe API::Projects do
expect(json_response).to include 'statistics'
end
+ it "includes import_error if user can admin project" do
+ get api("/projects/#{project.id}", user)
+
+ expect(response).to have_http_status(200)
+ expect(json_response).to include("import_error")
+ end
+
+ it "does not include import_error if user cannot admin project" do
+ get api("/projects/#{project.id}", user3)
+
+ expect(response).to have_http_status(200)
+ expect(json_response).not_to include("import_error")
+ end
+
describe 'permissions' do
context 'all projects' do
before { project.team << [user, :master] }
@@ -1464,6 +1480,8 @@ describe API::Projects do
expect(json_response['owner']['id']).to eq(user2.id)
expect(json_response['namespace']['id']).to eq(user2.namespace.id)
expect(json_response['forked_from_project']['id']).to eq(project.id)
+ expect(json_response['import_status']).to eq('started')
+ expect(json_response).to include("import_error")
end
it 'forks if user is admin' do
@@ -1475,6 +1493,8 @@ describe API::Projects do
expect(json_response['owner']['id']).to eq(admin.id)
expect(json_response['namespace']['id']).to eq(admin.namespace.id)
expect(json_response['forked_from_project']['id']).to eq(project.id)
+ expect(json_response['import_status']).to eq('started')
+ expect(json_response).to include("import_error")
end
it 'fails on missing project access for the project to fork' do