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