修改控制器名称及控制器查询访问权限

This commit is contained in:
huang 2016-08-01 16:54:31 +08:00
parent 685f9d8090
commit b718803bd9
11 changed files with 64 additions and 3 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the pull_requests controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,36 @@
class PullRequestsController < ApplicationController
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show]
layout "base_projects"
def index
results = @g.merge_requests(@project.gpid)
end
def new
end
def create
end
def show
end
private
def connect_gitlab
@g = Gitlab.client
end
def find_project_and_repository
@project = Project.find(params[:project_id])
render_404 if @project.gpid.blank?
@repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab")
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -1,17 +1,29 @@
class PullRquestsController < ApplicationController
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show]
layout "base_projects"
def index
results = @g.merge_requests(@project.gpid)
end
def new
end
def create
end
private
def connect_gitlab
@g = Gitlab.client
end
def find_project_and_repository
@project = Project.find(params[:project_id])
render_404 if @project.gpid.blank?
@repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab")
rescue ActiveRecord::RecordNotFound
render_404

View File

@ -0,0 +1,2 @@
module PullRequestsHelper
end

View File

@ -59,7 +59,7 @@
<!-- more -->
<% if allow_pull_request(@project) %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_rquest_path(:project_id => @project.id), :class => "f14 c_blue02" %>
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<% unless @project.project_score.attach_num == 0 %>
<%#= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>

View File

View File

View File

View File

@ -805,7 +805,7 @@ RedmineApp::Application.routes.draw do
end
end
resources :pull_rquests do
resources :pull_requests do
collection do
end
member do

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PullRequestsController, :type => :controller do
end