fixtures :users, :roles
def test_login
- get "my/page"
+ get "/my/page"
assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fmy%2Fpage"
log_user('jsmith', 'jsmith')
- get "my/account"
+ get "/my/account"
assert_response :success
assert_template "my/account"
end
def test_lost_password
Token.delete_all
- get "account/lost_password"
+ get "/account/lost_password"
assert_response :success
assert_template "account/lost_password"
assert_select 'input[name=mail]'
- post "account/lost_password", :mail => 'jSmith@somenet.foo'
+ post "/account/lost_password", :mail => 'jSmith@somenet.foo'
assert_redirected_to "/login"
token = Token.first
assert_equal 'jsmith@somenet.foo', token.user.mail
assert !token.expired?
- get "account/lost_password", :token => token.value
+ get "/account/lost_password", :token => token.value
assert_response :success
assert_template "account/password_recovery"
assert_select 'input[type=hidden][name=token][value=?]', token.value
assert_select 'input[name=new_password]'
assert_select 'input[name=new_password_confirmation]'
- post "account/lost_password",
+ post "/account/lost_password",
:token => token.value, :new_password => 'newpass123',
:new_password_confirmation => 'newpass123'
assert_redirected_to "/login"
def test_register_with_automatic_activation
Setting.self_registration = '3'
- get 'account/register'
+ get '/account/register'
assert_response :success
assert_template 'account/register'
- post 'account/register',
+ post '/account/register',
:user => {:login => "newuser", :language => "en",
:firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
:password => "newpass123", :password_confirmation => "newpass123"}
def test_register_with_manual_activation
Setting.self_registration = '2'
- post 'account/register',
+ post '/account/register',
:user => {:login => "newuser", :language => "en",
:firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
:password => "newpass123", :password_confirmation => "newpass123"}
Setting.self_registration = '1'
Token.delete_all
- post 'account/register',
+ post '/account/register',
:user => {:login => "newuser", :language => "en",
:firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
:password => "newpass123", :password_confirmation => "newpass123"}
assert_equal 'newuser@foo.bar', token.user.mail
assert !token.expired?
- get 'account/activate', :token => token.value
+ get '/account/activate', :token => token.value
assert_redirected_to '/login'
log_user('newuser', 'newpass123')
end
assert_select 'input[name=?]', 'user[login]', 0
assert_select 'input[name=?]', 'user[password]', 0
- post 'account/register',
+ post '/account/register',
:user => {:firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com'}
assert_redirected_to '/my/account'
# register a new account
assert_difference 'User.count' do
assert_difference 'Token.count' do
- post 'account/register',
+ post '/account/register',
:user => {:login => "newuser", :language => "en",
:firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
:password => "newpass123", :password_confirmation => "newpass123"}
assert_kind_of User, logged_user
assert_equal "Paul", logged_user.firstname
- put "users/#{user.id}", :id => user.id, :user => { :status => User::STATUS_LOCKED }
+ put "/users/#{user.id}", :id => user.id, :user => { :status => User::STATUS_LOCKED }
assert_redirected_to "/users/#{ user.id }/edit"
locked_user = User.try_to_login("psmith", "psmith09")
assert_equal nil, locked_user
Setting.default_language = 'en'
# a french user
- get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
assert_select 'h2', :text => 'Projets'
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
# then an italien user
- get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
+ get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
assert_select 'h2', :text => 'Progetti'
assert_equal :it, current_language
assert_select "html[lang=?]", "it"
# not a supported language: default language should be used
- get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
+ get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
assert_response :success
assert_select 'h2', :text => 'Projects'
assert_select "html[lang=?]", "en"
def test_token_based_access_should_not_start_session
# issue of a private project
- get 'issues/4.atom'
+ get '/issues/4.atom'
assert_response 302
rss_key = User.find(2).rss_key
- get "issues/4.atom?key=#{rss_key}"
+ get "/issues/4.atom?key=#{rss_key}"
assert_response 200
assert_nil session[:user_id]
end
def test_localization_should_be_set_correctly_on_invalid_token
ActionController::Base.allow_forgery_protection = true
Setting.default_language = 'en'
- post 'issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ post '/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response 422
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
# create an issue
def test_add_issue
log_user('jsmith', 'jsmith')
- get 'projects/1/issues/new', :tracker_id => '1'
+ get '/projects/1/issues/new', :tracker_id => '1'
assert_response :success
assert_template 'issues/new'
- post 'projects/1/issues', :tracker_id => "1",
+ post '/projects/1/issues', :tracker_id => "1",
:issue => { :start_date => "2006-12-26",
:priority_id => "4",
:subject => "new test issue",
Role.anonymous.remove_permission! :add_issues
assert_no_difference 'Issue.count' do
- post 'projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
+ post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
end
assert_response 302
end
Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [3])
assert_difference 'Issue.count' do
- post 'projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
+ post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
end
assert_response 302
issue = Issue.order("id DESC").first
log_user('jsmith', 'jsmith')
set_tmp_attachments_directory
- put 'issues/1',
+ put '/issues/1',
:notes => 'Some notes',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
assert_redirected_to "/issues/1"
:enabled_modules
def test_project_menu_with_specific_locale
- get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ get '/projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_select 'div#main-menu' do
assert_select 'li a.activity[href=?]', '/projects/ecookbook/activity', :text => ll('fr', :label_activity)
menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
end
- get 'projects/ecookbook'
+ get '/projects/ecookbook'
assert_select 'div#main-menu ul' do
assert_select 'li:last-child a.foo[href=?]', '/projects/ecookbook', :text => 'Foo'
def test_archive_project
subproject = Project.find(1).children.first
log_user("admin", "admin")
- get "admin/projects"
+ get "/admin/projects"
assert_response :success
assert_template "admin/projects"
- post "projects/1/archive"
+ post "/projects/1/archive"
assert_redirected_to "/admin/projects"
assert !Project.find(1).active?
- get 'projects/1'
+ get '/projects/1'
assert_response 403
- get "projects/#{subproject.id}"
+ get "/projects/#{subproject.id}"
assert_response 403
- post "projects/1/unarchive"
+ post "/projects/1/unarchive"
assert_redirected_to "/admin/projects"
assert Project.find(1).active?
- get "projects/1"
+ get "/projects/1"
assert_response :success
end