From b718803bd97c2e51572047a0f2c98ae5ad9686be Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 1 Aug 2016 16:54:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=8F=8A=E6=8E=A7=E5=88=B6=E5=99=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=AE=BF=E9=97=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/pull_requests.js.coffee | 3 ++ app/assets/stylesheets/pull_requests.css.scss | 3 ++ app/controllers/pull_requests_controller.rb | 36 +++++++++++++++++++ app/controllers/pull_rquests_controller.rb | 14 +++++++- app/helpers/pull_requests_helper.rb | 2 ++ .../projects/_development_group.html.erb | 2 +- app/views/pull_requests/index.html.erb | 0 app/views/pull_requests/new.html.erb | 0 app/views/pull_requests/show.html.erb | 0 config/routes.rb | 2 +- .../pull_requests_controller_spec.rb | 5 +++ 11 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/pull_requests.js.coffee create mode 100644 app/assets/stylesheets/pull_requests.css.scss create mode 100644 app/controllers/pull_requests_controller.rb create mode 100644 app/helpers/pull_requests_helper.rb create mode 100644 app/views/pull_requests/index.html.erb create mode 100644 app/views/pull_requests/new.html.erb create mode 100644 app/views/pull_requests/show.html.erb create mode 100644 spec/controllers/pull_requests_controller_spec.rb diff --git a/app/assets/javascripts/pull_requests.js.coffee b/app/assets/javascripts/pull_requests.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/pull_requests.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/pull_requests.css.scss b/app/assets/stylesheets/pull_requests.css.scss new file mode 100644 index 000000000..f69ac413b --- /dev/null +++ b/app/assets/stylesheets/pull_requests.css.scss @@ -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/ diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb new file mode 100644 index 000000000..61fb9c9e4 --- /dev/null +++ b/app/controllers/pull_requests_controller.rb @@ -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 diff --git a/app/controllers/pull_rquests_controller.rb b/app/controllers/pull_rquests_controller.rb index aaef56595..230f832bd 100644 --- a/app/controllers/pull_rquests_controller.rb +++ b/app/controllers/pull_rquests_controller.rb @@ -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 diff --git a/app/helpers/pull_requests_helper.rb b/app/helpers/pull_requests_helper.rb new file mode 100644 index 000000000..fa8554854 --- /dev/null +++ b/app/helpers/pull_requests_helper.rb @@ -0,0 +1,2 @@ +module PullRequestsHelper +end diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index d8d25dd3d..4dec58793 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -59,7 +59,7 @@ <% if allow_pull_request(@project) %>