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
description: eCookbook Subproject 2\r
homepage: ""\r
is_public: true\r
- identifier: subproject1\r
+ identifier: subproject2\r
parent_id: 1\r
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
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
end\r
\r
- def test_show\r
+ def test_show_by_id\r
get :show, :id => 1\r
assert_response :success
assert_template 'show'\r
assert_not_nil assigns(:project)\r
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
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
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
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
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
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
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
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
: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
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')
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')
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
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
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)