Commit b6c6a5b159beeb63829c72f5d7e2c48b1138705d

Authored by Alex Denisov
2 parents 87d40fd2 eed1b52f

Merge branch 'master' into ssh_keys_api

app/controllers/admin/dashboard_controller.rb
1   -class Admin::DashboardController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
5   -
  1 +class Admin::DashboardController < AdminController
6 2 def index
7 3 @workers = Resque.workers
8 4 @pending_jobs = Resque.size(:post_receive)
... ...
app/controllers/admin/hooks_controller.rb
1   -class Admin::HooksController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
5   -
  1 +class Admin::HooksController < AdminController
6 2 def index
7 3 @hooks = SystemHook.all
8 4 @hook = SystemHook.new
... ... @@ -15,7 +11,7 @@ class Admin::HooksController &lt; ApplicationController
15 11 redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
16 12 else
17 13 @hooks = SystemHook.all
18   - render :index
  14 + render :index
19 15 end
20 16 end
21 17  
... ...
app/controllers/admin/logs_controller.rb
1   -class Admin::LogsController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
  1 +class Admin::LogsController < AdminController
5 2 end
6   -
... ...
app/controllers/admin/projects_controller.rb
1   -class Admin::ProjectsController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
  1 +class Admin::ProjectsController < AdminController
5 2 before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update]
6 3  
7 4 def index
... ... @@ -43,7 +40,7 @@ class Admin::ProjectsController &lt; ApplicationController
43 40 def update
44 41 owner_id = params[:project].delete(:owner_id)
45 42  
46   - if owner_id
  43 + if owner_id
47 44 @admin_project.owner = User.find(owner_id)
48 45 end
49 46  
... ... @@ -60,7 +57,7 @@ class Admin::ProjectsController &lt; ApplicationController
60 57 redirect_to admin_projects_url, notice: 'Project was successfully deleted.'
61 58 end
62 59  
63   - private
  60 + private
64 61  
65 62 def admin_project
66 63 @admin_project = Project.find_by_code(params[:id])
... ...
app/controllers/admin/resque_controller.rb
1   -class Admin::ResqueController < ApplicationController
2   - layout 'admin'
  1 +class Admin::ResqueController < AdminController
3 2 def show
4 3 end
5   -end
6 4 \ No newline at end of file
  5 +end
... ...
app/controllers/admin/team_members_controller.rb
1   -class Admin::TeamMembersController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
5   -
  1 +class Admin::TeamMembersController < AdminController
6 2 def edit
7 3 @admin_team_member = UsersProject.find(params[:id])
8 4 end
... ...
app/controllers/admin/users_controller.rb
1   -class Admin::UsersController < ApplicationController
2   - layout "admin"
3   - before_filter :authenticate_user!
4   - before_filter :authenticate_admin!
5   -
  1 +class Admin::UsersController < AdminController
6 2 def index
7 3 @admin_users = User.scoped
8 4 @admin_users = @admin_users.filter(params[:filter])
... ... @@ -24,7 +20,7 @@ class Admin::UsersController &lt; ApplicationController
24 20 @admin_user = User.find(params[:id])
25 21  
26 22 UsersProject.user_bulk_import(
27   - @admin_user,
  23 + @admin_user,
28 24 params[:project_ids],
29 25 params[:project_access]
30 26 )
... ... @@ -41,22 +37,22 @@ class Admin::UsersController &lt; ApplicationController
41 37 @admin_user = User.find(params[:id])
42 38 end
43 39  
44   - def block
  40 + def block
45 41 @admin_user = User.find(params[:id])
46 42  
47 43 if @admin_user.block
48 44 redirect_to :back, alert: "Successfully blocked"
49   - else
  45 + else
50 46 redirect_to :back, alert: "Error occured. User was not blocked"
51 47 end
52 48 end
53 49  
54   - def unblock
  50 + def unblock
55 51 @admin_user = User.find(params[:id])
56 52  
57 53 if @admin_user.update_attribute(:blocked, false)
58 54 redirect_to :back, alert: "Successfully unblocked"
59   - else
  55 + else
60 56 redirect_to :back, alert: "Error occured. User was not unblocked"
61 57 end
62 58 end
... ...
app/controllers/admin_controller.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +# Provides a base class for Admin controllers to subclass
  2 +#
  3 +# Automatically sets the layout and ensures an administrator is logged in
  4 +class AdminController < ApplicationController
  5 + layout 'admin'
  6 + before_filter :authenticate_admin!
  7 +
  8 + def authenticate_admin!
  9 + return render_404 unless current_user.is_admin?
  10 + end
  11 +end
... ...
app/controllers/application_controller.rb
... ... @@ -84,10 +84,6 @@ class ApplicationController &lt; ActionController::Base
84 84 abilities << Ability
85 85 end
86 86  
87   - def authenticate_admin!
88   - return render_404 unless current_user.is_admin?
89   - end
90   -
91 87 def authorize_project!(action)
92 88 return access_denied! unless can?(current_user, action, project)
93 89 end
... ...
app/controllers/issues_controller.rb
... ... @@ -17,7 +17,7 @@ class IssuesController &lt; ApplicationController
17 17 before_filter :authorize_write_issue!, only: [:new, :create]
18 18  
19 19 # Allow modify issue
20   - before_filter :authorize_modify_issue!, only: [:close, :edit, :update]
  20 + before_filter :authorize_modify_issue!, only: [:edit, :update]
21 21  
22 22 # Allow destroy issue
23 23 before_filter :authorize_admin_issue!, only: [:destroy]
... ... @@ -87,8 +87,6 @@ class IssuesController &lt; ApplicationController
87 87 end
88 88  
89 89 def destroy
90   - return access_denied! unless can?(current_user, :admin_issue, @issue)
91   -
92 90 @issue.destroy
93 91  
94 92 respond_to do |format|
... ...
app/controllers/profile_controller.rb
... ... @@ -16,9 +16,6 @@ class ProfileController &lt; ApplicationController
16 16 def token
17 17 end
18 18  
19   - def password
20   - end
21   -
22 19 def password_update
23 20 params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}
24 21  
... ...
app/controllers/team_members_controller.rb
... ... @@ -5,7 +5,10 @@ class TeamMembersController &lt; ApplicationController
5 5 # Authorize
6 6 before_filter :add_project_abilities
7 7 before_filter :authorize_read_project!
8   - before_filter :authorize_admin_project!, except: [:show]
  8 + before_filter :authorize_admin_project!, except: [:index, :show]
  9 +
  10 + def index
  11 + end
9 12  
10 13 def show
11 14 @team_member = project.users_projects.find(params[:id])
... ... @@ -22,7 +25,7 @@ class TeamMembersController &lt; ApplicationController
22 25 params[:project_access]
23 26 )
24 27  
25   - redirect_to team_project_path(@project)
  28 + redirect_to project_team_index_path(@project)
26 29 end
27 30  
28 31 def update
... ... @@ -32,7 +35,7 @@ class TeamMembersController &lt; ApplicationController
32 35 unless @team_member.valid?
33 36 flash[:alert] = "User should have at least one role"
34 37 end
35   - redirect_to team_project_path(@project)
  38 + redirect_to project_team_index_path(@project)
36 39 end
37 40  
38 41 def destroy
... ... @@ -40,7 +43,7 @@ class TeamMembersController &lt; ApplicationController
40 43 @team_member.destroy
41 44  
42 45 respond_to do |format|
43   - format.html { redirect_to team_project_path(@project) }
  46 + format.html { redirect_to project_team_index_path(@project) }
44 47 format.js { render nothing: true }
45 48 end
46 49 end
... ...
app/helpers/application_helper.rb
... ... @@ -62,7 +62,7 @@ module ApplicationHelper
62 62 { label: "#{@project.name} / Wall", url: wall_project_path(@project) },
63 63 { label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) },
64 64 { label: "#{@project.name} / Commits", url: project_commits_path(@project) },
65   - { label: "#{@project.name} / Team", url: team_project_path(@project) }
  65 + { label: "#{@project.name} / Team", url: project_team_index_path(@project) }
