Merge pull request #432 from warpc/263-refactoring
Исправление роутов групп
This commit is contained in:
commit
fa027d8486
1
Gemfile
1
Gemfile
|
@ -70,6 +70,7 @@ group :development do
|
||||||
gem 'shotgun'
|
gem 'shotgun'
|
||||||
# deploy
|
# deploy
|
||||||
gem 'capistrano', :require => false
|
gem 'capistrano', :require => false
|
||||||
|
gem 'rvm-capistrano', :require => false
|
||||||
gem 'cape', :require => false
|
gem 'cape', :require => false
|
||||||
gem 'capistrano_colors', :require => false
|
gem 'capistrano_colors', :require => false
|
||||||
end
|
end
|
||||||
|
|
|
@ -255,6 +255,8 @@ GEM
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.1.8)
|
||||||
russian (0.6.0)
|
russian (0.6.0)
|
||||||
i18n (>= 0.5.0)
|
i18n (>= 0.5.0)
|
||||||
|
rvm-capistrano (1.1.0)
|
||||||
|
capistrano (>= 2.0.0)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
sass (3.1.16)
|
sass (3.1.16)
|
||||||
|
@ -358,6 +360,7 @@ DEPENDENCIES
|
||||||
rspec-rails (~> 2.9.0)
|
rspec-rails (~> 2.9.0)
|
||||||
ruby-haml-js (~> 0.0.3)
|
ruby-haml-js (~> 0.0.3)
|
||||||
russian (~> 0.6.0)
|
russian (~> 0.6.0)
|
||||||
|
rvm-capistrano
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
shotgun
|
shotgun
|
||||||
shoulda
|
shoulda
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Groups::BaseController < ApplicationController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_group
|
def find_group
|
||||||
if group_id = params[:owner_name] || params[:group_id] || params[:id]
|
if group_id = params[:uname] || params[:group_id] || params[:id]
|
||||||
@group = Group.find_by_insensitive_uname! group_id
|
@group = Group.find_by_insensitive_uname! group_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Users::BaseController < ApplicationController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_user
|
def find_user
|
||||||
if user_id = params[:owner_name] || params[:user_id] || params[:id]
|
if user_id = params[:uname] || params[:user_id] || params[:id]
|
||||||
@user = User.find_by_insensitive_uname! user_id
|
@user = User.find_by_insensitive_uname! user_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-set_meta_tags :title => [title_object(@group), t('layout.groups.edit')]
|
-set_meta_tags :title => [title_object(@group), t('layout.groups.edit')]
|
||||||
= form_for @group do |f|
|
= form_for @group, :url => profile_group_path(@group) do |f|
|
||||||
= render "form", :f => f
|
= render "form", :f => f
|
||||||
|
|
||||||
.hr
|
.hr
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
.hr
|
.hr
|
||||||
.leftside= t("layout.groups.delete_warning")
|
.leftside= t("layout.groups.delete_warning")
|
||||||
.rightside
|
.rightside
|
||||||
= link_to t("layout.delete"), group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group
|
= link_to t("layout.delete"), profile_group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group
|
||||||
.both
|
.both
|
||||||
|
|
||||||
- content_for :sidebar, render('sidebar')
|
- content_for :sidebar, render('sidebar')
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
$:.unshift File.expand_path('.')
|
require 'cape'
|
||||||
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
require 'capistrano_colors'
|
||||||
set :rvm_type, :user
|
|
||||||
|
|
||||||
set :default_environment, {
|
set :default_environment, {
|
||||||
'LANG' => 'en_US.UTF-8'
|
'LANG' => 'en_US.UTF-8'
|
||||||
|
@ -34,10 +33,10 @@ set :scm, :git
|
||||||
set :repository, "git@github.com:warpc/rosa-build.git"
|
set :repository, "git@github.com:warpc/rosa-build.git"
|
||||||
set :deploy_via, :remote_cache
|
set :deploy_via, :remote_cache
|
||||||
|
|
||||||
require 'lib/recipes/nginx'
|
require './lib/recipes/nginx'
|
||||||
require 'lib/recipes/unicorn'
|
require './lib/recipes/unicorn'
|
||||||
require 'lib/recipes/bluepill'
|
require './lib/recipes/bluepill'
|
||||||
require 'lib/recipes/delayed_job'
|
require './lib/recipes/delayed_job'
|
||||||
|
|
||||||
namespace :deploy do
|
namespace :deploy do
|
||||||
task :stub_xml_rpc do
|
task :stub_xml_rpc do
|
||||||
|
@ -92,7 +91,6 @@ after "deploy:restart", "delayed_job:restart"
|
||||||
|
|
||||||
after "deploy:restart", "deploy:cleanup"
|
after "deploy:restart", "deploy:cleanup"
|
||||||
|
|
||||||
require 'cape'
|
|
||||||
namespace :rake_tasks do
|
namespace :rake_tasks do
|
||||||
Cape do
|
Cape do
|
||||||
mirror_rake_tasks 'db:seeds'
|
mirror_rake_tasks 'db:seeds'
|
||||||
|
|
126
config/routes.rb
126
config/routes.rb
|
@ -20,6 +20,20 @@ Rosa::Application.routes.draw do
|
||||||
root :to => 'activity_feeds#index'
|
root :to => 'activity_feeds#index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :admin do
|
||||||
|
resources :users do
|
||||||
|
get :list, :on => :collection
|
||||||
|
end
|
||||||
|
resources :register_requests, :only => [:index] do
|
||||||
|
put :update, :on => :collection
|
||||||
|
member do
|
||||||
|
get :approve
|
||||||
|
get :reject
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :event_logs, :only => :index
|
||||||
|
end
|
||||||
|
|
||||||
scope :module => 'platforms' do
|
scope :module => 'platforms' do
|
||||||
resources :platforms do
|
resources :platforms do
|
||||||
resources :private_users, :except => [:show, :destroy, :update]
|
resources :private_users, :except => [:show, :destroy, :update]
|
||||||
|
@ -49,20 +63,6 @@ Rosa::Application.routes.draw do
|
||||||
resources :product_build_lists, :only => [:index]
|
resources :product_build_lists, :only => [:index]
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :admin do
|
|
||||||
resources :users do
|
|
||||||
get :list, :on => :collection
|
|
||||||
end
|
|
||||||
resources :register_requests, :only => [:index] do
|
|
||||||
put :update, :on => :collection
|
|
||||||
member do
|
|
||||||
get :approve
|
|
||||||
get :reject
|
|
||||||
end
|
|
||||||
end
|
|
||||||
resources :event_logs, :only => :index
|
|
||||||
end
|
|
||||||
|
|
||||||
scope :module => 'users' do
|
scope :module => 'users' do
|
||||||
resources :settings, :only => [] do
|
resources :settings, :only => [] do
|
||||||
collection do
|
collection do
|
||||||
|
@ -81,6 +81,8 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :module => 'groups' do
|
scope :module => 'groups' do
|
||||||
|
get '/groups/new' => 'profile#new' # need to force next route exclude :id => 'new'
|
||||||
|
get '/groups/:id' => redirect("/%{id}"), :as => :profile_group # override default group show route
|
||||||
resources :groups, :controller => 'profile' do
|
resources :groups, :controller => 'profile' do
|
||||||
get :autocomplete_group_uname, :on => :collection
|
get :autocomplete_group_uname, :on => :collection
|
||||||
delete :remove_user, :on => :member
|
delete :remove_user, :on => :member
|
||||||
|
@ -114,56 +116,49 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :projects, :only => [:index, :new, :create]
|
resources :projects, :only => [:index, :new, :create]
|
||||||
end
|
|
||||||
scope ':owner_name' do # Owner
|
|
||||||
constraints OwnerConstraint.new(User) do
|
|
||||||
get '/' => 'users/profile#show', :as => :user
|
|
||||||
end
|
|
||||||
constraints OwnerConstraint.new(Group, true) do
|
|
||||||
get '/' => 'groups/profile#show', :as => :group_profile
|
|
||||||
end
|
|
||||||
scope ':project_name', :as => 'project', :module => 'projects' do
|
|
||||||
resources :wiki do
|
|
||||||
collection do
|
|
||||||
match '_history' => 'wiki#wiki_history', :as => :history, :via => :get
|
|
||||||
match '_access' => 'wiki#git', :as => :git, :via => :get
|
|
||||||
match '_revert/:sha1/:sha2' => 'wiki#revert_wiki', :as => :revert, :via => [:get, :post]
|
|
||||||
match '_compare' => 'wiki#compare_wiki', :as => :compare, :via => :post
|
|
||||||
#match '_compare/:versions' => 'wiki#compare_wiki', :versions => /.*/, :as => :compare_versions, :via => :get
|
|
||||||
match '_compare/:versions' => 'wiki#compare_wiki', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get
|
|
||||||
post :preview
|
|
||||||
get :search
|
|
||||||
get :pages
|
|
||||||
end
|
|
||||||
member do
|
|
||||||
get :history
|
|
||||||
get :edit
|
|
||||||
match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => [:get, :post]
|
|
||||||
match ':ref' => 'wiki#show', :as => :versioned, :via => :get
|
|
||||||
|
|
||||||
post :compare
|
scope ':owner_name/:project_name' do # project
|
||||||
#match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get
|
scope :as => 'project' do
|
||||||
match 'compare/:versions' => 'wiki#compare', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get
|
resources :wiki do
|
||||||
|
collection do
|
||||||
|
match '_history' => 'wiki#wiki_history', :as => :history, :via => :get
|
||||||
|
match '_access' => 'wiki#git', :as => :git, :via => :get
|
||||||
|
match '_revert/:sha1/:sha2' => 'wiki#revert_wiki', :as => :revert, :via => [:get, :post]
|
||||||
|
match '_compare' => 'wiki#compare_wiki', :as => :compare, :via => :post
|
||||||
|
#match '_compare/:versions' => 'wiki#compare_wiki', :versions => /.*/, :as => :compare_versions, :via => :get
|
||||||
|
match '_compare/:versions' => 'wiki#compare_wiki', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get
|
||||||
|
post :preview
|
||||||
|
get :search
|
||||||
|
get :pages
|
||||||
|
end
|
||||||
|
member do
|
||||||
|
get :history
|
||||||
|
get :edit
|
||||||
|
match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => [:get, :post]
|
||||||
|
match ':ref' => 'wiki#show', :as => :versioned, :via => :get
|
||||||
|
|
||||||
|
post :compare
|
||||||
|
#match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get
|
||||||
|
match 'compare/:versions' => 'wiki#compare', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :issues, :except => :edit do
|
||||||
|
resources :comments, :only => [:edit, :create, :update, :destroy]
|
||||||
|
resources :subscribes, :only => [:create, :destroy]
|
||||||
|
collection do
|
||||||
|
post :create_label
|
||||||
|
get :search_collaborators
|
||||||
|
end
|
||||||
|
end
|
||||||
|
post "/labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label
|
||||||
|
post "/labels/:label_id/update" => "issues#update_label", :as => :issues_update_label
|
||||||
|
resources :build_lists, :only => [:index, :new, :create] do
|
||||||
|
collection { post :search }
|
||||||
|
end
|
||||||
|
resources :collaborators do
|
||||||
|
get :find, :on => :collection
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :issues, :except => :edit do
|
|
||||||
resources :comments, :only => [:edit, :create, :update, :destroy]
|
|
||||||
resources :subscribes, :only => [:create, :destroy]
|
|
||||||
collection do
|
|
||||||
post :create_label
|
|
||||||
get :search_collaborators
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post "/labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label
|
|
||||||
post "/labels/:label_id/update" => "issues#update_label", :as => :issues_update_label
|
|
||||||
resources :build_lists, :only => [:index, :new, :create] do
|
|
||||||
collection { post :search }
|
|
||||||
end
|
|
||||||
resources :collaborators do
|
|
||||||
get :find, :on => :collection
|
|
||||||
end
|
|
||||||
end
|
|
||||||
scope ':project_name', :module => 'projects' do
|
|
||||||
# Resource
|
# Resource
|
||||||
get '/edit' => 'projects#edit', :as => :edit_project
|
get '/edit' => 'projects#edit', :as => :edit_project
|
||||||
put '/' => 'projects#update'
|
put '/' => 'projects#update'
|
||||||
|
@ -200,4 +195,13 @@ Rosa::Application.routes.draw do
|
||||||
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
|
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope ':uname' do # project owner profile
|
||||||
|
constraints OwnerConstraint.new(User) do
|
||||||
|
get '/' => 'users/profile#show', :as => :user
|
||||||
|
end
|
||||||
|
constraints OwnerConstraint.new(Group, true) do
|
||||||
|
get '/' => 'groups/profile#show', :as => :group
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,6 @@ class OwnerConstraint
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches?(request)
|
def matches?(request)
|
||||||
@class_name.send(@finder, request.params[:owner_name]).present?
|
@class_name.send(@finder, request.params[:uname]).present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Projects::Git::TreesController do
|
||||||
|
|
||||||
@project = FactoryGirl.create(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@another_user = FactoryGirl.create(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@params = {:project_id => @project.id, :format => 'tar'}
|
@params = {:owner_name => @project.owner.uname, :project_name => @project.name, :format => 'tar'}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for guest' do
|
context 'for guest' do
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe Users::ProfileController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to view profile' do
|
it 'should be able to view profile' do
|
||||||
get :show, :owner_name => @other_user.uname
|
get :show, :uname => @other_user.uname
|
||||||
response.code.should eq('200')
|
response.code.should eq('200')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue