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
pull/351/head
Jean-Philippe Lang 17 years ago
parent b4eafd9ea8
commit 524cd689cf
  1. 14
      app/models/project.rb
  2. 2
      test/fixtures/projects.yml
  3. 2
      test/functional/issues_controller_test.rb
  4. 18
      test/functional/projects_controller_test.rb
  5. 4
      test/functional/repositories_controller_test.rb
  6. 4
      test/functional/versions_controller_test.rb
  7. 12
      test/functional/wiki_controller_test.rb
  8. 2
      test/functional/wikis_controller_test.rb
  9. 2
      test/integration/issues_test.rb

@ -111,6 +111,20 @@ class Project < ActiveRecord::Base
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?
self.status == STATUS_ACTIVE
end

@ -41,5 +41,5 @@ projects_004:
description: eCookbook Subproject 2
homepage: ""
is_public: true
identifier: subproject1
identifier: subproject2
parent_id: 1

@ -144,7 +144,7 @@ class IssuesControllerTest < Test::Unit::TestCase
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1
assert_redirected_to 'projects/1/issues'
assert_redirected_to 'projects/ecookbook/issues'
assert_nil Issue.find_by_id(1)
end

@ -47,13 +47,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
end
def test_show
def test_show_by_id
get :show, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:project)
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
@request.session[:user_id] = 2 # manager
get :settings, :id => 1
@ -64,7 +72,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
def test_edit
@request.session[:user_id] = 2 # manager
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)
assert_equal 'Test changed name', project.name
end
@ -104,7 +112,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
def test_move_issues_to_another_project
@request.session[:user_id] = 1
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(2).project_id
end
@ -112,7 +120,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
def test_move_issues_to_another_tracker
@request.session[:user_id] = 1
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(2).tracker_id
end
@ -242,7 +250,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_response :success
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}
assert_redirected_to 'projects/1/issues'
assert_redirected_to 'projects/ecookbook/issues'
assert Issue.find_by_subject('This is the test_add_issue issue')
end

@ -43,10 +43,10 @@ class RepositoriesControllerTest < Test::Unit::TestCase
assert_response :success
assert_template 'revision'
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" },
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'}
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook?rev=2'}
}
end

@ -52,7 +52,7 @@ class VersionsControllerTest < Test::Unit::TestCase
post :edit, :id => 2,
:version => { :name => 'New version name',
:effective_date => Date.today.strftime("%Y-%m-%d")}
assert_redirected_to 'projects/settings/1'
assert_redirected_to 'projects/settings/ecookbook'
version = Version.find(2)
assert_equal 'New version name', version.name
assert_equal Date.today, version.effective_date
@ -61,7 +61,7 @@ class VersionsControllerTest < Test::Unit::TestCase
def test_destroy
@request.session[:user_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)
end

@ -64,7 +64,7 @@ class WikiControllerTest < Test::Unit::TestCase
:content => {:comments => 'Created the page',
:text => "h1. New page\n\nThis is a new page",
: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')
assert !page.new_record?
assert_not_nil page.content
@ -103,7 +103,7 @@ class WikiControllerTest < Test::Unit::TestCase
post :rename, :id => 1, :page => 'Another_page',
:wiki_page => { :title => 'Another renamed page',
: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
# Check redirects
assert_not_nil wiki.find_page('Another page')
@ -115,7 +115,7 @@ class WikiControllerTest < Test::Unit::TestCase
post :rename, :id => 1, :page => 'Another_page',
:wiki_page => { :title => 'Another renamed page',
: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
# Check that there's no redirects
assert_nil wiki.find_page('Another page')
@ -124,17 +124,17 @@ class WikiControllerTest < Test::Unit::TestCase
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1, :page => 'CookBook_documentation'
assert_redirected_to 'wiki/1/Page_index/special'
assert_redirected_to 'wiki/ecookbook/Page_index/special'
end
def test_page_index
get :special, :id => 1, :page => 'Page_index'
get :special, :id => 'ecookbook', :page => 'Page_index'
assert_response :success
assert_template 'special_page_index'
pages = assigns(:pages)
assert_not_nil pages
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/
end

@ -44,7 +44,7 @@ class WikisControllerTest < Test::Unit::TestCase
def test_destroy
@request.session[:user_id] = 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
end

@ -24,7 +24,7 @@ class IssuesTest < ActionController::IntegrationTest
assert_kind_of Issue, issue
# check redirection
assert_redirected_to "projects/1/issues"
assert_redirected_to "projects/ecookbook/issues"
follow_redirect!
assert assigns(:issues).include?(issue)

Loading…
Cancel
Save