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'
|
||||
# deploy
|
||||
gem 'capistrano', :require => false
|
||||
gem 'rvm-capistrano', :require => false
|
||||
gem 'cape', :require => false
|
||||
gem 'capistrano_colors', :require => false
|
||||
end
|
||||
|
|
|
@ -255,6 +255,8 @@ GEM
|
|||
ruby-openid (2.1.8)
|
||||
russian (0.6.0)
|
||||
i18n (>= 0.5.0)
|
||||
rvm-capistrano (1.1.0)
|
||||
capistrano (>= 2.0.0)
|
||||
sanitize (2.0.3)
|
||||
nokogiri (>= 1.4.4, < 1.6)
|
||||
sass (3.1.16)
|
||||
|
@ -358,6 +360,7 @@ DEPENDENCIES
|
|||
rspec-rails (~> 2.9.0)
|
||||
ruby-haml-js (~> 0.0.3)
|
||||
russian (~> 0.6.0)
|
||||
rvm-capistrano
|
||||
sass-rails (~> 3.2.5)
|
||||
shotgun
|
||||
shoulda
|
||||
|
|
|
@ -6,7 +6,7 @@ class Groups::BaseController < ApplicationController
|
|||
protected
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Users::BaseController < ApplicationController
|
|||
protected
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-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
|
||||
|
||||
.hr
|
||||
|
@ -9,7 +9,7 @@
|
|||
.hr
|
||||
.leftside= t("layout.groups.delete_warning")
|
||||
.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
|
||||
|
||||
- content_for :sidebar, render('sidebar')
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
$:.unshift File.expand_path('.')
|
||||
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
||||
set :rvm_type, :user
|
||||
require 'cape'
|
||||
require 'capistrano_colors'
|
||||
|
||||
set :default_environment, {
|
||||
'LANG' => 'en_US.UTF-8'
|
||||
|
@ -34,10 +33,10 @@ set :scm, :git
|
|||
set :repository, "git@github.com:warpc/rosa-build.git"
|
||||
set :deploy_via, :remote_cache
|
||||
|
||||
require 'lib/recipes/nginx'
|
||||
require 'lib/recipes/unicorn'
|
||||
require 'lib/recipes/bluepill'
|
||||
require 'lib/recipes/delayed_job'
|
||||
require './lib/recipes/nginx'
|
||||
require './lib/recipes/unicorn'
|
||||
require './lib/recipes/bluepill'
|
||||
require './lib/recipes/delayed_job'
|
||||
|
||||
namespace :deploy do
|
||||
task :stub_xml_rpc do
|
||||
|
@ -92,7 +91,6 @@ after "deploy:restart", "delayed_job:restart"
|
|||
|
||||
after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
require 'cape'
|
||||
namespace :rake_tasks do
|
||||
Cape do
|
||||
mirror_rake_tasks 'db:seeds'
|
||||
|
|
|
@ -20,6 +20,20 @@ Rosa::Application.routes.draw do
|
|||
root :to => 'activity_feeds#index'
|
||||
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
|
||||
resources :platforms do
|
||||
resources :private_users, :except => [:show, :destroy, :update]
|
||||
|
@ -49,20 +63,6 @@ Rosa::Application.routes.draw do
|
|||
resources :product_build_lists, :only => [:index]
|
||||
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
|
||||
resources :settings, :only => [] do
|
||||
collection do
|
||||
|
@ -81,6 +81,8 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
|
||||
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
|
||||
get :autocomplete_group_uname, :on => :collection
|
||||
delete :remove_user, :on => :member
|
||||
|
@ -114,15 +116,9 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
scope ':owner_name/:project_name' do # project
|
||||
scope :as => 'project' do
|
||||
resources :wiki do
|
||||
collection do
|
||||
match '_history' => 'wiki#wiki_history', :as => :history, :via => :get
|
||||
|
@ -163,7 +159,6 @@ Rosa::Application.routes.draw do
|
|||
get :find, :on => :collection
|
||||
end
|
||||
end
|
||||
scope ':project_name', :module => 'projects' do
|
||||
# Resource
|
||||
get '/edit' => 'projects#edit', :as => :edit_project
|
||||
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/
|
||||
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
|
||||
|
|
|
@ -7,6 +7,6 @@ class OwnerConstraint
|
|||
end
|
||||
|
||||
def matches?(request)
|
||||
@class_name.send(@finder, request.params[:owner_name]).present?
|
||||
@class_name.send(@finder, request.params[:uname]).present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe Projects::Git::TreesController do
|
|||
|
||||
@project = FactoryGirl.create(:project)
|
||||
@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
|
||||
|
||||
context 'for guest' do
|
||||
|
|
|
@ -27,7 +27,7 @@ describe Users::ProfileController do
|
|||
end
|
||||
|
||||
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')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue