diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-08-12 00:17:48 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-08-12 00:17:48 +0100 |
commit | e93214bce63518b31532d9406d00703aa2ef2d26 (patch) | |
tree | 2b46a71ad89f3fa9f4996af51d318228a49fee5b /lib/api | |
parent | ab88fcf117c4f55071ffaa476b7e72e0c11a967f (diff) | |
parent | 1c874f71e31fdf2bbc9120fe2111b2daea320e86 (diff) | |
download | gitlab-ce-e93214bce63518b31532d9406d00703aa2ef2d26.tar.gz |
Merge branch 'master' into issue-discussions-refactor
* master: (66 commits)
fix confidential border issue as well as confidential styles leaking on new MR
Migrate force push check to Gitaly
Add option to disable project export on instance
Better categorize test coverage results
Add option to disable project export on instance - db changes
Better caching and indexing of broadcast messages
Include the `is_admin` field in the `GET /users/:id` API when current user is an admin
Document rspec-retry and rspec-flaky
Fix cop description
Retrieve and sync flaky specs report from and to S3
Use a new RspecFlakyListener to detect flaky specs
Fix formatting of patch_versions.md [skip ci]
Enable Timecop safe mode
Show error message for API 500 error in tests, and
Fix merge request diff deserialisation when too_large was absent
Delete correct key from `session` after authenticating using U2F
Bumps omniauth-ldap gem version to 2.0.4
Pending delete projects no longer return 500 error in Admins projects view
Do not run the `ee_compat_check` job for stableish branches
Update gitlab.po: Missing 'r' in "Fouché" that comes from "Fourcher" verb.
...
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 12 | ||||
-rw-r--r-- | lib/api/helpers.rb | 10 | ||||
-rw-r--r-- | lib/api/settings.rb | 1 | ||||
-rw-r--r-- | lib/api/users.rb | 13 | ||||
-rw-r--r-- | lib/api/v3/entities.rb | 12 |
5 files changed, 36 insertions, 12 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 7ee25bf177c..f7e251736ab 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -497,14 +497,24 @@ module API expose :author, using: Entities::UserBasic end + class PushEventPayload < Grape::Entity + expose :commit_count, :action, :ref_type, :commit_from, :commit_to + expose :ref, :commit_title + end + class Event < Grape::Entity expose :title, :project_id, :action_name expose :target_id, :target_iid, :target_type, :author_id - expose :data, :target_title + expose :target_title expose :created_at expose :note, using: Entities::Note, if: ->(event, options) { event.note? } expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author } + expose :push_event_payload, + as: :push_data, + using: PushEventPayload, + if: -> (event, _) { event.push? } + expose :author_username do |event, options| event.author&.username end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 99b8b62691f..3582ed81b0f 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -257,7 +257,15 @@ module API message << " " << trace.join("\n ") API.logger.add Logger::FATAL, message - rack_response({ 'message' => '500 Internal Server Error' }.to_json, 500) + + response_message = + if Rails.env.test? + message + else + '500 Internal Server Error' + end + + rack_response({ 'message' => response_message }.to_json, 500) end # project helpers diff --git a/lib/api/settings.rb b/lib/api/settings.rb index d55a61fa638..667ba468ce6 100644 --- a/lib/api/settings.rb +++ b/lib/api/settings.rb @@ -29,6 +29,7 @@ module API desc: 'Enabled sources for code import during project creation. OmniAuth must be configured for GitHub, Bitbucket, and GitLab.com' optional :disabled_oauth_sign_in_sources, type: Array[String], desc: 'Disable certain OAuth sign-in sources' optional :enabled_git_access_protocol, type: String, values: %w[ssh http nil], desc: 'Allow only the selected protocols to be used for Git access.' + optional :project_export_enabled, type: Boolean, desc: 'Enable project export' optional :gravatar_enabled, type: Boolean, desc: 'Flag indicating if the Gravatar service is enabled' optional :default_projects_limit, type: Integer, desc: 'The maximum number of personal projects' optional :max_attachment_size, type: Integer, desc: 'Maximum attachment size in MB' diff --git a/lib/api/users.rb b/lib/api/users.rb index a590f2692a2..e2019d6d512 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -79,22 +79,17 @@ module API end desc 'Get a single user' do - success Entities::UserBasic + success Entities::User end params do requires :id, type: Integer, desc: 'The ID of the user' end get ":id" do user = User.find_by(id: params[:id]) - not_found!('User') unless user + not_found!('User') unless user && can?(current_user, :read_user, user) - if current_user && current_user.admin? - present user, with: Entities::UserPublic - elsif can?(current_user, :read_user, user) - present user, with: Entities::User - else - render_api_error!("User not found.", 404) - end + opts = current_user&.admin? ? { with: Entities::UserWithAdmin } : {} + present user, opts end desc 'Create a user. Available only for admins.' do diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb index 4a2e9c9cbb0..a9a35f2a4bd 100644 --- a/lib/api/v3/entities.rb +++ b/lib/api/v3/entities.rb @@ -25,14 +25,24 @@ module API expose(:downvote?) { |note| false } end + class PushEventPayload < Grape::Entity + expose :commit_count, :action, :ref_type, :commit_from, :commit_to + expose :ref, :commit_title + end + class Event < Grape::Entity expose :title, :project_id, :action_name expose :target_id, :target_type, :author_id - expose :data, :target_title + expose :target_title expose :created_at expose :note, using: Entities::Note, if: ->(event, options) { event.note? } expose :author, using: ::API::Entities::UserBasic, if: ->(event, options) { event.author } + expose :push_event_payload, + as: :push_data, + using: PushEventPayload, + if: -> (event, _) { event.push? } + expose :author_username do |event, options| event.author&.username end |