Class: Projects::ProtectedBranchesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/projects/protected_branches_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#createObject


13
14
15
16
17
# File 'app/controllers/projects/protected_branches_controller.rb', line 13

def create
  @project.protected_branches.create(protected_branch_params)
  redirect_to namespace_project_protected_branches_path(@project.namespace,
                                                        @project)
end

#destroyObject


37
38
39
40
41
42
43
44
# File 'app/controllers/projects/protected_branches_controller.rb', line 37

def destroy
  @project.protected_branches.find(params[:id]).destroy

  respond_to do |format|
    format.html { redirect_to namespace_project_protected_branches_path }
    format.js { render nothing: true }
  end
end

#indexObject


8
9
10
11
# File 'app/controllers/projects/protected_branches_controller.rb', line 8

def index
  @branches = @project.protected_branches.to_a
  @protected_branch = @project.protected_branches.new
end

#updateObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/projects/protected_branches_controller.rb', line 19

def update
  protected_branch = @project.protected_branches.find(params[:id])

  if protected_branch &&
     protected_branch.update_attributes(
       developers_can_push: params[:developers_can_push]
     )

    respond_to do |format|
      format.json { render json: protected_branch, status: :ok }
    end
  else
    respond_to do |format|
      format.json { render json: protected_branch.errors, status: :unprocessable_entity }
    end
  end
end