diff options
| author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 11:43:07 +0530 |
|---|---|---|
| committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 15:20:39 +0530 |
| commit | 0a8aeb46dc187cc309ddbe23d8624f5d24b6218c (patch) | |
| tree | fc19d99c449d91ea56c65120f45d773dfdf77dcb /db | |
| parent | c93a895abc434b9b78aa7cf4d285ce309cfd868a (diff) | |
| download | gitlab-ce-0a8aeb46dc187cc309ddbe23d8624f5d24b6218c.tar.gz | |
Use `Gitlab::Access` to protected branch access levels.
1. It makes sense to reuse these constants since we had them duplicated
in the previous enum implementation. This also simplifies our
`check_access` implementation, because we can use
`project.team.max_member_access` directly.
2. Use `accepts_nested_attributes_for` to create push/merge access
levels. This was a bit fiddly to set up, but this simplifies our code
by quite a large amount. We can even get rid of
`ProtectedBranches::BaseService`.
3. Move API handling back into the API (previously in
`ProtectedBranches::BaseService#translate_api_params`.
4. The protected branch services now return a `ProtectedBranch` rather
than `true/false`.
5. Run `load_protected_branches` on-demand in the `create` action, to
prevent it being called unneccessarily.
6. "Masters" is pre-selected as the default option for "Allowed to Push"
and "Allowed to Merge".
7. These changes were based on a review from @rymai in !5081.
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20160705054938_add_protected_branches_push_access.rb | 4 | ||||
| -rw-r--r-- | db/migrate/20160705054952_add_protected_branches_merge_access.rb | 4 | ||||
| -rw-r--r-- | db/schema.rb | 16 |
3 files changed, 14 insertions, 10 deletions
diff --git a/db/migrate/20160705054938_add_protected_branches_push_access.rb b/db/migrate/20160705054938_add_protected_branches_push_access.rb index 3031574fe2a..5c14d449e71 100644 --- a/db/migrate/20160705054938_add_protected_branches_push_access.rb +++ b/db/migrate/20160705054938_add_protected_branches_push_access.rb @@ -5,7 +5,9 @@ class AddProtectedBranchesPushAccess < ActiveRecord::Migration def change create_table :protected_branch_push_access_levels do |t| t.references :protected_branch, index: { name: "index_protected_branch_push_access" }, foreign_key: true, null: false - t.integer :access_level, default: 0, null: false + + # Gitlab::Access::MASTER == 40 + t.integer :access_level, default: 40, null: false t.timestamps null: false end diff --git a/db/migrate/20160705054952_add_protected_branches_merge_access.rb b/db/migrate/20160705054952_add_protected_branches_merge_access.rb index cf1cdb8b3b6..789e3e04220 100644 --- a/db/migrate/20160705054952_add_protected_branches_merge_access.rb +++ b/db/migrate/20160705054952_add_protected_branches_merge_access.rb @@ -5,7 +5,9 @@ class AddProtectedBranchesMergeAccess < ActiveRecord::Migration def change create_table :protected_branch_merge_access_levels do |t| t.references :protected_branch, index: { name: "index_protected_branch_merge_access" }, foreign_key: true, null: false - t.integer :access_level, default: 0, null: false + + # Gitlab::Access::MASTER == 40 + t.integer :access_level, default: 40, null: false t.timestamps null: false end diff --git a/db/schema.rb b/db/schema.rb index 7a5eded8e02..2d2ae5fd840 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -868,19 +868,19 @@ ActiveRecord::Schema.define(version: 20160722221922) do add_index "projects", ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree create_table "protected_branch_merge_access_levels", force: :cascade do |t| - t.integer "protected_branch_id", null: false - t.integer "access_level", default: 0, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "protected_branch_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "protected_branch_merge_access_levels", ["protected_branch_id"], name: "index_protected_branch_merge_access", using: :btree create_table "protected_branch_push_access_levels", force: :cascade do |t| - t.integer "protected_branch_id", null: false - t.integer "access_level", default: 0, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "protected_branch_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "protected_branch_push_access_levels", ["protected_branch_id"], name: "index_protected_branch_push_access", using: :btree |
