Commit b6c6a5b1 authored by Alex Denisov's avatar Alex Denisov

Merge branch 'master' into ssh_keys_api

parents 87d40fd2 eed1b52f
class Admin::DashboardController < ApplicationController class Admin::DashboardController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
def index def index
@workers = Resque.workers @workers = Resque.workers
@pending_jobs = Resque.size(:post_receive) @pending_jobs = Resque.size(:post_receive)
......
class Admin::HooksController < ApplicationController class Admin::HooksController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
def index def index
@hooks = SystemHook.all @hooks = SystemHook.all
@hook = SystemHook.new @hook = SystemHook.new
...@@ -15,7 +11,7 @@ class Admin::HooksController < ApplicationController ...@@ -15,7 +11,7 @@ class Admin::HooksController < ApplicationController
redirect_to admin_hooks_path, notice: 'Hook was successfully created.' redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
else else
@hooks = SystemHook.all @hooks = SystemHook.all
render :index render :index
end end
end end
......
class Admin::LogsController < ApplicationController class Admin::LogsController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
end end
class Admin::ProjectsController < ApplicationController class Admin::ProjectsController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update] before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update]
def index def index
...@@ -43,7 +40,7 @@ class Admin::ProjectsController < ApplicationController ...@@ -43,7 +40,7 @@ class Admin::ProjectsController < ApplicationController
def update def update
owner_id = params[:project].delete(:owner_id) owner_id = params[:project].delete(:owner_id)
if owner_id if owner_id
@admin_project.owner = User.find(owner_id) @admin_project.owner = User.find(owner_id)
end end
...@@ -60,7 +57,7 @@ class Admin::ProjectsController < ApplicationController ...@@ -60,7 +57,7 @@ class Admin::ProjectsController < ApplicationController
redirect_to admin_projects_url, notice: 'Project was successfully deleted.' redirect_to admin_projects_url, notice: 'Project was successfully deleted.'
end end
private private
def admin_project def admin_project
@admin_project = Project.find_by_code(params[:id]) @admin_project = Project.find_by_code(params[:id])
......
class Admin::ResqueController < ApplicationController class Admin::ResqueController < AdminController
layout 'admin'
def show def show
end end
end end
\ No newline at end of file
class Admin::TeamMembersController < ApplicationController class Admin::TeamMembersController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
def edit def edit
@admin_team_member = UsersProject.find(params[:id]) @admin_team_member = UsersProject.find(params[:id])
end end
......
class Admin::UsersController < ApplicationController class Admin::UsersController < AdminController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
def index def index
@admin_users = User.scoped @admin_users = User.scoped
@admin_users = @admin_users.filter(params[:filter]) @admin_users = @admin_users.filter(params[:filter])
...@@ -24,7 +20,7 @@ class Admin::UsersController < ApplicationController ...@@ -24,7 +20,7 @@ class Admin::UsersController < ApplicationController
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
UsersProject.user_bulk_import( UsersProject.user_bulk_import(
@admin_user, @admin_user,
params[:project_ids], params[:project_ids],
params[:project_access] params[:project_access]
) )
...@@ -41,22 +37,22 @@ class Admin::UsersController < ApplicationController ...@@ -41,22 +37,22 @@ class Admin::UsersController < ApplicationController
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
end end
def block def block
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
if @admin_user.block if @admin_user.block
redirect_to :back, alert: "Successfully blocked" redirect_to :back, alert: "Successfully blocked"
else else
redirect_to :back, alert: "Error occured. User was not blocked" redirect_to :back, alert: "Error occured. User was not blocked"
end end
end end
def unblock def unblock
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
if @admin_user.update_attribute(:blocked, false) if @admin_user.update_attribute(:blocked, false)
redirect_to :back, alert: "Successfully unblocked" redirect_to :back, alert: "Successfully unblocked"
else else
redirect_to :back, alert: "Error occured. User was not unblocked" redirect_to :back, alert: "Error occured. User was not unblocked"
end end
end end
......
# Provides a base class for Admin controllers to subclass
#
# Automatically sets the layout and ensures an administrator is logged in
class AdminController < ApplicationController
layout 'admin'
before_filter :authenticate_admin!
def authenticate_admin!
return render_404 unless current_user.is_admin?
end
end
...@@ -84,10 +84,6 @@ class ApplicationController < ActionController::Base ...@@ -84,10 +84,6 @@ class ApplicationController < ActionController::Base
abilities << Ability abilities << Ability
end end
def authenticate_admin!
return render_404 unless current_user.is_admin?
end
def authorize_project!(action) def authorize_project!(action)
return access_denied! unless can?(current_user, action, project) return access_denied! unless can?(current_user, action, project)
end end
......
...@@ -17,7 +17,7 @@ class IssuesController < ApplicationController ...@@ -17,7 +17,7 @@ class IssuesController < ApplicationController
before_filter :authorize_write_issue!, only: [:new, :create] before_filter :authorize_write_issue!, only: [:new, :create]
# Allow modify issue # Allow modify issue
before_filter :authorize_modify_issue!, only: [:close, :edit, :update] before_filter :authorize_modify_issue!, only: [:edit, :update]
# Allow destroy issue # Allow destroy issue
before_filter :authorize_admin_issue!, only: [:destroy] before_filter :authorize_admin_issue!, only: [:destroy]
...@@ -87,8 +87,6 @@ class IssuesController < ApplicationController ...@@ -87,8 +87,6 @@ class IssuesController < ApplicationController
end end
def destroy def destroy
return access_denied! unless can?(current_user, :admin_issue, @issue)
@issue.destroy @issue.destroy
respond_to do |format| respond_to do |format|
......
...@@ -16,9 +16,6 @@ class ProfileController < ApplicationController ...@@ -16,9 +16,6 @@ class ProfileController < ApplicationController
def token def token
end end
def password
end
def password_update def password_update
params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"} params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}
......
...@@ -5,7 +5,10 @@ class TeamMembersController < ApplicationController ...@@ -5,7 +5,10 @@ class TeamMembersController < ApplicationController
# Authorize # Authorize
before_filter :add_project_abilities before_filter :add_project_abilities
before_filter :authorize_read_project! before_filter :authorize_read_project!
before_filter :authorize_admin_project!, except: [:show] before_filter :authorize_admin_project!, except: [:index, :show]
def index
end
def show def show
@team_member = project.users_projects.find(params[:id]) @team_member = project.users_projects.find(params[:id])
...@@ -22,7 +25,7 @@ class TeamMembersController < ApplicationController ...@@ -22,7 +25,7 @@ class TeamMembersController < ApplicationController
params[:project_access] params[:project_access]
) )
redirect_to team_project_path(@project) redirect_to project_team_index_path(@project)
end end
def update def update
...@@ -32,7 +35,7 @@ class TeamMembersController < ApplicationController ...@@ -32,7 +35,7 @@ class TeamMembersController < ApplicationController
unless @team_member.valid? unless @team_member.valid?
flash[:alert] = "User should have at least one role" flash[:alert] = "User should have at least one role"
end end
redirect_to team_project_path(@project) redirect_to project_team_index_path(@project)
end end
def destroy def destroy
...@@ -40,7 +43,7 @@ class TeamMembersController < ApplicationController ...@@ -40,7 +43,7 @@ class TeamMembersController < ApplicationController
@team_member.destroy @team_member.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to team_project_path(@project) } format.html { redirect_to project_team_index_path(@project) }
format.js { render nothing: true } format.js { render nothing: true }
end end
end end
......
...@@ -62,7 +62,7 @@ module ApplicationHelper ...@@ -62,7 +62,7 @@ module ApplicationHelper
{ label: "#{@project.name} / Wall", url: wall_project_path(@project) }, { label: "#{@project.name} / Wall", url: wall_project_path(@project) },
{ label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) }, { label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) },
{ label: "#{@project.name} / Commits", url: project_commits_path(@project) }, { label: "#{@project.name} / Commits", url: project_commits_path(@project) },
{ label: "#{@project.name} / Team", url: team_project_path(@project) } { label: "#{@project.name} / Team", url: project_team_index_path(@project) }
] ]
end end
......
...@@ -8,7 +8,7 @@ module TabHelper ...@@ -8,7 +8,7 @@ module TabHelper
end end
def project_tab_class def project_tab_class
[:show, :files, :team, :edit, :update].each do |action| [:show, :files, :edit, :update].each do |action|
return "current" if current_page?(controller: "projects", action: action, id: @project) return "current" if current_page?(controller: "projects", action: action, id: @project)
end end
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
= link_to project_path(@project), class: "activities-tab tab" do = link_to project_path(@project), class: "activities-tab tab" do
%i.icon-home %i.icon-home
Show Show
%li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(team_project_path(@project)) }" } %li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(project_team_index_path(@project)) }" }
= link_to team_project_path(@project), class: "team-tab tab" do = link_to project_team_index_path(@project), class: "team-tab tab" do
%i.icon-user %i.icon-user
Team Team
%li{ class: "#{'active' if current_page?(files_project_path(@project)) }" } %li{ class: "#{'active' if current_page?(files_project_path(@project)) }" }
......
...@@ -20,4 +20,4 @@ ...@@ -20,4 +20,4 @@
.actions .actions
= f.submit 'Save', class: "btn save-btn" = f.submit 'Save', class: "btn save-btn"
= link_to "Cancel", team_project_path(@project), class: "btn cancel-btn" = link_to "Cancel", project_team_index_path(@project), class: "btn cancel-btn"
= render "project_head" = render "projects/project_head"
%h3.page_title %h3.page_title
Team Members Team Members
%small (#{@project.users_projects.count}) %small (#{@project.users_projects.count})
...@@ -10,6 +10,4 @@ ...@@ -10,6 +10,4 @@
Read more about project permissions Read more about project permissions
%strong= link_to "here", help_permissions_path, class: "vlink" %strong= link_to "here", help_permissions_path, class: "vlink"
= render partial: "team_members/team", locals: {project: @project}
= render partial: "team", locals: {project: @project}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
%hr %hr
.back_link .back_link
%br %br
= link_to team_project_path(@project), class: "" do = link_to project_team_index_path(@project), class: "" do
&larr; To team list &larr; To team list
%br %br
.row .row
......
...@@ -10,7 +10,7 @@ Gitlab::Application.routes.draw do ...@@ -10,7 +10,7 @@ Gitlab::Application.routes.draw do
# Optionally, enable Resque here # Optionally, enable Resque here
require 'resque/server' require 'resque/server'
mount Resque::Server.new, at: '/info/resque', as: 'resque' mount Resque::Server => '/info/resque', as: 'resque'
# Enable Grack support # Enable Grack support
mount Grack::Bundle.new({ mount Grack::Bundle.new({
...@@ -23,14 +23,14 @@ Gitlab::Application.routes.draw do ...@@ -23,14 +23,14 @@ Gitlab::Application.routes.draw do
# #
# Help # Help
# #
get 'help' => 'help#index' get 'help' => 'help#index'
get 'help/permissions' => 'help#permissions' get 'help/permissions' => 'help#permissions'
get 'help/workflow' => 'help#workflow' get 'help/workflow' => 'help#workflow'
get 'help/api' => 'help#api' get 'help/api' => 'help#api'
get 'help/web_hooks' => 'help#web_hooks' get 'help/web_hooks' => 'help#web_hooks'
get 'help/system_hooks' => 'help#system_hooks' get 'help/system_hooks' => 'help#system_hooks'
get 'help/markdown' => 'help#markdown' get 'help/markdown' => 'help#markdown'
get 'help/ssh' => 'help#ssh' get 'help/ssh' => 'help#ssh'
# #
# Admin Area # Admin Area
...@@ -43,19 +43,19 @@ Gitlab::Application.routes.draw do ...@@ -43,19 +43,19 @@ Gitlab::Application.routes.draw do
put :unblock put :unblock
end end
end end
resources :projects, :constraints => { :id => /[^\/]+/ } do resources :projects, constraints: { id: /[^\/]+/ } do
member do member do
get :team get :team
put :team_update put :team_update
end end
end end
resources :team_members, :only => [:edit, :update, :destroy] resources :team_members, only: [:edit, :update, :destroy]
resources :hooks, :only => [:index, :create, :destroy] do resources :hooks, only: [:index, :create, :destroy] do
get :test get :test
end end
resource :logs resource :logs, only: [:show]
resource :resque, :controller => 'resque' resource :resque, controller: 'resque', only: [:show]
root :to => "dashboard#index" root to: "dashboard#index"
end end
get "errors/githost" get "errors/githost"
...@@ -63,39 +63,39 @@ Gitlab::Application.routes.draw do ...@@ -63,39 +63,39 @@ Gitlab::Application.routes.draw do
# #
# Profile Area # Profile Area
# #
get "profile/account", :to => "profile#account" get "profile/account" => "profile#account"
get "profile/history", :to => "profile#history" get "profile/history" => "profile#history"
put "profile/password", :to => "profile#password_update" put "profile/password" => "profile#password_update"
get "profile/token", :to => "profile#token" get "profile/token" => "profile#token"
put "profile/reset_private_token", :to => "profile#reset_private_token" put "profile/reset_private_token" => "profile#reset_private_token"
get "profile", :to => "profile#show" get "profile" => "profile#show"
get "profile/design", :to => "profile#design" get "profile/design" => "profile#design"
put "profile/update", :to => "profile#update" put "profile/update" => "profile#update"
resources :keys resources :keys
# #
# Dashboard Area # Dashboard Area
# #
get "dashboard", :to => "dashboard#index" get "dashboard" => "dashboard#index"
get "dashboard/issues", :to => "dashboard#issues" get "dashboard/issues" => "dashboard#issues"
get "dashboard/merge_requests", :to => "dashboard#merge_requests" get "dashboard/merge_requests" => "dashboard#merge_requests"
resources :projects, :constraints => { :id => /[^\/]+/ }, :only => [:new, :create] resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
devise_for :users, :controllers => { :omniauth_callbacks => :omniauth_callbacks } devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks }
# #
# Project Area # Project Area
# #
resources :projects, :constraints => { :id => /[^\/]+/ }, :except => [:new, :create, :index], :path => "/" do resources :projects, constraints: { id: /[^\/]+/ }, except: [:new, :create, :index], path: "/" do
member do member do
get "team"
get "wall" get "wall"
get "graph" get "graph"
get "files" get "files"
end end
resources :wikis, :only => [:show, :edit, :destroy, :create] do resources :wikis, only: [:show, :edit, :destroy, :create] do
collection do collection do
get :pages get :pages
end end
...@@ -114,46 +114,45 @@ Gitlab::Application.routes.draw do ...@@ -114,46 +114,45 @@ Gitlab::Application.routes.draw do
end end
resources :deploy_keys resources :deploy_keys
resources :protected_branches, :only => [:index, :create, :destroy] resources :protected_branches, only: [:index, :create, :destroy]
resources :refs, :only => [], :path => "/" do resources :refs, only: [], path: "/" do
collection do collection do
get "switch" get "switch"
end end
member do member do
get "tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ } get "tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
get "logs_tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ } get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
get "blob", get "blob",
:constraints => { constraints: {
:id => /[a-zA-Z.0-9\/_\-]+/, id: /[a-zA-Z.0-9\/_\-]+/,
:path => /.*/ path: /.*/
} }
# tree viewer # tree viewer
get "tree/:path" => "refs#tree", get "tree/:path" => "refs#tree",
:as => :tree_file, as: :tree_file,
:constraints => { constraints: {
:id => /[a-zA-Z.0-9\/_\-]+/, id: /[a-zA-Z.0-9\/_\-]+/,
:path => /.*/ path: /.*/
} }
# tree viewer # tree viewer
get "logs_tree/:path" => "refs#logs_tree", get "logs_tree/:path" => "refs#logs_tree",
:as => :logs_file, as: :logs_file,
:constraints => { constraints: {
:id => /[a-zA-Z.0-9\/_\-]+/, id: /[a-zA-Z.0-9\/_\-]+/,
:path => /.*/ path: /.*/
} }
# blame # blame
get "blame/:path" => "refs#blame", get "blame/:path" => "refs#blame",
:as => :blame_file, as: :blame_file,
:constraints => { constraints: {
:id => /[a-zA-Z.0-9\/_\-]+/, id: /[a-zA-Z.0-9\/_\-]+/,
:path => /.*/ path: /.*/
} }
end end
end end
...@@ -178,7 +177,7 @@ Gitlab::Application.routes.draw do ...@@ -178,7 +177,7 @@ Gitlab::Application.routes.draw do
end end
end end
resources :hooks, :only => [:index, :create, :destroy] do resources :hooks, only: [:index, :create, :destroy] do
member do member do
get :test get :test
end end
...@@ -192,9 +191,10 @@ Gitlab::Application.routes.draw do ...@@ -192,9 +191,10 @@ Gitlab::Application.routes.draw do
get :patch get :patch
end end
end end
resources :team, controller: 'team_members', only: [:index]
resources :team_members resources :team_members
resources :milestones resources :milestones
resources :labels, :only => [:index] resources :labels, only: [:index]
resources :issues do resources :issues do
collection do collection do
...@@ -203,11 +203,12 @@ Gitlab::Application.routes.draw do ...@@ -203,11 +203,12 @@ Gitlab::Application.routes.draw do
get :search get :search
end end
end end
resources :notes, :only => [:index, :create, :destroy] do resources :notes, only: [:index, :create, :destroy] do
collection do collection do
post :preview post :preview
end end
end end
end end
root :to => "dashboard#index"
root to: "dashboard#index"
end end
...@@ -98,7 +98,7 @@ module SharedPaths ...@@ -98,7 +98,7 @@ module SharedPaths
end end
Then 'I visit project "Shop" team page' do Then 'I visit project "Shop" team page' do
visit team_project_path(Project.find_by_name("Shop")) visit project_team_index_path(Project.find_by_name("Shop"))
end end
Then 'I visit project "Shop" wall page' do Then 'I visit project "Shop" wall page' do
......
...@@ -28,6 +28,14 @@ module Gitlab ...@@ -28,6 +28,14 @@ module Gitlab
end end
end end
def attributes_for_keys(keys)
attrs = {}
keys.each do |key|
attrs[key] = params[key] if params[key].present?
end
attrs
end
# error helpers # error helpers
def forbidden! def forbidden!
......
...@@ -48,15 +48,10 @@ module Gitlab ...@@ -48,15 +48,10 @@ module Gitlab
# Example Request: # Example Request:
# POST /projects/:id/issues # POST /projects/:id/issues
post ":id/issues" do post ":id/issues" do
@issue = user_project.issues.new( attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id]
title: params[:title], attrs[:label_list] = params[:labels] if params[:labels].present?
description: params[:description], @issue = user_project.issues.new attrs
assignee_id: params[:assignee_id],
milestone_id: params[:milestone_id],
label_list: params[:labels]
)
@issue.author = current_user @issue.author = current_user
if @issue.save if @issue.save
present @issue, with: Entities::Issue present @issue, with: Entities::Issue
else else
...@@ -81,16 +76,9 @@ module Gitlab ...@@ -81,16 +76,9 @@ module Gitlab
@issue = user_project.issues.find(params[:issue_id]) @issue = user_project.issues.find(params[:issue_id])
authorize! :modify_issue, @issue authorize! :modify_issue, @issue
parameters = { attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :closed]
title: (params[:title] || @issue.title), attrs[:label_list] = params[:labels] if params[:labels].present?
description: (params[:description] || @issue.description), if @issue.update_attributes attrs
assignee_id: (params[:assignee_id] || @issue.assignee_id),
milestone_id: (params[:milestone_id] || @issue.milestone_id),
label_list: (params[:labels] || @issue.label_list),
closed: (params[:closed] || @issue.closed)
}
if @issue.update_attributes(parameters)
present @issue, with: Entities::Issue present @issue, with: Entities::Issue
else else
not_found! not_found!
......
...@@ -36,12 +36,8 @@ module Gitlab ...@@ -36,12 +36,8 @@ module Gitlab
# Example Request: # Example Request:
# POST /projects/:id/milestones # POST /projects/:id/milestones
post ":id/milestones" do post ":id/milestones" do
@milestone = user_project.milestones.new( attrs = attributes_for_keys [:title, :description, :due_date]
title: params[:title], @milestone = user_project.milestones.new attrs
description: params[:description],
due_date: params[:due_date]
)
if @milestone.save if @milestone.save
present @milestone, with: Entities::Milestone present @milestone, with: Entities::Milestone
else else
...@@ -64,14 +60,8 @@ module Gitlab ...@@ -64,14 +60,8 @@ module Gitlab
authorize! :admin_milestone, user_project authorize! :admin_milestone, user_project
@milestone = user_project.milestones.find(params[:milestone_id]) @milestone = user_project.milestones.find(params[:milestone_id])
parameters = { attrs = attributes_for_keys [:title, :description, :due_date, :closed]
title: (params[:title] || @milestone.title), if @milestone.update_attributes attrs
description: (params[:description] || @milestone.description),
due_date: (params[:due_date] || @milestone.due_date),
closed: (params[:closed] || @milestone.closed)
}
if @milestone.update_attributes(parameters)
present @milestone, with: Entities::Milestone present @milestone, with: Entities::Milestone
else else
not_found! not_found!
......
...@@ -40,13 +40,16 @@ module Gitlab ...@@ -40,13 +40,16 @@ module Gitlab
post do post do
params[:code] ||= params[:name] params[:code] ||= params[:name]
params[:path] ||= params[:name] params[:path] ||= params[:name]
project_attrs = {} attrs = attributes_for_keys [:code,
params.each_pair do |k ,v| :path,
if Project.attribute_names.include? k :name,
project_attrs[k] = v :description,
end :default_branch,
end :issues_enabled,
@project = Project.create_by_user(project_attrs, current_user) :wall_enabled,
:merge_requests_enabled,
:wiki_enabled]
@project = Project.create_by_user(attrs, current_user)
if @project.saved? if @project.saved?
present @project, with: Entities::Project present @project, with: Entities::Project
else else
...@@ -204,12 +207,10 @@ module Gitlab ...@@ -204,12 +207,10 @@ module Gitlab
# Example Request: # Example Request:
# POST /projects/:id/snippets # POST /projects/:id/snippets
post ":id/snippets" do post ":id/snippets" do
@snippet = user_project.snippets.new( attrs = attributes_for_keys [:title, :file_name]
title: params[:title], attrs[:expires_at] = params[:lifetime] if params[:lifetime].present?
file_name: params[:file_name], attrs[:content] = params[:code] if params[:code].present?
expires_at: params[:lifetime], @snippet = user_project.snippets.new attrs
content: params[:code]
)
@snippet.author = current_user @snippet.author = current_user
if @snippet.save if @snippet.save
...@@ -234,14 +235,11 @@ module Gitlab ...@@ -234,14 +235,11 @@ module Gitlab
@snippet = user_project.snippets.find(params[:snippet_id]) @snippet = user_project.snippets.find(params[:snippet_id])
authorize! :modify_snippet, @snippet authorize! :modify_snippet, @snippet
parameters = { attrs = attributes_for_keys [:title, :file_name]
title: (params[:title] || @snippet.title), attrs[:expires_at] = params[:lifetime] if params[:lifetime].present?
file_name: (params[:file_name] || @snippet.file_name), attrs[:content] = params[:code] if params[:code].present?
expires_at: (params[:lifetime] || @snippet.expires_at),
content: (params[:code] || @snippet.content)
}
if @snippet.update_attributes(parameters) if @snippet.update_attributes attrs
present @snippet, with: Entities::ProjectSnippet present @snippet, with: Entities::ProjectSnippet
else else
not_found! not_found!
......
...@@ -70,7 +70,7 @@ describe "Application access" do ...@@ -70,7 +70,7 @@ describe "Application access" do
end end
describe "GET /project_code/team" do describe "GET /project_code/team" do
subject { team_project_path(@project) } subject { project_team_index_path(@project) }
it { should be_allowed_for @u1 } it { should be_allowed_for @u1 }
it { should be_allowed_for @u3 } it { should be_allowed_for @u3 }
......
require 'spec_helper'
# team_update_admin_user PUT /admin/users/:id/team_update(.:format) admin/users#team_update
# block_admin_user PUT /admin/users/:id/block(.:format) admin/users#block
# unblock_admin_user PUT /admin/users/:id/unblock(.:format) admin/users#unblock
# admin_users GET /admin/users(.:format) admin/users#index
# POST /admin/users(.:format) admin/users#create
# new_admin_user GET /admin/users/new(.:format) admin/users#new
# edit_admin_user GET /admin/users/:id/edit(.:format) admin/users#edit
# admin_user GET /admin/users/:id(.:format) admin/users#show
# PUT /admin/users/:id(.:format) admin/users#update
# DELETE /admin/users/:id(.:format) admin/users#destroy
describe Admin::UsersController, "routing" do
it "to #team_update" do
put("/admin/users/1/team_update").should route_to('admin/users#team_update', id: '1')
end
it "to #block" do
put("/admin/users/1/block").should route_to('admin/users#block', id: '1')
end
it "to #unblock" do
put("/admin/users/1/unblock").should route_to('admin/users#unblock', id: '1')
end
it "to #index" do
get("/admin/users").should route_to('admin/users#index')
end
it "to #show" do
get("/admin/users/1").should route_to('admin/users#show', id: '1')
end
it "to #create" do
post("/admin/users").should route_to('admin/users#create')
end
it "to #new" do
get("/admin/users/new").should route_to('admin/users#new')
end
it "to #edit" do
get("/admin/users/1/edit").should route_to('admin/users#edit', id: '1')
end
it "to #show" do
get("/admin/users/1").should route_to('admin/users#show', id: '1')
end
it "to #update" do
put("/admin/users/1").should route_to('admin/users#update', id: '1')
end
it "to #destroy" do
delete("/admin/users/1").should route_to('admin/users#destroy', id: '1')
end
end
# team_admin_project GET /admin/projects/:id/team(.:format) admin/projects#team {:id=>/[^\/]+/}
# team_update_admin_project PUT /admin/projects/:id/team_update(.:format) admin/projects#team_update {:id=>/[^\/]+/}
# admin_projects GET /admin/projects(.:format) admin/projects#index {:id=>/[^\/]+/}
# POST /admin/projects(.:format) admin/projects#create {:id=>/[^\/]+/}
# new_admin_project GET /admin/projects/new(.:format) admin/projects#new {:id=>/[^\/]+/}
# edit_admin_project GET /admin/projects/:id/edit(.:format) admin/projects#edit {:id=>/[^\/]+/}
# admin_project GET /admin/projects/:id(.:format) admin/projects#show {:id=>/[^\/]+/}
# PUT /admin/projects/:id(.:format) admin/projects#update {:id=>/[^\/]+/}
# DELETE /admin/projects/:id(.:format) admin/projects#destroy {:id=>/[^\/]+/}
describe Admin::ProjectsController, "routing" do
it "to #team" do
get("/admin/projects/gitlab/team").should route_to('admin/projects#team', id: 'gitlab')
end
it "to #team_update" do
put("/admin/projects/gitlab/team_update").should route_to('admin/projects#team_update', id: 'gitlab')
end
it "to #index" do
get("/admin/projects").should route_to('admin/projects#index')
end
it "to #create" do
post("/admin/projects").should route_to('admin/projects#create')
end
it "to #new" do
get("/admin/projects/new").should route_to('admin/projects#new')
end
it "to #edit" do
get("/admin/projects/gitlab/edit").should route_to('admin/projects#edit', id: 'gitlab')
end
it "to #show" do
get("/admin/projects/gitlab").should route_to('admin/projects#show', id: 'gitlab')
end
it "to #update" do
put("/admin/projects/gitlab").should route_to('admin/projects#update', id: 'gitlab')
end
it "to #destroy" do
delete("/admin/projects/gitlab").should route_to('admin/projects#destroy', id: 'gitlab')
end
end
# edit_admin_team_member GET /admin/team_members/:id/edit(.:format) admin/team_members#edit
# admin_team_member PUT /admin/team_members/:id(.:format) admin/team_members#update
# DELETE /admin/team_members/:id(.:format) admin/team_members#destroy
describe Admin::TeamMembersController, "routing" do
it "to #edit" do
get("/admin/team_members/1/edit").should route_to('admin/team_members#edit', id: '1')
end
it "to #update" do
put("/admin/team_members/1").should route_to('admin/team_members#update', id: '1')
end
it "to #destroy" do
delete("/admin/team_members/1").should route_to('admin/team_members#destroy', id: '1')
end
end
# admin_hook_test GET /admin/hooks/:hook_id/test(.:format) admin/hooks#test
# admin_hooks GET /admin/hooks(.:format) admin/hooks#index
# POST /admin/hooks(.:format) admin/hooks#create
# admin_hook DELETE /admin/hooks/:id(.:format) admin/hooks#destroy
describe Admin::HooksController, "routing" do
it "to #test" do
get("/admin/hooks/1/test").should route_to('admin/hooks#test', hook_id: '1')
end
it "to #index" do
get("/admin/hooks").should route_to('admin/hooks#index')
end
it "to #create" do
post("/admin/hooks").should route_to('admin/hooks#create')
end
it "to #destroy" do
delete("/admin/hooks/1").should route_to('admin/hooks#destroy', id: '1')
end
end
# admin_logs GET /admin/logs(.:format) admin/logs#show
describe Admin::LogsController, "routing" do
it "to #show" do
get("/admin/logs").should route_to('admin/logs#show')
end
end
# admin_resque GET /admin/resque(.:format) admin/resque#show
describe Admin::ResqueController, "routing" do
it "to #show" do
get("/admin/resque").should route_to('admin/resque#show')
end
end
# admin_root /admin(.:format) admin/dashboard#index
describe Admin::DashboardController, "routing" do
it "to #index" do
get("/admin").should route_to('admin/dashboard#index')
end
end
This diff is collapsed.
require 'spec_helper'
# search GET /search(.:format) search#show
describe SearchController, "routing" do
it "to #show" do
get("/search").should route_to('search#show')
end
end
# gitlab_api /api Gitlab::API
# resque /info/resque Resque::Server
# /:path Grack
describe "Mounted Apps", "routing" do
it "to API" do
get("/api").should be_routable
end
it "to Resque" do
pending
get("/info/resque").should be_routable
end
it "to Grack" do
get("/gitlabhq.git").should be_routable
end
end
# help GET /help(.:format) help#index
# help_permissions GET /help/permissions(.:format) help#permissions
# help_workflow GET /help/workflow(.:format) help#workflow
# help_api GET /help/api(.:format) help#api
# help_web_hooks GET /help/web_hooks(.:format) help#web_hooks
# help_system_hooks GET /help/system_hooks(.:format) help#system_hooks
# help_markdown GET /help/markdown(.:format) help#markdown
# help_ssh GET /help/ssh(.:format) help#ssh
describe HelpController, "routing" do
it "to #index" do
get("/help").should route_to('help#index')
end
it "to #permissions" do
get("/help/permissions").should route_to('help#permissions')
end
it "to #workflow" do
get("/help/workflow").should route_to('help#workflow')
end
it "to #api" do
get("/help/api").should route_to('help#api')
end
it "to #web_hooks" do
get("/help/web_hooks").should route_to('help#web_hooks')
end
it "to #system_hooks" do
get("/help/system_hooks").should route_to('help#system_hooks')
end
it "to #markdown" do
get("/help/markdown").should route_to('help#markdown')
end
it "to #ssh" do
get("/help/ssh").should route_to('help#ssh')
end
end
# errors_githost GET /errors/githost(.:format) errors#githost
describe ErrorsController, "routing" do
it "to #githost" do
get("/errors/githost").should route_to('errors#githost')
end
end
# profile_account GET /profile/account(.:format) profile#account
# profile_history GET /profile/history(.:format) profile#history
# profile_password PUT /profile/password(.:format) profile#password_update
# profile_token GET /profile/token(.:format) profile#token
# profile_reset_private_token PUT /profile/reset_private_token(.:format) profile#reset_private_token
# profile GET /profile(.:format) profile#show
# profile_design GET /profile/design(.:format) profile#design
# profile_update PUT /profile/update(.:format) profile#update
describe ProfileController, "routing" do
it "to #account" do
get("/profile/account").should route_to('profile#account')
end
it "to #history" do
get("/profile/history").should route_to('profile#history')
end
it "to #password_update" do
put("/profile/password").should route_to('profile#password_update')
end
it "to #token" do
get("/profile/token").should route_to('profile#token')
end
it "to #reset_private_token" do
put("/profile/reset_private_token").should route_to('profile#reset_private_token')
end
it "to #show" do
get("/profile").should route_to('profile#show')
end
it "to #design" do
get("/profile/design").should route_to('profile#design')
end
it "to #update" do
put("/profile/update").should route_to('profile#update')
end
end
# keys GET /keys(.:format) keys#index
# POST /keys(.:format) keys#create
# new_key GET /keys/new(.:format) keys#new
# edit_key GET /keys/:id/edit(.:format) keys#edit
# key GET /keys/:id(.:format) keys#show
# PUT /keys/:id(.:format) keys#update
# DELETE /keys/:id(.:format) keys#destroy
describe KeysController, "routing" do
it "to #index" do
get("/keys").should route_to('keys#index')
end
it "to #create" do
post("/keys").should route_to('keys#create')
end
it "to #new" do
get("/keys/new").should route_to('keys#new')
end
it "to #edit" do
get("/keys/1/edit").should route_to('keys#edit', id: '1')
end
it "to #show" do
get("/keys/1").should route_to('keys#show', id: '1')
end
it "to #update" do
put("/keys/1").should route_to('keys#update', id: '1')
end
it "to #destroy" do
delete("/keys/1").should route_to('keys#destroy', id: '1')
end
end
# dashboard GET /dashboard(.:format) dashboard#index
# dashboard_issues GET /dashboard/issues(.:format) dashboard#issues
# dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests
# root / dashboard#index
describe DashboardController, "routing" do
it "to #index" do
get("/dashboard").should route_to('dashboard#index')
get("/").should route_to('dashboard#index')
end
it "to #issues" do
get("/dashboard/issues").should route_to('dashboard#issues')
end
it "to #merge_requests" do
get("/dashboard/merge_requests").should route_to('dashboard#merge_requests')
end
end
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
# user_session POST /users/sign_in(.:format) devise/sessions#create
# destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
# user_omniauth_authorize /users/auth/:provider(.:format) omniauth_callbacks#passthru
# user_omniauth_callback /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:(?!))
# user_password POST /users/password(.:format) devise/passwords#create
# new_user_password GET /users/password/new(.:format) devise/passwords#new
# edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
# PUT /users/password(.:format) devise/passwords#update
describe "Authentication", "routing" do
# pending
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment