mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-23 07:34:08 +01:00
Apply Trevor Lovett's patch (#364)
"I kick off a lot of small projects, and I often want to add actions right when I create the project. This is a simple tweak that provides a check box that allows you to immediately go to the project page after creating a new project." Thanks, Trevor. Sorry it took so long! git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@474 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
18bb7ff16a
commit
84357b67d5
5 changed files with 35 additions and 1 deletions
|
|
@ -53,6 +53,13 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
assert_rjs :call, "Form.reset", "project-form"
|
||||
assert_rjs :call, "Form.focusFirstElement", "project-form"
|
||||
end
|
||||
|
||||
def test_create_project_and_go_to_project_page
|
||||
num_projects = Project.count
|
||||
xhr :post, :create, { :project => {:name => 'Immediate Project Planning Required'}, :go_to_project => 1}
|
||||
assert_js_redirected_to '/projects/Immediate_Project_Planning_Required'
|
||||
assert_equal num_projects + 1, Project.count
|
||||
end
|
||||
|
||||
def test_create_with_slash_in_name_does_not_increment_number_of_projects
|
||||
assert_ajax_create_does_not_increment_count 'foo/bar'
|
||||
|
|
|
|||
|
|
@ -44,6 +44,28 @@ class Test::Unit::TestCase
|
|||
1.week.from_now.utc.to_date
|
||||
end
|
||||
|
||||
# Courtesy of http://habtm.com/articles/2006/02/20/assert-yourself-man-redirecting-with-rjs
|
||||
def assert_js_redirected_to(options={}, message=nil)
|
||||
clean_backtrace do
|
||||
assert_response(:success, message)
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'], 'Response should be Javascript content-type';
|
||||
js_regexp = %r{(\w+://)?.*?(/|$|\\\?)(.*)}
|
||||
url_regexp = %r{^window\.location\.href [=] ['"]#{js_regexp}['"][;]$}
|
||||
redirected_to = @response.body.match(url_regexp)
|
||||
assert_not_nil(redirected_to, message)
|
||||
redirected_to = redirected_to[3]
|
||||
msg = build_message(message, "expected a JS redirect to <?>, found one to <?>", options, redirected_to)
|
||||
|
||||
if options.is_a?(String)
|
||||
assert_equal(options.gsub(/^\//, ''), redirected_to, message)
|
||||
else
|
||||
msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)", redirected_to)
|
||||
assert_equal(@controller.url_for(options).match(js_regexp)[3], redirected_to, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
class ActionController::IntegrationTest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue