diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-05 20:04:11 -0500 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-06 21:20:16 -0500 |
commit | a475411f4380ef4d0260940206e2553da3b2f3ee (patch) | |
tree | f9e67c7dc2476f57fdf30a2a9e55eb323759d0b6 | |
parent | 2c6c61815edada16c4477c938209c24c647e1798 (diff) | |
download | gitlab-ce-a475411f4380ef4d0260940206e2553da3b2f3ee.tar.gz |
Fixes broken schema and minor changes
-rw-r--r-- | app/controllers/projects/settings/repository_controller.rb | 4 | ||||
-rw-r--r-- | app/views/projects/deploy_tokens/_new_deploy_token.html.haml | 7 | ||||
-rw-r--r-- | db/schema.rb | 1 | ||||
-rw-r--r-- | doc/user/project/deploy_tokens/index.md | 4 | ||||
-rw-r--r-- | lib/gitlab/auth.rb | 4 | ||||
-rw-r--r-- | spec/controllers/projects/deploy_tokens_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/auth_spec.rb | 2 |
7 files changed, 11 insertions, 12 deletions
diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index c085870dacd..5dfd3af1d55 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -10,8 +10,8 @@ module Projects def create_deploy_token @new_deploy_token = DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute - if @new_deploy_token.valid? - flash[:notice] = 'Your new project deploy token has been created.' + if @new_deploy_token.persisted? + flash.now[:notice] = 'Your new project deploy token has been created.' end render_show diff --git a/app/views/projects/deploy_tokens/_new_deploy_token.html.haml b/app/views/projects/deploy_tokens/_new_deploy_token.html.haml index 82268e7900c..1e715681e59 100644 --- a/app/views/projects/deploy_tokens/_new_deploy_token.html.haml +++ b/app/views/projects/deploy_tokens/_new_deploy_token.html.haml @@ -4,12 +4,11 @@ .form-group = text_field_tag 'deploy-token-user', deploy_token.username, readonly: true, class: 'deploy-token-field form-control js-select-on-focus' - = clipboard_button(text: deploy_token.username, title: s_('DeployTokens|Copy deploy token username to clipboard'), placement: 'left') - %span.help-block.prepend-top-5.text-success= s_("DeployTokens|Use this username as a login.") + = clipboard_button(text: deploy_token.username, title: s_('DeployTokens|Copy username to clipboard'), placement: 'left') + %span.deploy-token-help-block.prepend-top-5.text-success= s_("DeployTokens|Use this username as a login.") .form-group = text_field_tag 'deploy-token', deploy_token.token, readonly: true, class: 'deploy-token-field form-control js-select-on-focus' = clipboard_button(text: deploy_token.token, title: s_('DeployTokens|Copy deploy token to clipboard'), placement: 'left') - %span.help-block.prepend-top-5.text-danger= s_("DeployTokens|Use this token as a password. Make sure you save it - you won't be able to access it again.") - + %span.deploy-token-help-block.prepend-top-5.text-danger= s_("DeployTokens|Use this token as a password. Make sure you save it - you won't be able to access it again.") %hr diff --git a/db/schema.rb b/db/schema.rb index 50b8635cb96..0c8938b015d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1639,7 +1639,6 @@ ActiveRecord::Schema.define(version: 20180405142733) do t.string "path", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "permanent" end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree diff --git a/doc/user/project/deploy_tokens/index.md b/doc/user/project/deploy_tokens/index.md index 44e95bbcda0..72a1a1ccabc 100644 --- a/doc/user/project/deploy_tokens/index.md +++ b/doc/user/project/deploy_tokens/index.md @@ -7,7 +7,7 @@ Deploy tokens allow to download (through `git clone`), or read the container reg Please note, that the expiration of deploy tokens happens on the date you define, at midnight UTC and that they can be only managed by [masters](https://docs.gitlab.com/ee/user/permissions.html). -## Creating a personal access token +## Creating a Deploy Token You can create as many deploy tokens as you like from the settings of your project: @@ -36,7 +36,7 @@ the following table. | Scope | Description | | ----- | ----------- | -|`read_repository` | Allows read-access to the repository through `git clone` | +| `read_repository` | Allows read-access to the repository through `git clone` | | `read_registry` | Allows read-access to [container registry] images if a project is private and authorization is required. | ## Usage diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index d03b1caca91..13a59bb4a76 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -164,8 +164,8 @@ module Gitlab def abilities_for_scopes(scopes) abilities_by_scope = { api: full_authentication_abilities, - read_registry: build_authentication_abilities - [:build_create_container_image], - read_repository: read_authentication_abilities - [:read_container_image] + read_registry: [:build_read_container_image], + read_repository: [:download_code] } scopes.flat_map do |scope| diff --git a/spec/controllers/projects/deploy_tokens_controller_spec.rb b/spec/controllers/projects/deploy_tokens_controller_spec.rb index f037aacfe8e..8de564a56af 100644 --- a/spec/controllers/projects/deploy_tokens_controller_spec.rb +++ b/spec/controllers/projects/deploy_tokens_controller_spec.rb @@ -11,6 +11,7 @@ describe Projects::DeployTokensController do describe 'POST #create' do let(:deploy_token_params) { attributes_for(:deploy_token) } + subject do post :create, namespace_id: project.namespace, diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index db517c25ef4..7be888d812f 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -264,7 +264,7 @@ describe Gitlab::Auth do let(:deploy_token) { create(:deploy_token, read_registry: false, projects: [project]) } it 'succeeds when project is present, token is valid and has read_repository as scope' do - abilities = %i(read_project download_code) + abilities = %i(download_code) auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, abilities) expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: '') |