Project identifier is now used in URLs (instead of project id).
URLs with a project id will still be recognized. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1007 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b4eafd9ea8
commit
524cd689cf
@ -111,6 +111,20 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.find(*args)
|
||||||
|
if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
|
||||||
|
project = find_by_identifier(*args)
|
||||||
|
raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
|
||||||
|
project
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_param
|
||||||
|
identifier
|
||||||
|
end
|
||||||
|
|
||||||
def active?
|
def active?
|
||||||
self.status == STATUS_ACTIVE
|
self.status == STATUS_ACTIVE
|
||||||
end
|
end
|
||||||
|
2
test/fixtures/projects.yml
vendored
2
test/fixtures/projects.yml
vendored
@ -41,5 +41,5 @@ projects_004:
|
|||||||
description: eCookbook Subproject 2
|
description: eCookbook Subproject 2
|
||||||
homepage: ""
|
homepage: ""
|
||||||
is_public: true
|
is_public: true
|
||||||
identifier: subproject1
|
identifier: subproject2
|
||||||
parent_id: 1
|
parent_id: 1
|
||||||
|
@ -144,7 +144,7 @@ class IssuesControllerTest < Test::Unit::TestCase
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :destroy, :id => 1
|
post :destroy, :id => 1
|
||||||
assert_redirected_to 'projects/1/issues'
|
assert_redirected_to 'projects/ecookbook/issues'
|
||||||
assert_nil Issue.find_by_id(1)
|
assert_nil Issue.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,13 +47,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
|||||||
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
|
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show_by_id
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'show'
|
assert_template 'show'
|
||||||
assert_not_nil assigns(:project)
|
assert_not_nil assigns(:project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_by_identifier
|
||||||
|
get :show, :id => 'ecookbook'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'show'
|
||||||
|
assert_not_nil assigns(:project)
|
||||||
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||||
|
end
|
||||||
|
|
||||||
def test_settings
|
def test_settings
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
get :settings, :id => 1
|
get :settings, :id => 1
|
||||||
@ -64,7 +72,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
|||||||
def test_edit
|
def test_edit
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
post :edit, :id => 1, :project => {:name => 'Test changed name'}
|
post :edit, :id => 1, :project => {:name => 'Test changed name'}
|
||||||
assert_redirected_to 'projects/settings/1'
|
assert_redirected_to 'projects/settings/ecookbook'
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
assert_equal 'Test changed name', project.name
|
assert_equal 'Test changed name', project.name
|
||||||
end
|
end
|
||||||
@ -104,7 +112,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
|||||||
def test_move_issues_to_another_project
|
def test_move_issues_to_another_project
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_project_id => 2
|
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_project_id => 2
|
||||||
assert_redirected_to 'projects/1/issues'
|
assert_redirected_to 'projects/ecookbook/issues'
|
||||||
assert_equal 2, Issue.find(1).project_id
|
assert_equal 2, Issue.find(1).project_id
|
||||||
assert_equal 2, Issue.find(2).project_id
|
assert_equal 2, Issue.find(2).project_id
|
||||||
end
|
end
|
||||||
@ -112,7 +120,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
|||||||
def test_move_issues_to_another_tracker
|
def test_move_issues_to_another_tracker
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 3
|
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 3
|
||||||
assert_redirected_to 'projects/1/issues'
|
assert_redirected_to 'projects/ecookbook/issues'
|
||||||
assert_equal 3, Issue.find(1).tracker_id
|
assert_equal 3, Issue.find(1).tracker_id
|
||||||
assert_equal 3, Issue.find(2).tracker_id
|
assert_equal 3, Issue.find(2).tracker_id
|
||||||
end
|
end
|
||||||
@ -242,7 +250,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'add_issue'
|
assert_template 'add_issue'
|
||||||
post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5}
|
post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5}
|
||||||
assert_redirected_to 'projects/1/issues'
|
assert_redirected_to 'projects/ecookbook/issues'
|
||||||
assert Issue.find_by_subject('This is the test_add_issue issue')
|
assert Issue.find_by_subject('This is the test_add_issue issue')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ class RepositoriesControllerTest < Test::Unit::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'revision'
|
assert_template 'revision'
|
||||||
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
|
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
|
||||||
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'}
|
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook?rev=0'}
|
||||||
}
|
}
|
||||||
assert_tag :tag => "div", :attributes => { :class => "contextual" },
|
assert_tag :tag => "div", :attributes => { :class => "contextual" },
|
||||||
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'}
|
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook?rev=2'}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class VersionsControllerTest < Test::Unit::TestCase
|
|||||||
post :edit, :id => 2,
|
post :edit, :id => 2,
|
||||||
:version => { :name => 'New version name',
|
:version => { :name => 'New version name',
|
||||||
:effective_date => Date.today.strftime("%Y-%m-%d")}
|
:effective_date => Date.today.strftime("%Y-%m-%d")}
|
||||||
assert_redirected_to 'projects/settings/1'
|
assert_redirected_to 'projects/settings/ecookbook'
|
||||||
version = Version.find(2)
|
version = Version.find(2)
|
||||||
assert_equal 'New version name', version.name
|
assert_equal 'New version name', version.name
|
||||||
assert_equal Date.today, version.effective_date
|
assert_equal Date.today, version.effective_date
|
||||||
@ -61,7 +61,7 @@ class VersionsControllerTest < Test::Unit::TestCase
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :destroy, :id => 2
|
post :destroy, :id => 2
|
||||||
assert_redirected_to 'projects/settings/1'
|
assert_redirected_to 'projects/settings/ecookbook'
|
||||||
assert_nil Version.find_by_id(2)
|
assert_nil Version.find_by_id(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||||||
:content => {:comments => 'Created the page',
|
:content => {:comments => 'Created the page',
|
||||||
:text => "h1. New page\n\nThis is a new page",
|
:text => "h1. New page\n\nThis is a new page",
|
||||||
:version => 0}
|
:version => 0}
|
||||||
assert_redirected_to 'wiki/1/New_page'
|
assert_redirected_to 'wiki/ecookbook/New_page'
|
||||||
page = Project.find(1).wiki.find_page('New page')
|
page = Project.find(1).wiki.find_page('New page')
|
||||||
assert !page.new_record?
|
assert !page.new_record?
|
||||||
assert_not_nil page.content
|
assert_not_nil page.content
|
||||||
@ -103,7 +103,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||||||
post :rename, :id => 1, :page => 'Another_page',
|
post :rename, :id => 1, :page => 'Another_page',
|
||||||
:wiki_page => { :title => 'Another renamed page',
|
:wiki_page => { :title => 'Another renamed page',
|
||||||
:redirect_existing_links => 1 }
|
:redirect_existing_links => 1 }
|
||||||
assert_redirected_to 'wiki/1/Another_renamed_page'
|
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||||
wiki = Project.find(1).wiki
|
wiki = Project.find(1).wiki
|
||||||
# Check redirects
|
# Check redirects
|
||||||
assert_not_nil wiki.find_page('Another page')
|
assert_not_nil wiki.find_page('Another page')
|
||||||
@ -115,7 +115,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||||||
post :rename, :id => 1, :page => 'Another_page',
|
post :rename, :id => 1, :page => 'Another_page',
|
||||||
:wiki_page => { :title => 'Another renamed page',
|
:wiki_page => { :title => 'Another renamed page',
|
||||||
:redirect_existing_links => "0" }
|
:redirect_existing_links => "0" }
|
||||||
assert_redirected_to 'wiki/1/Another_renamed_page'
|
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||||
wiki = Project.find(1).wiki
|
wiki = Project.find(1).wiki
|
||||||
# Check that there's no redirects
|
# Check that there's no redirects
|
||||||
assert_nil wiki.find_page('Another page')
|
assert_nil wiki.find_page('Another page')
|
||||||
@ -124,17 +124,17 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :destroy, :id => 1, :page => 'CookBook_documentation'
|
post :destroy, :id => 1, :page => 'CookBook_documentation'
|
||||||
assert_redirected_to 'wiki/1/Page_index/special'
|
assert_redirected_to 'wiki/ecookbook/Page_index/special'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_page_index
|
def test_page_index
|
||||||
get :special, :id => 1, :page => 'Page_index'
|
get :special, :id => 'ecookbook', :page => 'Page_index'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'special_page_index'
|
assert_template 'special_page_index'
|
||||||
pages = assigns(:pages)
|
pages = assigns(:pages)
|
||||||
assert_not_nil pages
|
assert_not_nil pages
|
||||||
assert_equal 2, pages.size
|
assert_equal 2, pages.size
|
||||||
assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation' },
|
assert_tag :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
|
||||||
:content => /CookBook documentation/
|
:content => /CookBook documentation/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class WikisControllerTest < Test::Unit::TestCase
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :destroy, :id => 1, :confirm => 1
|
post :destroy, :id => 1, :confirm => 1
|
||||||
assert_redirected_to 'projects/settings/1'
|
assert_redirected_to 'projects/settings/ecookbook'
|
||||||
assert_nil Project.find(1).wiki
|
assert_nil Project.find(1).wiki
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class IssuesTest < ActionController::IntegrationTest
|
|||||||
assert_kind_of Issue, issue
|
assert_kind_of Issue, issue
|
||||||
|
|
||||||
# check redirection
|
# check redirection
|
||||||
assert_redirected_to "projects/1/issues"
|
assert_redirected_to "projects/ecookbook/issues"
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert assigns(:issues).include?(issue)
|
assert assigns(:issues).include?(issue)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user