66 66 ]
67 67 end
68 68  
... ...
app/helpers/tab_helper.rb
... ... @@ -8,7 +8,7 @@ module TabHelper
8 8 end
9 9  
10 10 def project_tab_class
11   - [:show, :files, :team, :edit, :update].each do |action|
  11 + [:show, :files, :edit, :update].each do |action|
12 12 return "current" if current_page?(controller: "projects", action: action, id: @project)
13 13 end
14 14  
... ...
app/views/projects/_project_head.html.haml
... ... @@ -3,8 +3,8 @@
3 3 = link_to project_path(@project), class: "activities-tab tab" do
4 4 %i.icon-home
5 5 Show
6   - %li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(team_project_path(@project)) }" }
7   - = link_to team_project_path(@project), class: "team-tab tab" do
  6 + %li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(project_team_index_path(@project)) }" }
  7 + = link_to project_team_index_path(@project), class: "team-tab tab" do
8 8 %i.icon-user
9 9 Team
10 10 %li{ class: "#{'active' if current_page?(files_project_path(@project)) }" }
... ...
app/views/projects/_team.html.haml
... ... @@ -1,18 +0,0 @@
1   -- grouper_project_members(@project).each do |access, members|
2   - %table
3   - %thead
4   - %tr
5   - %th.span7
6   - = Project.access_options.key(access).pluralize
7   - %th
8   - %tbody
9   - - members.each do |up|
10   - = render(partial: 'team_members/show', locals: {member: up})
11   -
12   -
13   -:javascript
14   - $(function(){
15   - $('.repo-access-select, .project-access-select').live("change", function() {
16   - $(this.form).submit();
17   - });
18   - })
app/views/projects/team.html.haml
... ... @@ -1,15 +0,0 @@
1   -= render "project_head"
2   -%h3.page_title
3   - Team Members
4   - %small (#{@project.users_projects.count})
5   -
6   -- if can? current_user, :admin_team_member, @project
7   - %p.slead
8   - = link_to new_project_team_member_path(@project), class: "btn small right", title: "New Team Member" do
9   - New Team Member
10   - Read more about project permissions
11   - %strong= link_to "here", help_permissions_path, class: "vlink"
12   -
13   -
14   -= render partial: "team", locals: {project: @project}
15   -
app/views/team_members/_form.html.haml
... ... @@ -20,4 +20,4 @@
20 20  
21 21 .actions
22 22 = f.submit 'Save', class: "btn save-btn"
23   - = link_to "Cancel", team_project_path(@project), class: "btn cancel-btn"
  23 + = link_to "Cancel", project_team_index_path(@project), class: "btn cancel-btn"
... ...
app/views/team_members/_team.html.haml 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +- grouper_project_members(@project).each do |access, members|
  2 + %table
  3 + %thead
  4 + %tr
  5 + %th.span7
  6 + = Project.access_options.key(access).pluralize
  7 + %th
  8 + %tbody
  9 + - members.each do |up|
  10 + = render(partial: 'team_members/show', locals: {member: up})
  11 +
  12 +
  13 +:javascript
  14 + $(function(){
  15 + $('.repo-access-select, .project-access-select').live("change", function() {
  16 + $(this.form).submit();
  17 + });
  18 + })
... ...
app/views/team_members/index.html.haml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 += render "projects/project_head"
  2 +%h3.page_title
  3 + Team Members
  4 + %small (#{@project.users_projects.count})
  5 +
  6 +- if can? current_user, :admin_team_member, @project
  7 + %p.slead
  8 + = link_to new_project_team_member_path(@project), class: "btn small right", title: "New Team Member" do
  9 + New Team Member
  10 + Read more about project permissions
  11 + %strong= link_to "here", help_permissions_path, class: "vlink"
  12 +
  13 += render partial: "team_members/team", locals: {project: @project}
... ...
app/views/team_members/show.html.haml
... ... @@ -14,7 +14,7 @@
14 14 %hr
15 15 .back_link
16 16 %br
17   - = link_to team_project_path(@project), class: "" do
  17 + = link_to project_team_index_path(@project), class: "" do
18 18 &larr; To team list
19 19 %br
20 20 .row
... ...
config/routes.rb
... ... @@ -10,7 +10,7 @@ Gitlab::Application.routes.draw do
10 10  
11 11 # Optionally, enable Resque here
12 12 require 'resque/server'
13   - mount Resque::Server.new, at: '/info/resque', as: 'resque'
  13 + mount Resque::Server => '/info/resque', as: 'resque'
14 14  
15 15 # Enable Grack support
16 16 mount Grack::Bundle.new({
... ... @@ -23,14 +23,14 @@ Gitlab::Application.routes.draw do
23 23 #
24 24 # Help
25 25 #
26   - get 'help' => 'help#index'
27   - get 'help/permissions' => 'help#permissions'
28   - get 'help/workflow' => 'help#workflow'
29   - get 'help/api' => 'help#api'
30   - get 'help/web_hooks' => 'help#web_hooks'
  26 + get 'help' => 'help#index'
  27 + get 'help/permissions' => 'help#permissions'
  28 + get 'help/workflow' => 'help#workflow'
  29 + get 'help/api' => 'help#api'
  30 + get 'help/web_hooks' => 'help#web_hooks'
31 31 get 'help/system_hooks' => 'help#system_hooks'
32   - get 'help/markdown' => 'help#markdown'
33   - get 'help/ssh' => 'help#ssh'
  32 + get 'help/markdown' => 'help#markdown'
  33 + get 'help/ssh' => 'help#ssh'
34 34  
35 35 #
36 36 # Admin Area
... ... @@ -43,19 +43,19 @@ Gitlab::Application.routes.draw do
43 43 put :unblock
44 44 end
45 45 end
46   - resources :projects, :constraints => { :id => /[^\/]+/ } do
  46 + resources :projects, constraints: { id: /[^\/]+/ } do
47 47 member do
48 48 get :team
49 49 put :team_update
50 50 end
51 51 end
52   - resources :team_members, :only => [:edit, :update, :destroy]
53   - resources :hooks, :only => [:index, :create, :destroy] do
  52 + resources :team_members, only: [:edit, :update, :destroy]
  53 + resources :hooks, only: [:index, :create, :destroy] do
54 54 get :test
55 55 end
56   - resource :logs
57   - resource :resque, :controller => 'resque'
58   - root :to => "dashboard#index"
  56 + resource :logs, only: [:show]
  57 + resource :resque, controller: 'resque', only: [:show]
  58 + root to: "dashboard#index"
59 59 end
60 60  
61 61 get "errors/githost"
... ... @@ -63,39 +63,39 @@ Gitlab::Application.routes.draw do
63 63 #
64 64 # Profile Area
65 65 #
66   - get "profile/account", :to => "profile#account"
67   - get "profile/history", :to => "profile#history"
68   - put "profile/password", :to => "profile#password_update"
69   - get "profile/token", :to => "profile#token"
70   - put "profile/reset_private_token", :to => "profile#reset_private_token"
71   - get "profile", :to => "profile#show"
72   - get "profile/design", :to => "profile#design"
73   - put "profile/update", :to => "profile#update"
  66 + get "profile/account" => "profile#account"
  67 + get "profile/history" => "profile#history"
  68 + put "profile/password" => "profile#password_update"
  69 + get "profile/token" => "profile#token"
  70 + put "profile/reset_private_token" => "profile#reset_private_token"
  71 + get "profile" => "profile#show"
  72 + get "profile/design" => "profile#design"
  73 + put "profile/update" => "profile#update"
  74 +
74 75 resources :keys
75 76  
76 77 #
77 78 # Dashboard Area
78 79 #
79   - get "dashboard", :to => "dashboard#index"
80   - get "dashboard/issues", :to => "dashboard#issues"
81   - get "dashboard/merge_requests", :to => "dashboard#merge_requests"
  80 + get "dashboard" => "dashboard#index"
  81 + get "dashboard/issues" => "dashboard#issues"
  82 + get "dashboard/merge_requests" => "dashboard#merge_requests"
82 83  
83   - resources :projects, :constraints => { :id => /[^\/]+/ }, :only => [:new, :create]
  84 + resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
84 85  
85   - devise_for :users, :controllers => { :omniauth_callbacks => :omniauth_callbacks }
  86 + devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks }
86 87  
87 88 #
88 89 # Project Area
89 90 #
90   - resources :projects, :constraints => { :id => /[^\/]+/ }, :except => [:new, :create, :index], :path => "/" do
  91 + resources :projects, constraints: { id: /[^\/]+/ }, except: [:new, :create, :index], path: "/" do
91 92 member do
92   - get "team"
93 93 get "wall"
94 94 get "graph"
95 95 get "files"
96 96 end
97 97  
98   - resources :wikis, :only => [:show, :edit, :destroy, :create] do
  98 + resources :wikis, only: [:show, :edit, :destroy, :create] do
99 99 collection do
100 100 get :pages
101 101 end
... ... @@ -114,46 +114,45 @@ Gitlab::Application.routes.draw do
114 114 end
115 115  
116 116 resources :deploy_keys
117   - resources :protected_branches, :only => [:index, :create, :destroy]
  117 + resources :protected_branches, only: [:index, :create, :destroy]
118 118  
119   - resources :refs, :only => [], :path => "/" do
  119 + resources :refs, only: [], path: "/" do
120 120 collection do
121 121 get "switch"
122 122 end
123 123  
124 124 member do
125   - get "tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ }
126   - get "logs_tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ }
  125 + get "tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
  126 + get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
127 127  
128 128 get "blob",
129   - :constraints => {
130   - :id => /[a-zA-Z.0-9\/_\-]+/,
131   - :path => /.*/
  129 + constraints: {
  130 + id: /[a-zA-Z.0-9\/_\-]+/,
  131 + path: /.*/
132 132 }
133 133  
134   -
135 134 # tree viewer
136 135 get "tree/:path" => "refs#tree",
137   - :as => :tree_file,
138   - :constraints => {
139   - :id => /[a-zA-Z.0-9\/_\-]+/,
140   - :path => /.*/
  136 + as: :tree_file,
  137 + constraints: {
  138 + id: /[a-zA-Z.0-9\/_\-]+/,
  139 + path: /.*/
141 140 }
142 141  
143 142 # tree viewer
144 143 get "logs_tree/:path" => "refs#logs_tree",
145   - :as => :logs_file,
146   - :constraints => {
147   - :id => /[a-zA-Z.0-9\/_\-]+/,
148   - :path => /.*/
  144 + as: :logs_file,
  145 + constraints: {
  146 + id: /[a-zA-Z.0-9\/_\-]+/,
  147 + path: /.*/
149 148 }
150 149  
151 150 # blame
152 151 get "blame/:path" => "refs#blame",
153   - :as => :blame_file,
154   - :constraints => {
155   - :id => /[a-zA-Z.0-9\/_\-]+/,
156   - :path => /.*/
  152 + as: :blame_file,
  153 + constraints: {
  154 + id: /[a-zA-Z.0-9\/_\-]+/,
  155 + path: /.*/
157 156 }
158 157 end
159 158 end
... ... @@ -178,7 +177,7 @@ Gitlab::Application.routes.draw do
178 177 end
179 178 end
180 179  
181   - resources :hooks, :only => [:index, :create, :destroy] do
  180 + resources :hooks, only: [:index, :create, :destroy] do
182 181 member do
183 182 get :test
184 183 end
... ... @@ -192,9 +191,10 @@ Gitlab::Application.routes.draw do
192 191 get :patch
193 192 end
194 193 end
  194 + resources :team, controller: 'team_members', only: [:index]
195 195 resources :team_members
196 196 resources :milestones
197   - resources :labels, :only => [:index]
  197 + resources :labels, only: [:index]
198 198 resources :issues do
199 199  
200 200 collection do
... ... @@ -203,11 +203,12 @@ Gitlab::Application.routes.draw do
203 203 get :search
204 204 end
205 205 end
206   - resources :notes, :only => [:index, :create, :destroy] do
  206 + resources :notes, only: [:index, :create, :destroy] do
207 207 collection do
208 208 post :preview
209 209 end
210 210 end
211 211 end
212   - root :to => "dashboard#index"
  212 +
  213 + root to: "dashboard#index"
213 214 end
... ...
features/steps/shared/paths.rb
... ... @@ -98,7 +98,7 @@ module SharedPaths
98 98 end
99 99  
100 100 Then 'I visit project "Shop" team page' do
101   - visit team_project_path(Project.find_by_name("Shop"))
  101 + visit project_team_index_path(Project.find_by_name("Shop"))
102 102 end
103 103  
104 104 Then 'I visit project "Shop" wall page' do
... ...
lib/api/helpers.rb
... ... @@ -28,6 +28,14 @@ module Gitlab
28 28 end
29 29 end
30 30  
  31 + def attributes_for_keys(keys)
  32 + attrs = {}
  33 + keys.each do |key|
  34 + attrs[key] = params[key] if params[key].present?
  35 + end
  36 + attrs
  37 + end
  38 +
31 39 # error helpers
32 40  
33 41 def forbidden!
... ...
lib/api/issues.rb
... ... @@ -48,15 +48,10 @@ module Gitlab
48 48 # Example Request:
49 49 # POST /projects/:id/issues
50 50 post ":id/issues" do
51   - @issue = user_project.issues.new(
52   - title: params[:title],
53   - description: params[:description],
54   - assignee_id: params[:assignee_id],
55   - milestone_id: params[:milestone_id],
56   - label_list: params[:labels]
57   - )
  51 + attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id]
  52 + attrs[:label_list] = params[:labels] if params[:labels].present?
  53 + @issue = user_project.issues.new attrs
58 54 @issue.author = current_user
59   -
60 55 if @issue.save
61 56 present @issue, with: Entities::Issue
62 57 else
... ... @@ -81,16 +76,9 @@ module Gitlab
81 76 @issue = user_project.issues.find(params[:issue_id])
82 77 authorize! :modify_issue, @issue
83 78  
84   - parameters = {
85   - title: (params[:title] || @issue.title),
86   - description: (params[:description] || @issue.description),
87   - assignee_id: (params[:assignee_id] || @issue.assignee_id),
88   - milestone_id: (params[:milestone_id] || @issue.milestone_id),
89   - label_list: (params[:labels] || @issue.label_list),
90   - closed: (params[:closed] || @issue.closed)
91   - }
92   -
93   - if @issue.update_attributes(parameters)
  79 + attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :closed]
  80 + attrs[:label_list] = params[:labels] if params[:labels].present?
  81 + if @issue.update_attributes attrs
94 82 present @issue, with: Entities::Issue
95 83 else
96 84 not_found!
... ...
lib/api/milestones.rb
... ... @@ -36,12 +36,8 @@ module Gitlab
36 36 # Example Request:
37 37 # POST /projects/:id/milestones
38 38 post ":id/milestones" do
39   - @milestone = user_project.milestones.new(
40   - title: params[:title],
41   - description: params[:description],
42   - due_date: params[:due_date]
43   - )
44   -
  39 + attrs = attributes_for_keys [:title, :description, :due_date]
  40 + @milestone = user_project.milestones.new attrs
45 41 if @milestone.save
46 42 present @milestone, with: Entities::Milestone
47 43 else
... ... @@ -64,14 +60,8 @@ module Gitlab
64 60 authorize! :admin_milestone, user_project
65 61  
66 62 @milestone = user_project.milestones.find(params[:milestone_id])
67   - parameters = {
68   - title: (params[:title] || @milestone.title),
69   - description: (params[:description] || @milestone.description),
70   - due_date: (params[:due_date] || @milestone.due_date),
71   - closed: (params[:closed] || @milestone.closed)
72   - }
73   -
74   - if @milestone.update_attributes(parameters)
  63 + attrs = attributes_for_keys [:title, :description, :due_date, :closed]
  64 + if @milestone.update_attributes attrs
75 65 present @milestone, with: Entities::Milestone
76 66 else
77 67 not_found!
... ...
lib/api/projects.rb
... ... @@ -40,13 +40,16 @@ module Gitlab
40 40 post do
41 41 params[:code] ||= params[:name]
42 42 params[:path] ||= params[:name]
43   - project_attrs = {}
44   - params.each_pair do |k ,v|
45   - if Project.attribute_names.include? k
46   - project_attrs[k] = v
47   - end
48   - end
49   - @project = Project.create_by_user(project_attrs, current_user)
  43 + attrs = attributes_for_keys [:code,
  44 + :path,
  45 + :name,
  46 + :description,
  47 + :default_branch,
  48 + :issues_enabled,
  49 + :wall_enabled,
  50 + :merge_requests_enabled,
  51 + :wiki_enabled]
  52 + @project = Project.create_by_user(attrs, current_user)
50 53 if @project.saved?
51 54 present @project, with: Entities::Project
52 55 else
... ... @@ -204,12 +207,10 @@ module Gitlab
204 207 # Example Request:
205 208 # POST /projects/:id/snippets
206 209 post ":id/snippets" do
207   - @snippet = user_project.snippets.new(
208   - title: params[:title],
209   - file_name: params[:file_name],
210   - expires_at: params[:lifetime],
211   - content: params[:code]
212   - )
  210 + attrs = attributes_for_keys [:title, :file_name]
  211 + attrs[:expires_at] = params[:lifetime] if params[:lifetime].present?
  212 + attrs[:content] = params[:code] if params[:code].present?
  213 + @snippet = user_project.snippets.new attrs
213 214 @snippet.author = current_user
214 215  
215 216 if @snippet.save
... ... @@ -234,14 +235,11 @@ module Gitlab
234 235 @snippet = user_project.snippets.find(params[:snippet_id])
235 236 authorize! :modify_snippet, @snippet
236 237  
237   - parameters = {
238   - title: (params[:title] || @snippet.title),
239   - file_name: (params[:file_name] || @snippet.file_name),
240   - expires_at: (params[:lifetime] || @snippet.expires_at),
241   - content: (params[:code] || @snippet.content)
242   - }
  238 + attrs = attributes_for_keys [:title, :file_name]
  239 + attrs[:expires_at] = params[:lifetime] if params[:lifetime].present?
  240 + attrs[:content] = params[:code] if params[:code].present?
243 241  
244   - if @snippet.update_attributes(parameters)
  242 + if @snippet.update_attributes attrs
245 243 present @snippet, with: Entities::ProjectSnippet
246 244 else
247 245 not_found!
... ...
spec/requests/security/project_access_spec.rb
... ... @@ -70,7 +70,7 @@ describe &quot;Application access&quot; do
70 70 end
71 71  
72 72 describe "GET /project_code/team" do
73   - subject { team_project_path(@project) }
  73 + subject { project_team_index_path(@project) }
74 74  
75 75 it { should be_allowed_for @u1 }
76 76 it { should be_allowed_for @u3 }
... ...
spec/routing/admin_routing_spec.rb 0 → 100644
... ... @@ -0,0 +1,166 @@
  1 +require 'spec_helper'
  2 +
  3 +# team_update_admin_user PUT /admin/users/:id/team_update(.:format) admin/users#team_update
  4 +# block_admin_user PUT /admin/users/:id/block(.:format) admin/users#block
  5 +# unblock_admin_user PUT /admin/users/:id/unblock(.:format) admin/users#unblock
  6 +# admin_users GET /admin/users(.:format) admin/users#index
  7 +# POST /admin/users(.:format) admin/users#create
  8 +# new_admin_user GET /admin/users/new(.:format) admin/users#new
  9 +# edit_admin_user GET /admin/users/:id/edit(.:format) admin/users#edit
  10 +# admin_user GET /admin/users/:id(.:format) admin/users#show
  11 +# PUT /admin/users/:id(.:format) admin/users#update
  12 +# DELETE /admin/users/:id(.:format) admin/users#destroy
  13 +describe Admin::UsersController, "routing" do
  14 + it "to #team_update" do
  15 + put("/admin/users/1/team_update").should route_to('admin/users#team_update', id: '1')
  16 + end
  17 +
  18 + it "to #block" do
  19 + put("/admin/users/1/block").should route_to('admin/users#block', id: '1')
  20 + end
  21 +
  22 + it "to #unblock" do
  23 + put("/admin/users/1/unblock").should route_to('admin/users#unblock', id: '1')
  24 + end
  25 +
  26 + it "to #index" do
  27 + get("/admin/users").should route_to('admin/users#index')
  28 + end
  29 +
  30 + it "to #show" do
  31 + get("/admin/users/1").should route_to('admin/users#show', id: '1')
  32 + end
  33 +
  34 + it "to #create" do
  35 + post("/admin/users").should route_to('admin/users#create')
  36 + end
  37 +
  38 + it "to #new" do
  39 + get("/admin/users/new").should route_to('admin/users#new')
  40 + end
  41 +
  42 + it "to #edit" do
  43 + get("/admin/users/1/edit").should route_to('admin/users#edit', id: '1')
  44 + end
  45 +
  46 + it "to #show" do
  47 + get("/admin/users/1").should route_to('admin/users#show', id: '1')
  48 + end
  49 +
  50 + it "to #update" do
  51 + put("/admin/users/1").should route_to('admin/users#update', id: '1')
  52 + end
  53 +
  54 + it "to #destroy" do
  55 + delete("/admin/users/1").should route_to('admin/users#destroy', id: '1')
  56 + end
  57 +end
  58 +
  59 +# team_admin_project GET /admin/projects/:id/team(.:format) admin/projects#team {:id=>/[^\/]+/}
  60 +# team_update_admin_project PUT /admin/projects/:id/team_update(.:format) admin/projects#team_update {:id=>/[^\/]+/}
  61 +# admin_projects GET /admin/projects(.:format) admin/projects#index {:id=>/[^\/]+/}
  62 +# POST /admin/projects(.:format) admin/projects#create {:id=>/[^\/]+/}
  63 +# new_admin_project GET /admin/projects/new(.:format) admin/projects#new {:id=>/[^\/]+/}
  64 +# edit_admin_project GET /admin/projects/:id/edit(.:format) admin/projects#edit {:id=>/[^\/]+/}
  65 +# admin_project GET /admin/projects/:id(.:format) admin/projects#show {:id=>/[^\/]+/}
  66 +# PUT /admin/projects/:id(.:format) admin/projects#update {:id=>/[^\/]+/}
  67 +# DELETE /admin/projects/:id(.:format) admin/projects#destroy {:id=>/[^\/]+/}
  68 +describe Admin::ProjectsController, "routing" do
  69 + it "to #team" do
  70 + get("/admin/projects/gitlab/team").should route_to('admin/projects#team', id: 'gitlab')
  71 + end
  72 +
  73 + it "to #team_update" do
  74 + put("/admin/projects/gitlab/team_update").should route_to('admin/projects#team_update', id: 'gitlab')
  75 + end
  76 +
  77 + it "to #index" do
  78 + get("/admin/projects").should route_to('admin/projects#index')
  79 + end
  80 +
  81 + it "to #create" do
  82 + post("/admin/projects").should route_to('admin/projects#create')
  83 + end
  84 +
  85 + it "to #new" do
  86 + get("/admin/projects/new").should route_to('admin/projects#new')
  87 + end
  88 +
  89 + it "to #edit" do
  90 + get("/admin/projects/gitlab/edit").should route_to('admin/projects#edit', id: 'gitlab')
  91 + end
  92 +
  93 + it "to #show" do
  94 + get("/admin/projects/gitlab").should route_to('admin/projects#show', id: 'gitlab')
  95 + end
  96 +
  97 + it "to #update" do
  98 + put("/admin/projects/gitlab").should route_to('admin/projects#update', id: 'gitlab')
  99 + end
  100 +
  101 + it "to #destroy" do
  102 + delete("/admin/projects/gitlab").should route_to('admin/projects#destroy', id: 'gitlab')
  103 + end
  104 +end
  105 +
  106 +# edit_admin_team_member GET /admin/team_members/:id/edit(.:format) admin/team_members#edit
  107 +# admin_team_member PUT /admin/team_members/:id(.:format) admin/team_members#update
  108 +# DELETE /admin/team_members/:id(.:format) admin/team_members#destroy
  109 +describe Admin::TeamMembersController, "routing" do
  110 + it "to #edit" do
  111 + get("/admin/team_members/1/edit").should route_to('admin/team_members#edit', id: '1')
  112 + end
  113 +
  114 + it "to #update" do
  115 + put("/admin/team_members/1").should route_to('admin/team_members#update', id: '1')
  116 + end
  117 +
  118 + it "to #destroy" do
  119 + delete("/admin/team_members/1").should route_to('admin/team_members#destroy', id: '1')
  120 + end
  121 +end
  122 +
  123 +# admin_hook_test GET /admin/hooks/:hook_id/test(.:format) admin/hooks#test
  124 +# admin_hooks GET /admin/hooks(.:format) admin/hooks#index
  125 +# POST /admin/hooks(.:format) admin/hooks#create
  126 +# admin_hook DELETE /admin/hooks/:id(.:format) admin/hooks#destroy
  127 +describe Admin::HooksController, "routing" do
  128 + it "to #test" do
  129 + get("/admin/hooks/1/test").should route_to('admin/hooks#test', hook_id: '1')
  130 + end
  131 +
  132 + it "to #index" do
  133 + get("/admin/hooks").should route_to('admin/hooks#index')
  134 + end
  135 +
  136 + it "to #create" do
  137 + post("/admin/hooks").should route_to('admin/hooks#create')
  138 + end
  139 +
  140 + it "to #destroy" do
  141 + delete("/admin/hooks/1").should route_to('admin/hooks#destroy', id: '1')
  142 + end
  143 +
  144 +end
  145 +
  146 +# admin_logs GET /admin/logs(.:format) admin/logs#show
  147 +describe Admin::LogsController, "routing" do
  148 + it "to #show" do
  149 + get("/admin/logs").should route_to('admin/logs#show')
  150 + end
  151 +end
  152 +
  153 +# admin_resque GET /admin/resque(.:format) admin/resque#show
  154 +describe Admin::ResqueController, "routing" do
  155 + it "to #show" do
  156 + get("/admin/resque").should route_to('admin/resque#show')
  157 + end
  158 +end
  159 +
  160 +# admin_root /admin(.:format) admin/dashboard#index
  161 +describe Admin::DashboardController, "routing" do
  162 + it "to #index" do
  163 + get("/admin").should route_to('admin/dashboard#index')
  164 + end
  165 +end
  166 +
... ...
spec/routing/project_routing_spec.rb 0 → 100644
... ... @@ -0,0 +1,398 @@
  1 +require 'spec_helper'
  2 +
  3 +# Shared examples for a resource inside a Project
  4 +#
  5 +# By default it tests all the default REST actions: index, create, new, edit,
  6 +# show, update, and destroy. You can remove actions by customizing the
  7 +# `actions` variable.
  8 +#
  9 +# It also expects a `controller` variable to be available which defines both
  10 +# the path to the resource as well as the controller name.
  11 +#
  12 +# Examples
  13 +#
  14 +# # Default behavior
  15 +# it_behaves_like "RESTful project resources" do
  16 +# let(:controller) { 'issues' }
  17 +# end
  18 +#
  19 +# # Customizing actions
  20 +# it_behaves_like "RESTful project resources" do
  21 +# let(:actions) { [:index] }
  22 +# let(:controller) { 'issues' }
  23 +# end
  24 +shared_examples "RESTful project resources" do
  25 + let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] }
  26 +
  27 + it "to #index" do
  28 + get("/gitlabhq/#{controller}").should route_to("#{controller}#index", project_id: 'gitlabhq') if actions.include?(:index)
  29 + end
  30 +
  31 + it "to #create" do
  32 + post("/gitlabhq/#{controller}").should route_to("#{controller}#create", project_id: 'gitlabhq') if actions.include?(:create)
  33 + end
  34 +
  35 + it "to #new" do
  36 + get("/gitlabhq/#{controller}/new").should route_to("#{controller}#new", project_id: 'gitlabhq') if actions.include?(:new)
  37 + end
  38 +
  39 + it "to #edit" do
  40 + get("/gitlabhq/#{controller}/1/edit").should route_to("#{controller}#edit", project_id: 'gitlabhq', id: '1') if actions.include?(:edit)
  41 + end
  42 +
  43 + it "to #show" do
  44 + get("/gitlabhq/#{controller}/1").should route_to("#{controller}#show", project_id: 'gitlabhq', id: '1') if actions.include?(:show)
  45 + end
  46 +
  47 + it "to #update" do
  48 + put("/gitlabhq/#{controller}/1").should route_to("#{controller}#update", project_id: 'gitlabhq', id: '1') if actions.include?(:update)
  49 + end
  50 +
  51 + it "to #destroy" do
  52 + delete("/gitlabhq/#{controller}/1").should route_to("#{controller}#destroy", project_id: 'gitlabhq', id: '1') if actions.include?(:destroy)
  53 + end
  54 +end
  55 +
  56 +# projects POST /projects(.:format) projects#create
  57 +# new_project GET /projects/new(.:format) projects#new
  58 +# wall_project GET /:id/wall(.:format) projects#wall
  59 +# graph_project GET /:id/graph(.:format) projects#graph
  60 +# files_project GET /:id/files(.:format) projects#files
  61 +# edit_project GET /:id/edit(.:format) projects#edit
  62 +# project GET /:id(.:format) projects#show
  63 +# PUT /:id(.:format) projects#update
  64 +# DELETE /:id(.:format) projects#destroy
  65 +describe ProjectsController, "routing" do
  66 + it "to #create" do
  67 + post("/projects").should route_to('projects#create')
  68 + end
  69 +
  70 + it "to #new" do
  71 + get("/projects/new").should route_to('projects#new')
  72 + end
  73 +
  74 + it "to #wall" do
  75 + get("/gitlabhq/wall").should route_to('projects#wall', id: 'gitlabhq')
  76 + end
  77 +
  78 + it "to #graph" do
  79 + get("/gitlabhq/graph").should route_to('projects#graph', id: 'gitlabhq')
  80 + end
  81 +
  82 + it "to #files" do
  83 + get("/gitlabhq/files").should route_to('projects#files', id: 'gitlabhq')
  84 + end
  85 +
  86 + it "to #edit" do
  87 + get("/gitlabhq/edit").should route_to('projects#edit', id: 'gitlabhq')
  88 + end
  89 +
  90 + it "to #show" do
  91 + get("/gitlabhq").should route_to('projects#show', id: 'gitlabhq')
  92 + end
  93 +
  94 + it "to #update" do
  95 + put("/gitlabhq").should route_to('projects#update', id: 'gitlabhq')
  96 + end
  97 +
  98 + it "to #destroy" do
  99 + delete("/gitlabhq").should route_to('projects#destroy', id: 'gitlabhq')
  100 + end
  101 +end
  102 +
  103 +# pages_project_wikis GET /:project_id/wikis/pages(.:format) wikis#pages
  104 +# history_project_wiki GET /:project_id/wikis/:id/history(.:format) wikis#history
  105 +# project_wikis POST /:project_id/wikis(.:format) wikis#create
  106 +# edit_project_wiki GET /:project_id/wikis/:id/edit(.:format) wikis#edit
  107 +# project_wiki GET /:project_id/wikis/:id(.:format) wikis#show
  108 +# DELETE /:project_id/wikis/:id(.:format) wikis#destroy
  109 +describe WikisController, "routing" do
  110 + it "to #pages" do
  111 + get("/gitlabhq/wikis/pages").should route_to('wikis#pages', project_id: 'gitlabhq')
  112 + end
  113 +
  114 + it "to #history" do
  115 + get("/gitlabhq/wikis/1/history").should route_to('wikis#history', project_id: 'gitlabhq', id: '1')
  116 + end
  117 +
  118 + it_behaves_like "RESTful project resources" do
  119 + let(:actions) { [:create, :edit, :show, :destroy] }
  120 + let(:controller) { 'wikis' }
  121 + end
  122 +end
  123 +
  124 +# branches_project_repository GET /:project_id/repository/branches(.:format) repositories#branches
  125 +# tags_project_repository GET /:project_id/repository/tags(.:format) repositories#tags
  126 +# archive_project_repository GET /:project_id/repository/archive(.:format) repositories#archive
  127 +# project_repository POST /:project_id/repository(.:format) repositories#create
  128 +# new_project_repository GET /:project_id/repository/new(.:format) repositories#new
  129 +# edit_project_repository GET /:project_id/repository/edit(.:format) repositories#edit
  130 +# GET /:project_id/repository(.:format) repositories#show
  131 +# PUT /:project_id/repository(.:format) repositories#update
  132 +# DELETE /:project_id/repository(.:format) repositories#destroy
  133 +describe RepositoriesController, "routing" do
  134 + it "to #branches" do
  135 + get("/gitlabhq/repository/branches").should route_to('repositories#branches', project_id: 'gitlabhq')
  136 + end
  137 +
  138 + it "to #tags" do
  139 + get("/gitlabhq/repository/tags").should route_to('repositories#tags', project_id: 'gitlabhq')
  140 + end
  141 +
  142 + it "to #archive" do
  143 + get("/gitlabhq/repository/archive").should route_to('repositories#archive', project_id: 'gitlabhq')
  144 + end
  145 +
  146 + it "to #create" do
  147 + post("/gitlabhq/repository").should route_to('repositories#create', project_id: 'gitlabhq')
  148 + end
  149 +
  150 + it "to #new" do
  151 + get("/gitlabhq/repository/new").should route_to('repositories#new', project_id: 'gitlabhq')
  152 + end
  153 +
  154 + it "to #edit" do
  155 + get("/gitlabhq/repository/edit").should route_to('repositories#edit', project_id: 'gitlabhq')
  156 + end
  157 +
  158 + it "to #show" do
  159 + get("/gitlabhq/repository").should route_to('repositories#show', project_id: 'gitlabhq')
  160 + end
  161 +
  162 + it "to #update" do
  163 + put("/gitlabhq/repository").should route_to('repositories#update', project_id: 'gitlabhq')
  164 + end
  165 +
  166 + it "to #destroy" do
  167 + delete("/gitlabhq/repository").should route_to('repositories#destroy', project_id: 'gitlabhq')
  168 + end
  169 +end
  170 +
  171 +# project_deploy_keys GET /:project_id/deploy_keys(.:format) deploy_keys#index
  172 +# POST /:project_id/deploy_keys(.:format) deploy_keys#create
  173 +# new_project_deploy_key GET /:project_id/deploy_keys/new(.:format) deploy_keys#new
  174 +# edit_project_deploy_key GET /:project_id/deploy_keys/:id/edit(.:format) deploy_keys#edit
  175 +# project_deploy_key GET /:project_id/deploy_keys/:id(.:format) deploy_keys#show
  176 +# PUT /:project_id/deploy_keys/:id(.:format) deploy_keys#update
  177 +# DELETE /:project_id/deploy_keys/:id(.:format) deploy_keys#destroy
  178 +describe DeployKeysController, "routing" do
  179 + it_behaves_like "RESTful project resources" do
  180 + let(:controller) { 'deploy_keys' }
  181 + end
  182 +end
  183 +
  184 +# project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index
  185 +# POST /:project_id/protected_branches(.:format) protected_branches#create
  186 +# project_protected_branch DELETE /:project_id/protected_branches/:id(.:format) protected_branches#destroy
  187 +describe ProtectedBranchesController, "routing" do
  188 + it_behaves_like "RESTful project resources" do
  189 + let(:actions) { [:index, :create, :destroy] }
  190 + let(:controller) { 'protected_branches' }
  191 + end
  192 +end
  193 +
  194 +# switch_project_refs GET /:project_id/switch(.:format) refs#switch
  195 +# tree_project_ref GET /:project_id/:id/tree(.:format) refs#tree
  196 +# logs_tree_project_ref GET /:project_id/:id/logs_tree(.:format) refs#logs_tree
  197 +# blob_project_ref GET /:project_id/:id/blob(.:format) refs#blob
  198 +# tree_file_project_ref GET /:project_id/:id/tree/:path(.:format) refs#tree
  199 +# logs_file_project_ref GET /:project_id/:id/logs_tree/:path(.:format) refs#logs_tree
  200 +# blame_file_project_ref GET /:project_id/:id/blame/:path(.:format) refs#blame
  201 +describe RefsController, "routing" do
  202 + it "to #switch" do
  203 + get("/gitlabhq/switch").should route_to('refs#switch', project_id: 'gitlabhq')
  204 + end
  205 +
  206 + it "to #tree" do
  207 + get("/gitlabhq/stable/tree").should route_to('refs#tree', project_id: 'gitlabhq', id: 'stable')
  208 + get("/gitlabhq/stable/tree/foo/bar/baz").should route_to('refs#tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz')
  209 + end
  210 +
  211 + it "to #logs_tree" do
  212 + get("/gitlabhq/stable/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable')
  213 + get("/gitlabhq/stable/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz')
  214 + end
  215 +
  216 + it "to #blob" do
  217 + get("/gitlabhq/stable/blob").should route_to('refs#blob', project_id: 'gitlabhq', id: 'stable')
  218 + end
  219 +
  220 + it "to #blame" do
  221 + get("/gitlabhq/stable/blame/foo/bar/baz").should route_to('refs#blame', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz')
  222 + end
  223 +end
  224 +
  225 +# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs
  226 +# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) merge_requests#automerge
  227 +# automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) merge_requests#automerge_check
  228 +# raw_project_merge_request GET /:project_id/merge_requests/:id/raw(.:format) merge_requests#raw
  229 +# branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) merge_requests#branch_from
  230 +# branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) merge_requests#branch_to
  231 +# project_merge_requests GET /:project_id/merge_requests(.:format) merge_requests#index
  232 +# POST /:project_id/merge_requests(.:format) merge_requests#create
  233 +# new_project_merge_request GET /:project_id/merge_requests/new(.:format) merge_requests#new
  234 +# edit_project_merge_request GET /:project_id/merge_requests/:id/edit(.:format) merge_requests#edit
  235 +# project_merge_request GET /:project_id/merge_requests/:id(.:format) merge_requests#show
  236 +# PUT /:project_id/merge_requests/:id(.:format) merge_requests#update
  237 +# DELETE /:project_id/merge_requests/:id(.:format) merge_requests#destroy
  238 +describe MergeRequestsController, "routing" do
  239 + it "to #diffs" do
  240 + get("/gitlabhq/merge_requests/1/diffs").should route_to('merge_requests#diffs', project_id: 'gitlabhq', id: '1')
  241 + end
  242 +
  243 + it "to #automerge" do
  244 + get("/gitlabhq/merge_requests/1/automerge").should route_to('merge_requests#automerge', project_id: 'gitlabhq', id: '1')
  245 + end
  246 +
  247 + it "to #automerge_check" do
  248 + get("/gitlabhq/merge_requests/1/automerge_check").should route_to('merge_requests#automerge_check', project_id: 'gitlabhq', id: '1')
  249 + end
  250 +
  251 + it "to #raw" do
  252 + get("/gitlabhq/merge_requests/1/raw").should route_to('merge_requests#raw', project_id: 'gitlabhq', id: '1')
  253 + end
  254 +
  255 + it "to #branch_from" do
  256 + get("/gitlabhq/merge_requests/branch_from").should route_to('merge_requests#branch_from', project_id: 'gitlabhq')
  257 + end
  258 +
  259 + it "to #branch_to" do
  260 + get("/gitlabhq/merge_requests/branch_to").should route_to('merge_requests#branch_to', project_id: 'gitlabhq')
  261 + end
  262 +
  263 + it_behaves_like "RESTful project resources" do
  264 + let(:controller) { 'merge_requests' }
  265 + end
  266 +end
  267 +
  268 +# raw_project_snippet GET /:project_id/snippets/:id/raw(.:format) snippets#raw
  269 +# project_snippets GET /:project_id/snippets(.:format) snippets#index
  270 +# POST /:project_id/snippets(.:format) snippets#create
  271 +# new_project_snippet GET /:project_id/snippets/new(.:format) snippets#new
  272 +# edit_project_snippet GET /:project_id/snippets/:id/edit(.:format) snippets#edit
  273 +# project_snippet GET /:project_id/snippets/:id(.:format) snippets#show
  274 +# PUT /:project_id/snippets/:id(.:format) snippets#update
  275 +# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
  276 +describe SnippetsController, "routing" do
  277 + it "to #raw" do
  278 + get("/gitlabhq/snippets/1/raw").should route_to('snippets#raw', project_id: 'gitlabhq', id: '1')
  279 + end
  280 +
  281 + it_behaves_like "RESTful project resources" do
  282 + let(:controller) { 'snippets' }
  283 + end
  284 +end
  285 +
  286 +# test_project_hook GET /:project_id/hooks/:id/test(.:format) hooks#test
  287 +# project_hooks GET /:project_id/hooks(.:format) hooks#index
  288 +# POST /:project_id/hooks(.:format) hooks#create
  289 +# project_hook DELETE /:project_id/hooks/:id(.:format) hooks#destroy
  290 +describe HooksController, "routing" do
  291 + it "to #test" do
  292 + get("/gitlabhq/hooks/1/test").should route_to('hooks#test', project_id: 'gitlabhq', id: '1')
  293 + end
  294 +
  295 + it_behaves_like "RESTful project resources" do
  296 + let(:actions) { [:index, :create, :destroy] }
  297 + let(:controller) { 'hooks' }
  298 + end
  299 +end
  300 +
  301 +# compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare
  302 +# patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
  303 +# project_commits GET /:project_id/commits(.:format) commits#index
  304 +# POST /:project_id/commits(.:format) commits#create
  305 +# new_project_commit GET /:project_id/commits/new(.:format) commits#new
  306 +# edit_project_commit GET /:project_id/commits/:id/edit(.:format) commits#edit
  307 +# project_commit GET /:project_id/commits/:id(.:format) commits#show
  308 +# PUT /:project_id/commits/:id(.:format) commits#update
  309 +# DELETE /:project_id/commits/:id(.:format) commits#destroy
  310 +describe CommitsController, "routing" do
  311 + it "to #compare" do
  312 + get("/gitlabhq/commits/compare").should route_to('commits#compare', project_id: 'gitlabhq')
  313 + end
  314 +
  315 + it "to #patch" do
  316 + get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1')
  317 + end
  318 +
  319 + it_behaves_like "RESTful project resources" do
  320 + let(:controller) { 'commits' }
  321 + end
  322 +end
  323 +
  324 +# project_team_members GET /:project_id/team_members(.:format) team_members#index
  325 +# POST /:project_id/team_members(.:format) team_members#create
  326 +# new_project_team_member GET /:project_id/team_members/new(.:format) team_members#new
  327 +# edit_project_team_member GET /:project_id/team_members/:id/edit(.:format) team_members#edit
  328 +# project_team_member GET /:project_id/team_members/:id(.:format) team_members#show
  329 +# PUT /:project_id/team_members/:id(.:format) team_members#update
  330 +# DELETE /:project_id/team_members/:id(.:format) team_members#destroy
  331 +describe TeamMembersController, "routing" do
  332 + it_behaves_like "RESTful project resources" do
  333 + let(:controller) { 'team_members' }
  334 + end
  335 +end
  336 +
  337 +# project_milestones GET /:project_id/milestones(.:format) milestones#index
  338 +# POST /:project_id/milestones(.:format) milestones#create
  339 +# new_project_milestone GET /:project_id/milestones/new(.:format) milestones#new
  340 +# edit_project_milestone GET /:project_id/milestones/:id/edit(.:format) milestones#edit
  341 +# project_milestone GET /:project_id/milestones/:id(.:format) milestones#show
  342 +# PUT /:project_id/milestones/:id(.:format) milestones#update
  343 +# DELETE /:project_id/milestones/:id(.:format) milestones#destroy
  344 +describe MilestonesController, "routing" do
  345 + it_behaves_like "RESTful project resources" do
  346 + let(:controller) { 'milestones' }
  347 + end
  348 +end
  349 +
  350 +# project_labels GET /:project_id/labels(.:format) labels#index
  351 +describe LabelsController, "routing" do
  352 + it "to #index" do
  353 + get("/gitlabhq/labels").should route_to('labels#index', project_id: 'gitlabhq')
  354 + end
  355 +end
  356 +
  357 +# sort_project_issues POST /:project_id/issues/sort(.:format) issues#sort
  358 +# bulk_update_project_issues POST /:project_id/issues/bulk_update(.:format) issues#bulk_update
  359 +# search_project_issues GET /:project_id/issues/search(.:format) issues#search
  360 +# project_issues GET /:project_id/issues(.:format) issues#index
  361 +# POST /:project_id/issues(.:format) issues#create
  362 +# new_project_issue GET /:project_id/issues/new(.:format) issues#new
  363 +# edit_project_issue GET /:project_id/issues/:id/edit(.:format) issues#edit
  364 +# project_issue GET /:project_id/issues/:id(.:format) issues#show
  365 +# PUT /:project_id/issues/:id(.:format) issues#update
  366 +# DELETE /:project_id/issues/:id(.:format) issues#destroy
  367 +describe IssuesController, "routing" do
  368 + it "to #sort" do
  369 + post("/gitlabhq/issues/sort").should route_to('issues#sort', project_id: 'gitlabhq')
  370 + end
  371 +
  372 + it "to #bulk_update" do
  373 + post("/gitlabhq/issues/bulk_update").should route_to('issues#bulk_update', project_id: 'gitlabhq')
  374 + end
  375 +
  376 + it "to #search" do
  377 + get("/gitlabhq/issues/search").should route_to('issues#search', project_id: 'gitlabhq')
  378 + end
  379 +
  380 + it_behaves_like "RESTful project resources" do
  381 + let(:controller) { 'issues' }
  382 + end
  383 +end
  384 +
  385 +# preview_project_notes POST /:project_id/notes/preview(.:format) notes#preview
  386 +# project_notes GET /:project_id/notes(.:format) notes#index
  387 +# POST /:project_id/notes(.:format) notes#create
  388 +# project_note DELETE /:project_id/notes/:id(.:format) notes#destroy
  389 +describe NotesController, "routing" do
  390 + it "to #preview" do
  391 + post("/gitlabhq/notes/preview").should route_to('notes#preview', project_id: 'gitlabhq')
  392 + end
  393 +
  394 + it_behaves_like "RESTful project resources" do
  395 + let(:actions) { [:index, :create, :destroy] }
  396 + let(:controller) { 'notes' }
  397 + end
  398 +end
... ...
spec/routing/routing_spec.rb 0 → 100644
... ... @@ -0,0 +1,186 @@
  1 +require 'spec_helper'
  2 +
  3 +# search GET /search(.:format) search#show
  4 +describe SearchController, "routing" do
  5 + it "to #show" do
  6 + get("/search").should route_to('search#show')
  7 + end
  8 +end
  9 +
  10 +# gitlab_api /api Gitlab::API
  11 +# resque /info/resque Resque::Server
  12 +# /:path Grack
  13 +describe "Mounted Apps", "routing" do
  14 + it "to API" do
  15 + get("/api").should be_routable
  16 + end
  17 +
  18 + it "to Resque" do
  19 + pending
  20 + get("/info/resque").should be_routable
  21 + end
  22 +
  23 + it "to Grack" do
  24 + get("/gitlabhq.git").should be_routable
  25 + end
  26 +end
  27 +
  28 +# help GET /help(.:format) help#index
  29 +# help_permissions GET /help/permissions(.:format) help#permissions
  30 +# help_workflow GET /help/workflow(.:format) help#workflow
  31 +# help_api GET /help/api(.:format) help#api
  32 +# help_web_hooks GET /help/web_hooks(.:format) help#web_hooks
  33 +# help_system_hooks GET /help/system_hooks(.:format) help#system_hooks
  34 +# help_markdown GET /help/markdown(.:format) help#markdown
  35 +# help_ssh GET /help/ssh(.:format) help#ssh
  36 +describe HelpController, "routing" do
  37 + it "to #index" do
  38 + get("/help").should route_to('help#index')
  39 + end
  40 +
  41 + it "to #permissions" do
  42 + get("/help/permissions").should route_to('help#permissions')
  43 + end
  44 +
  45 + it "to #workflow" do
  46 + get("/help/workflow").should route_to('help#workflow')
  47 + end
  48 +
  49 + it "to #api" do
  50 + get("/help/api").should route_to('help#api')
  51 + end
  52 +
  53 + it "to #web_hooks" do
  54 + get("/help/web_hooks").should route_to('help#web_hooks')
  55 + end
  56 +
  57 + it "to #system_hooks" do
  58 + get("/help/system_hooks").should route_to('help#system_hooks')
  59 + end
  60 +
  61 + it "to #markdown" do
  62 + get("/help/markdown").should route_to('help#markdown')
  63 + end
  64 +
  65 + it "to #ssh" do
  66 + get("/help/ssh").should route_to('help#ssh')
  67 + end
  68 +end
  69 +
  70 +# errors_githost GET /errors/githost(.:format) errors#githost
  71 +describe ErrorsController, "routing" do
  72 + it "to #githost" do
  73 + get("/errors/githost").should route_to('errors#githost')
  74 + end
  75 +end
  76 +
  77 +# profile_account GET /profile/account(.:format) profile#account
  78 +# profile_history GET /profile/history(.:format) profile#history
  79 +# profile_password PUT /profile/password(.:format) profile#password_update
  80 +# profile_token GET /profile/token(.:format) profile#token
  81 +# profile_reset_private_token PUT /profile/reset_private_token(.:format) profile#reset_private_token
  82 +# profile GET /profile(.:format) profile#show
  83 +# profile_design GET /profile/design(.:format) profile#design
  84 +# profile_update PUT /profile/update(.:format) profile#update
  85 +describe ProfileController, "routing" do
  86 + it "to #account" do
  87 + get("/profile/account").should route_to('profile#account')
  88 + end
  89 +
  90 + it "to #history" do
  91 + get("/profile/history").should route_to('profile#history')
  92 + end
  93 +
  94 + it "to #password_update" do
  95 + put("/profile/password").should route_to('profile#password_update')
  96 + end
  97 +
  98 + it "to #token" do
  99 + get("/profile/token").should route_to('profile#token')
  100 + end
  101 +
  102 + it "to #reset_private_token" do
  103 + put("/profile/reset_private_token").should route_to('profile#reset_private_token')
  104 + end
  105 +
  106 + it "to #show" do
  107 + get("/profile").should route_to('profile#show')
  108 + end
  109 +
  110 + it "to #design" do
  111 + get("/profile/design").should route_to('profile#design')
  112 + end
  113 +
  114 + it "to #update" do
  115 + put("/profile/update").should route_to('profile#update')
  116 + end
  117 +end
  118 +
  119 +# keys GET /keys(.:format) keys#index
  120 +# POST /keys(.:format) keys#create
  121 +# new_key GET /keys/new(.:format) keys#new
  122 +# edit_key GET /keys/:id/edit(.:format) keys#edit
  123 +# key GET /keys/:id(.:format) keys#show
  124 +# PUT /keys/:id(.:format) keys#update
  125 +# DELETE /keys/:id(.:format) keys#destroy
  126 +describe KeysController, "routing" do
  127 + it "to #index" do
  128 + get("/keys").should route_to('keys#index')
  129 + end
  130 +
  131 + it "to #create" do
  132 + post("/keys").should route_to('keys#create')
  133 + end
  134 +
  135 + it "to #new" do
  136 + get("/keys/new").should route_to('keys#new')
  137 + end
  138 +
  139 + it "to #edit" do
  140 + get("/keys/1/edit").should route_to('keys#edit', id: '1')
  141 + end
  142 +
  143 + it "to #show" do
  144 + get("/keys/1").should route_to('keys#show', id: '1')
  145 + end
  146 +
  147 + it "to #update" do
  148 + put("/keys/1").should route_to('keys#update', id: '1')
  149 + end
  150 +
  151 + it "to #destroy" do
  152 + delete("/keys/1").should route_to('keys#destroy', id: '1')
  153 + end
  154 +end
  155 +
  156 +# dashboard GET /dashboard(.:format) dashboard#index
  157 +# dashboard_issues GET /dashboard/issues(.:format) dashboard#issues
  158 +# dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests
  159 +# root / dashboard#index
  160 +describe DashboardController, "routing" do
  161 + it "to #index" do
  162 + get("/dashboard").should route_to('dashboard#index')
  163 + get("/").should route_to('dashboard#index')
  164 + end
  165 +
  166 + it "to #issues" do
  167 + get("/dashboard/issues").should route_to('dashboard#issues')
  168 + end
  169 +
  170 + it "to #merge_requests" do
  171 + get("/dashboard/merge_requests").should route_to('dashboard#merge_requests')
  172 + end
  173 +end
  174 +
  175 +# new_user_session GET /users/sign_in(.:format) devise/sessions#new
  176 +# user_session POST /users/sign_in(.:format) devise/sessions#create
  177 +# destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
  178 +# user_omniauth_authorize /users/auth/:provider(.:format) omniauth_callbacks#passthru
  179 +# user_omniauth_callback /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:(?!))
  180 +# user_password POST /users/password(.:format) devise/passwords#create
  181 +# new_user_password GET /users/password/new(.:format) devise/passwords#new
  182 +# edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
  183 +# PUT /users/password(.:format) devise/passwords#update
  184 +describe "Authentication", "routing" do
  185 + # pending
  186 +end
... ...