##// END OF EJS Templates
Project identifier is now used in URLs (instead of project id)....
Jean-Philippe Lang -
r994:524cd689cf87
parent child
Show More
@@ -111,6 +111,20 class Project < ActiveRecord::Base
111 111 end
112 112 end
113 113
114 def self.find(*args)
115 if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
116 project = find_by_identifier(*args)
117 raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
118 project
119 else
120 super
121 end
122 end
123
124 def to_param
125 identifier
126 end
127
114 128 def active?
115 129 self.status == STATUS_ACTIVE
116 130 end
@@ -41,5 +41,5 projects_004:
41 41 description: eCookbook Subproject 2
42 42 homepage: ""
43 43 is_public: true
44 identifier: subproject1
44 identifier: subproject2
45 45 parent_id: 1
@@ -144,7 +144,7 class IssuesControllerTest < Test::Unit::TestCase
144 144 def test_destroy
145 145 @request.session[:user_id] = 2
146 146 post :destroy, :id => 1
147 assert_redirected_to 'projects/1/issues'
147 assert_redirected_to 'projects/ecookbook/issues'
148 148 assert_nil Issue.find_by_id(1)
149 149 end
150 150
@@ -47,12 +47,20 class ProjectsControllerTest < Test::Unit::TestCase
47 47 assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
48 48 end
49 49
50 def test_show
50 def test_show_by_id
51 51 get :show, :id => 1
52 52 assert_response :success
53 53 assert_template 'show'
54 54 assert_not_nil assigns(:project)
55 55 end
56
57 def test_show_by_identifier
58 get :show, :id => 'ecookbook'
59 assert_response :success
60 assert_template 'show'
61 assert_not_nil assigns(:project)
62 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
63 end
56 64
57 65 def test_settings
58 66 @request.session[:user_id] = 2 # manager
@@ -64,7 +72,7 class ProjectsControllerTest < Test::Unit::TestCase
64 72 def test_edit
65 73 @request.session[:user_id] = 2 # manager
66 74 post :edit, :id => 1, :project => {:name => 'Test changed name'}
67 assert_redirected_to 'projects/settings/1'
75 assert_redirected_to 'projects/settings/ecookbook'
68 76 project = Project.find(1)
69 77 assert_equal 'Test changed name', project.name
70 78 end
@@ -104,7 +112,7 class ProjectsControllerTest < Test::Unit::TestCase
104 112 def test_move_issues_to_another_project
105 113 @request.session[:user_id] = 1
106 114 post :move_issues, :id => 1, :issue_ids => [1, 2], :new_project_id => 2
107 assert_redirected_to 'projects/1/issues'
115 assert_redirected_to 'projects/ecookbook/issues'
108 116 assert_equal 2, Issue.find(1).project_id
109 117 assert_equal 2, Issue.find(2).project_id
110 118 end
@@ -112,7 +120,7 class ProjectsControllerTest < Test::Unit::TestCase
112 120 def test_move_issues_to_another_tracker
113 121 @request.session[:user_id] = 1
114 122 post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 3
115 assert_redirected_to 'projects/1/issues'
123 assert_redirected_to 'projects/ecookbook/issues'
116 124 assert_equal 3, Issue.find(1).tracker_id
117 125 assert_equal 3, Issue.find(2).tracker_id
118 126 end
@@ -242,7 +250,7 class ProjectsControllerTest < Test::Unit::TestCase
242 250 assert_response :success
243 251 assert_template 'add_issue'
244 252 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}
245 assert_redirected_to 'projects/1/issues'
253 assert_redirected_to 'projects/ecookbook/issues'
246 254 assert Issue.find_by_subject('This is the test_add_issue issue')
247 255 end
248 256
@@ -43,10 +43,10 class RepositoriesControllerTest < Test::Unit::TestCase
43 43 assert_response :success
44 44 assert_template 'revision'
45 45 assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
46 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'}
46 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook?rev=0'}
47 47 }
48 48 assert_tag :tag => "div", :attributes => { :class => "contextual" },
49 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'}
49 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook?rev=2'}
50 50 }
51 51 end
52 52
@@ -52,7 +52,7 class VersionsControllerTest < Test::Unit::TestCase
52 52 post :edit, :id => 2,
53 53 :version => { :name => 'New version name',
54 54 :effective_date => Date.today.strftime("%Y-%m-%d")}
55 assert_redirected_to 'projects/settings/1'
55 assert_redirected_to 'projects/settings/ecookbook'
56 56 version = Version.find(2)
57 57 assert_equal 'New version name', version.name
58 58 assert_equal Date.today, version.effective_date
@@ -61,7 +61,7 class VersionsControllerTest < Test::Unit::TestCase
61 61 def test_destroy
62 62 @request.session[:user_id] = 2
63 63 post :destroy, :id => 2
64 assert_redirected_to 'projects/settings/1'
64 assert_redirected_to 'projects/settings/ecookbook'
65 65 assert_nil Version.find_by_id(2)
66 66 end
67 67
@@ -64,7 +64,7 class WikiControllerTest < Test::Unit::TestCase
64 64 :content => {:comments => 'Created the page',
65 65 :text => "h1. New page\n\nThis is a new page",
66 66 :version => 0}
67 assert_redirected_to 'wiki/1/New_page'
67 assert_redirected_to 'wiki/ecookbook/New_page'
68 68 page = Project.find(1).wiki.find_page('New page')
69 69 assert !page.new_record?
70 70 assert_not_nil page.content
@@ -103,7 +103,7 class WikiControllerTest < Test::Unit::TestCase
103 103 post :rename, :id => 1, :page => 'Another_page',
104 104 :wiki_page => { :title => 'Another renamed page',
105 105 :redirect_existing_links => 1 }
106 assert_redirected_to 'wiki/1/Another_renamed_page'
106 assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
107 107 wiki = Project.find(1).wiki
108 108 # Check redirects
109 109 assert_not_nil wiki.find_page('Another page')
@@ -115,7 +115,7 class WikiControllerTest < Test::Unit::TestCase
115 115 post :rename, :id => 1, :page => 'Another_page',
116 116 :wiki_page => { :title => 'Another renamed page',
117 117 :redirect_existing_links => "0" }
118 assert_redirected_to 'wiki/1/Another_renamed_page'
118 assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
119 119 wiki = Project.find(1).wiki
120 120 # Check that there's no redirects
121 121 assert_nil wiki.find_page('Another page')
@@ -124,17 +124,17 class WikiControllerTest < Test::Unit::TestCase
124 124 def test_destroy
125 125 @request.session[:user_id] = 2
126 126 post :destroy, :id => 1, :page => 'CookBook_documentation'
127 assert_redirected_to 'wiki/1/Page_index/special'
127 assert_redirected_to 'wiki/ecookbook/Page_index/special'
128 128 end
129 129
130 130 def test_page_index
131 get :special, :id => 1, :page => 'Page_index'
131 get :special, :id => 'ecookbook', :page => 'Page_index'
132 132 assert_response :success
133 133 assert_template 'special_page_index'
134 134 pages = assigns(:pages)
135 135 assert_not_nil pages
136 136 assert_equal 2, pages.size
137 assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation' },
137 assert_tag :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
138 138 :content => /CookBook documentation/
139 139 end
140 140
@@ -44,7 +44,7 class WikisControllerTest < Test::Unit::TestCase
44 44 def test_destroy
45 45 @request.session[:user_id] = 1
46 46 post :destroy, :id => 1, :confirm => 1
47 assert_redirected_to 'projects/settings/1'
47 assert_redirected_to 'projects/settings/ecookbook'
48 48 assert_nil Project.find(1).wiki
49 49 end
50 50
@@ -24,7 +24,7 class IssuesTest < ActionController::IntegrationTest
24 24 assert_kind_of Issue, issue
25 25
26 26 # check redirection
27 assert_redirected_to "projects/1/issues"
27 assert_redirected_to "projects/ecookbook/issues"
28 28 follow_redirect!
29 29 assert assigns(:issues).include?(issue)
30 30
General Comments 0
You need to be logged in to leave comments. Login now