mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Use Rails 5 syntax for functional tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@16585 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1d4300b674
commit
b834e81d7f
@ -41,13 +41,17 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
existing_user.login = 'cool_user'
|
existing_user.login = 'cool_user'
|
||||||
assert existing_user.save!
|
assert existing_user.save!
|
||||||
|
|
||||||
post :login, :openid_url => existing_user.identity_url
|
post :login, :params => {
|
||||||
|
:openid_url => existing_user.identity_url
|
||||||
|
}
|
||||||
assert_redirected_to '/my/page'
|
assert_redirected_to '/my/page'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_login_with_invalid_openid_provider
|
def test_login_with_invalid_openid_provider
|
||||||
Setting.self_registration = '0'
|
Setting.self_registration = '0'
|
||||||
post :login, :openid_url => 'http;//openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http;//openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_redirected_to home_url
|
assert_redirected_to home_url
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,13 +65,17 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
existing_user.login = 'cool_user'
|
existing_user.login = 'cool_user'
|
||||||
assert existing_user.save!
|
assert existing_user.save!
|
||||||
|
|
||||||
post :login, :openid_url => existing_user.identity_url
|
post :login, :params => {
|
||||||
|
:openid_url => existing_user.identity_url
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_login_with_openid_with_new_user_created
|
def test_login_with_openid_with_new_user_created
|
||||||
Setting.self_registration = '3'
|
Setting.self_registration = '3'
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
user = User.find_by_login('cool_user')
|
user = User.find_by_login('cool_user')
|
||||||
assert user
|
assert user
|
||||||
@ -77,7 +85,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_login_with_openid_with_new_user_and_self_registration_off
|
def test_login_with_openid_with_new_user_and_self_registration_off
|
||||||
Setting.self_registration = '0'
|
Setting.self_registration = '0'
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_redirected_to home_url
|
assert_redirected_to home_url
|
||||||
user = User.find_by_login('cool_user')
|
user = User.find_by_login('cool_user')
|
||||||
assert_nil user
|
assert_nil user
|
||||||
@ -85,7 +95,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
|
def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
|
||||||
Setting.self_registration = '1'
|
Setting.self_registration = '1'
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
user = User.find_by_login('cool_user')
|
user = User.find_by_login('cool_user')
|
||||||
assert user
|
assert user
|
||||||
@ -96,7 +108,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_login_with_openid_with_new_user_created_with_manual_activation
|
def test_login_with_openid_with_new_user_created_with_manual_activation
|
||||||
Setting.self_registration = '2'
|
Setting.self_registration = '2'
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
user = User.find_by_login('cool_user')
|
user = User.find_by_login('cool_user')
|
||||||
assert user
|
assert user
|
||||||
@ -109,7 +123,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
existing_user.login = 'cool_user'
|
existing_user.login = 'cool_user'
|
||||||
assert existing_user.save!
|
assert existing_user.save!
|
||||||
|
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_user'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value=?]', 'user[identity_url]', 'http://openid.example.com/good_user'
|
assert_select 'input[name=?][value=?]', 'user[identity_url]', 'http://openid.example.com/good_user'
|
||||||
@ -118,7 +134,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
def test_login_with_openid_with_new_user_with_missing_information_should_register
|
def test_login_with_openid_with_new_user_with_missing_information_should_register
|
||||||
Setting.self_registration = '3'
|
Setting.self_registration = '3'
|
||||||
|
|
||||||
post :login, :openid_url => 'http://openid.example.com/good_blank_user'
|
post :login, :params => {
|
||||||
|
:openid_url => 'http://openid.example.com/good_blank_user'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?]', 'user[login]'
|
assert_select 'input[name=?]', 'user[login]'
|
||||||
@ -141,7 +159,8 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
Setting.self_registration = '3'
|
Setting.self_registration = '3'
|
||||||
|
|
||||||
assert_difference 'User.count' do
|
assert_difference 'User.count' do
|
||||||
post :register, :user => {
|
post :register, :params => {
|
||||||
|
:user => {
|
||||||
:login => 'good_blank_user',
|
:login => 'good_blank_user',
|
||||||
:password => '',
|
:password => '',
|
||||||
:password_confirmation => '',
|
:password_confirmation => '',
|
||||||
@ -149,6 +168,8 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
|||||||
:lastname => 'User',
|
:lastname => 'User',
|
||||||
:mail => 'user@somedomain.com',
|
:mail => 'user@somedomain.com',
|
||||||
:identity_url => 'http://openid.example.com/good_blank_user'
|
:identity_url => 'http://openid.example.com/good_blank_user'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|||||||
@ -36,7 +36,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
@request.env["HTTP_REFERER"] = 'http://test.host/issues/show/1'
|
@request.env["HTTP_REFERER"] = 'http://test.host/issues/show/1'
|
||||||
|
|
||||||
get :login, :back_url => 'http://test.host/issues/show/1'
|
get :login, :params => {
|
||||||
|
:back_url => 'http://test.host/issues/show/1'
|
||||||
|
}
|
||||||
assert_redirected_to '/issues/show/1'
|
assert_redirected_to '/issues/show/1'
|
||||||
assert_equal 2, @request.session[:user_id]
|
assert_equal 2, @request.session[:user_id]
|
||||||
end
|
end
|
||||||
@ -66,7 +68,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
'/'
|
'/'
|
||||||
]
|
]
|
||||||
back_urls.each do |back_url|
|
back_urls.each do |back_url|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith',
|
||||||
|
:back_url => back_url
|
||||||
|
}
|
||||||
assert_redirected_to back_url
|
assert_redirected_to back_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -80,7 +86,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
'/redmine'
|
'/redmine'
|
||||||
]
|
]
|
||||||
back_urls.each do |back_url|
|
back_urls.each do |back_url|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith',
|
||||||
|
:back_url => back_url
|
||||||
|
}
|
||||||
assert_redirected_to back_url
|
assert_redirected_to back_url
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
@ -93,7 +103,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
'//test.foo/fake'
|
'//test.foo/fake'
|
||||||
]
|
]
|
||||||
back_urls.each do |back_url|
|
back_urls.each do |back_url|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith',
|
||||||
|
:back_url => back_url
|
||||||
|
}
|
||||||
assert_redirected_to '/my/page'
|
assert_redirected_to '/my/page'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -120,7 +134,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
'.test.foo'
|
'.test.foo'
|
||||||
]
|
]
|
||||||
back_urls.each do |back_url|
|
back_urls.each do |back_url|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith',
|
||||||
|
:back_url => back_url
|
||||||
|
}
|
||||||
assert_redirected_to '/my/page'
|
assert_redirected_to '/my/page'
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
@ -128,7 +146,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_login_with_wrong_password
|
def test_login_with_wrong_password
|
||||||
post :login, :username => 'admin', :password => 'bad'
|
post :login, :params => {
|
||||||
|
:username => 'admin',
|
||||||
|
:password => 'bad'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'div.flash.error', :text => /Invalid user or password/
|
assert_select 'div.flash.error', :text => /Invalid user or password/
|
||||||
@ -140,7 +161,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_login_with_locked_account_should_fail
|
def test_login_with_locked_account_should_fail
|
||||||
User.find(2).update_attribute :status, User::STATUS_LOCKED
|
User.find(2).update_attribute :status, User::STATUS_LOCKED
|
||||||
|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
assert_include 'locked', flash[:error]
|
assert_include 'locked', flash[:error]
|
||||||
assert_nil @request.session[:user_id]
|
assert_nil @request.session[:user_id]
|
||||||
@ -150,7 +174,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
||||||
|
|
||||||
with_settings :self_registration => '2', :default_language => 'en' do
|
with_settings :self_registration => '2', :default_language => 'en' do
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
assert_include 'pending administrator approval', flash[:error]
|
assert_include 'pending administrator approval', flash[:error]
|
||||||
end
|
end
|
||||||
@ -160,7 +187,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
||||||
|
|
||||||
with_settings :self_registration => '1', :default_language => 'en' do
|
with_settings :self_registration => '1', :default_language => 'en' do
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
assert_equal 2, @request.session[:registered_user_id]
|
assert_equal 2, @request.session[:registered_user_id]
|
||||||
assert_include 'new activation email', flash[:error]
|
assert_include 'new activation email', flash[:error]
|
||||||
@ -172,7 +202,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
User.find(2).update_attribute :auth_source_id, source.id
|
User.find(2).update_attribute :auth_source_id, source.id
|
||||||
AuthSource.any_instance.stubs(:authenticate).raises(AuthSourceException.new("Something wrong"))
|
AuthSource.any_instance.stubs(:authenticate).raises(AuthSourceException.new("Something wrong"))
|
||||||
|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith'
|
||||||
|
}
|
||||||
assert_response 500
|
assert_response 500
|
||||||
assert_select_error /Something wrong/
|
assert_select_error /Something wrong/
|
||||||
end
|
end
|
||||||
@ -180,7 +213,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_login_should_reset_session
|
def test_login_should_reset_session
|
||||||
@controller.expects(:reset_session).once
|
@controller.expects(:reset_session).once
|
||||||
|
|
||||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
post :login, :params => {
|
||||||
|
:username => 'jsmith',
|
||||||
|
:password => 'jsmith'
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -257,13 +293,16 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_register_with_registration_on
|
def test_post_register_with_registration_on
|
||||||
with_settings :self_registration => '3' do
|
with_settings :self_registration => '3' do
|
||||||
assert_difference 'User.count' do
|
assert_difference 'User.count' do
|
||||||
post :register, :user => {
|
post :register, :params => {
|
||||||
|
:user => {
|
||||||
:login => 'register',
|
:login => 'register',
|
||||||
:password => 'secret123',
|
:password => 'secret123',
|
||||||
:password_confirmation => 'secret123',
|
:password_confirmation => 'secret123',
|
||||||
:firstname => 'John',
|
:firstname => 'John',
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:mail => 'register@example.com'
|
:mail => 'register@example.com'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
end
|
end
|
||||||
@ -280,13 +319,16 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_register_with_registration_off_should_redirect
|
def test_post_register_with_registration_off_should_redirect
|
||||||
with_settings :self_registration => '0' do
|
with_settings :self_registration => '0' do
|
||||||
assert_no_difference 'User.count' do
|
assert_no_difference 'User.count' do
|
||||||
post :register, :user => {
|
post :register, :params => {
|
||||||
|
:user => {
|
||||||
:login => 'register',
|
:login => 'register',
|
||||||
:password => 'test',
|
:password => 'test',
|
||||||
:password_confirmation => 'test',
|
:password_confirmation => 'test',
|
||||||
:firstname => 'John',
|
:firstname => 'John',
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:mail => 'register@example.com'
|
:mail => 'register@example.com'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
end
|
end
|
||||||
@ -296,13 +338,20 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_register_should_create_user_with_hide_mail_preference
|
def test_post_register_should_create_user_with_hide_mail_preference
|
||||||
with_settings :default_users_hide_mail => '0' do
|
with_settings :default_users_hide_mail => '0' do
|
||||||
user = new_record(User) do
|
user = new_record(User) do
|
||||||
post :register, :user => {
|
post :register, :params => {
|
||||||
|
:user => {
|
||||||
:login => 'register',
|
:login => 'register',
|
||||||
:password => 'secret123', :password_confirmation => 'secret123',
|
:password => 'secret123',
|
||||||
:firstname => 'John', :lastname => 'Doe',
|
:password_confirmation => 'secret123',
|
||||||
|
:firstname => 'John',
|
||||||
|
:lastname => 'Doe',
|
||||||
:mail => 'register@example.com'
|
:mail => 'register@example.com'
|
||||||
}, :pref => {
|
|
||||||
|
},
|
||||||
|
:pref => {
|
||||||
:hide_mail => '1'
|
:hide_mail => '1'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_equal true, user.pref.hide_mail
|
assert_equal true, user.pref.hide_mail
|
||||||
@ -320,7 +369,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||||
assert_difference 'Token.count' do
|
assert_difference 'Token.count' do
|
||||||
post :lost_password, :mail => 'JSmith@somenet.foo'
|
post :lost_password, :params => {
|
||||||
|
:mail => 'JSmith@somenet.foo'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -340,7 +391,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||||
assert_difference 'Token.count' do
|
assert_difference 'Token.count' do
|
||||||
post :lost_password, :mail => 'ANOTHERaddress@foo.bar'
|
post :lost_password, :params => {
|
||||||
|
:mail => 'ANOTHERaddress@foo.bar'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -351,7 +404,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
def test_lost_password_for_unknown_user_should_fail
|
def test_lost_password_for_unknown_user_should_fail
|
||||||
Token.delete_all
|
Token.delete_all
|
||||||
assert_no_difference 'Token.count' do
|
assert_no_difference 'Token.count' do
|
||||||
post :lost_password, :mail => 'invalid@somenet.foo'
|
post :lost_password, :params => {
|
||||||
|
:mail => 'invalid@somenet.foo'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -361,7 +416,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
assert User.find(2).lock!
|
assert User.find(2).lock!
|
||||||
|
|
||||||
assert_no_difference 'Token.count' do
|
assert_no_difference 'Token.count' do
|
||||||
post :lost_password, :mail => 'JSmith@somenet.foo'
|
post :lost_password, :params => {
|
||||||
|
:mail => 'JSmith@somenet.foo'
|
||||||
|
}
|
||||||
assert_redirected_to '/account/lost_password'
|
assert_redirected_to '/account/lost_password'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -370,7 +427,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
User.any_instance.stubs(:change_password_allowed?).returns(false)
|
User.any_instance.stubs(:change_password_allowed?).returns(false)
|
||||||
|
|
||||||
assert_no_difference 'Token.count' do
|
assert_no_difference 'Token.count' do
|
||||||
post :lost_password, :mail => 'JSmith@somenet.foo'
|
post :lost_password, :params => {
|
||||||
|
:mail => 'JSmith@somenet.foo'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -379,7 +438,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
get :lost_password, :token => token.value
|
get :lost_password, :params => {
|
||||||
|
:token => token.value
|
||||||
|
}
|
||||||
assert_redirected_to '/account/lost_password'
|
assert_redirected_to '/account/lost_password'
|
||||||
|
|
||||||
assert_equal token.value, request.session[:password_recovery_token]
|
assert_equal token.value, request.session[:password_recovery_token]
|
||||||
@ -397,7 +458,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_get_lost_password_with_invalid_token_should_redirect
|
def test_get_lost_password_with_invalid_token_should_redirect
|
||||||
get :lost_password, :token => "abcdef"
|
get :lost_password, :params => {
|
||||||
|
:token => "abcdef"
|
||||||
|
}
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -406,7 +469,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpass123', :new_password_confirmation => 'newpass123'
|
post :lost_password, :params => {
|
||||||
|
:token => token.value,
|
||||||
|
:new_password => 'newpass123',
|
||||||
|
:new_password_confirmation => 'newpass123'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
user.reload
|
user.reload
|
||||||
assert user.check_password?('newpass123')
|
assert user.check_password?('newpass123')
|
||||||
@ -422,7 +489,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
user.lock!
|
user.lock!
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpass123', :new_password_confirmation => 'newpass123'
|
post :lost_password, :params => {
|
||||||
|
:token => token.value,
|
||||||
|
:new_password => 'newpass123',
|
||||||
|
:new_password_confirmation => 'newpass123'
|
||||||
|
}
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
assert ! user.check_password?('newpass123')
|
assert ! user.check_password?('newpass123')
|
||||||
end
|
end
|
||||||
@ -431,7 +502,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'wrongpass'
|
post :lost_password, :params => {
|
||||||
|
:token => token.value,
|
||||||
|
:new_password => 'newpass',
|
||||||
|
:new_password_confirmation => 'wrongpass'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
|
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
|
||||||
|
|
||||||
@ -445,7 +520,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
user.save!
|
user.save!
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'originalpassword', :new_password_confirmation => 'originalpassword'
|
post :lost_password, :params => {
|
||||||
|
:token => token.value,
|
||||||
|
:new_password => 'originalpassword',
|
||||||
|
:new_password_confirmation => 'originalpassword'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
|
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
|
||||||
|
|
||||||
@ -460,14 +539,22 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
user.save!
|
user.save!
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpassword', :new_password_confirmation => 'newpassword'
|
post :lost_password, :params => {
|
||||||
|
:token => token.value,
|
||||||
|
:new_password => 'newpassword',
|
||||||
|
:new_password_confirmation => 'newpassword'
|
||||||
|
}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
|
|
||||||
assert_equal false, user.reload.must_change_passwd
|
assert_equal false, user.reload.must_change_passwd
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_lost_password_with_invalid_token_should_redirect
|
def test_post_lost_password_with_invalid_token_should_redirect
|
||||||
post :lost_password, :token => "abcdef", :new_password => 'newpass', :new_password_confirmation => 'newpass'
|
post :lost_password, :params => {
|
||||||
|
:token => "abcdef",
|
||||||
|
:new_password => 'newpass',
|
||||||
|
:new_password_confirmation => 'newpass'
|
||||||
|
}
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
|
|
||||||
def test_project_index
|
def test_project_index
|
||||||
get :index, :id => 1, :with_subprojects => 0
|
get :index, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:with_subprojects => 0
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
|
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
|
||||||
@ -38,12 +41,17 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_project_index_with_invalid_project_id_should_respond_404
|
def test_project_index_with_invalid_project_id_should_respond_404
|
||||||
get :index, :id => 299
|
get :index, :params => {
|
||||||
|
:id => 299
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_previous_project_index
|
def test_previous_project_index
|
||||||
get :index, :id => 1, :from => 2.days.ago.to_date
|
get :index, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:from => 2.days.ago.to_date
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
|
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
|
||||||
@ -64,7 +72,9 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_user_index
|
def test_user_index
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
|
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
|
||||||
@ -77,12 +87,17 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_user_index_with_invalid_user_id_should_respond_404
|
def test_user_index_with_invalid_user_id_should_respond_404
|
||||||
get :index, :user_id => 299
|
get :index, :params => {
|
||||||
|
:user_id => 299
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_atom_feed
|
def test_index_atom_feed
|
||||||
get :index, :format => 'atom', :with_subprojects => 0
|
get :index, :params => {
|
||||||
|
:format => 'atom',
|
||||||
|
:with_subprojects => 0
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'feed' do
|
assert_select 'feed' do
|
||||||
@ -95,7 +110,9 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_atom_feed_with_explicit_selection
|
def test_index_atom_feed_with_explicit_selection
|
||||||
get :index, :format => 'atom', :with_subprojects => 0,
|
get :index, :params => {
|
||||||
|
:format => 'atom',
|
||||||
|
:with_subprojects => 0,
|
||||||
:show_changesets => 1,
|
:show_changesets => 1,
|
||||||
:show_documents => 1,
|
:show_documents => 1,
|
||||||
:show_files => 1,
|
:show_files => 1,
|
||||||
@ -104,6 +121,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
:show_news => 1,
|
:show_news => 1,
|
||||||
:show_time_entries => 1,
|
:show_time_entries => 1,
|
||||||
:show_wiki_edits => 1
|
:show_wiki_edits => 1
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
@ -118,7 +136,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_index_atom_feed_with_one_item_type
|
def test_index_atom_feed_with_one_item_type
|
||||||
with_settings :default_language => 'en' do
|
with_settings :default_language => 'en' do
|
||||||
get :index, :format => 'atom', :show_issues => '1'
|
get :index, :params => {
|
||||||
|
:format => 'atom',
|
||||||
|
:show_issues => '1'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'title', :text => /Issues/
|
assert_select 'title', :text => /Issues/
|
||||||
@ -126,7 +147,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_atom_feed_with_user
|
def test_index_atom_feed_with_user
|
||||||
get :index, :user_id => 2, :format => 'atom'
|
get :index, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:format => 'atom'
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'title', :text => "Redmine: #{User.find(2).name}"
|
assert_select 'title', :text => "Redmine: #{User.find(2).name}"
|
||||||
@ -149,7 +173,11 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
def test_index_with_submitted_scope_should_save_as_preference
|
def test_index_with_submitted_scope_should_save_as_preference
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
|
get :index, :params => {
|
||||||
|
:show_issues => '1',
|
||||||
|
:show_messages => '1',
|
||||||
|
:submit => 'Apply'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
|
assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
|
||||||
end
|
end
|
||||||
@ -182,7 +210,9 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
def test_index_up_to_yesterday_should_show_next_page_link
|
def test_index_up_to_yesterday_should_show_next_page_link
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :index, :from => (User.find(2).today-1)
|
get :index, :params => {
|
||||||
|
:from => (User.find(2).today-1)
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '.pagination a', :text => /Previous/
|
assert_select '.pagination a', :text => /Previous/
|
||||||
assert_select '.pagination a', :text => /Next/
|
assert_select '.pagination a', :text => /Next/
|
||||||
|
|||||||
@ -43,13 +43,18 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_projects_with_status_filter
|
def test_projects_with_status_filter
|
||||||
get :projects, :status => 1
|
get :projects, :params => {
|
||||||
|
:status => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr.project.closed', 0
|
assert_select 'tr.project.closed', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_projects_with_name_filter
|
def test_projects_with_name_filter
|
||||||
get :projects, :name => 'store', :status => ''
|
get :projects, :params => {
|
||||||
|
:name => 'store',
|
||||||
|
:status => ''
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'tr.project td.name', :text => 'OnlineStore'
|
assert_select 'tr.project td.name', :text => 'OnlineStore'
|
||||||
@ -58,7 +63,9 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_load_default_configuration_data
|
def test_load_default_configuration_data
|
||||||
delete_configuration_data
|
delete_configuration_data
|
||||||
post :default_configuration, :lang => 'fr'
|
post :default_configuration, :params => {
|
||||||
|
:lang => 'fr'
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_nil flash[:error]
|
assert_nil flash[:error]
|
||||||
assert IssueStatus.find_by_name('Nouveau')
|
assert IssueStatus.find_by_name('Nouveau')
|
||||||
@ -67,7 +74,9 @@ class AdminControllerTest < Redmine::ControllerTest
|
|||||||
def test_load_default_configuration_data_should_rescue_error
|
def test_load_default_configuration_data_should_rescue_error
|
||||||
delete_configuration_data
|
delete_configuration_data
|
||||||
Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
|
Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
|
||||||
post :default_configuration, :lang => 'fr'
|
post :default_configuration, :params => {
|
||||||
|
:lang => 'fr'
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_not_nil flash[:error]
|
assert_not_nil flash[:error]
|
||||||
assert_match /Something went wrong/, flash[:error]
|
assert_match /Something went wrong/, flash[:error]
|
||||||
|
|||||||
@ -36,7 +36,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_show_diff
|
def test_show_diff
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
# 060719210727_changeset_utf8.diff
|
# 060719210727_changeset_utf8.diff
|
||||||
get :show, :id => 14, :type => dt
|
get :show, :params => {
|
||||||
|
:id => 14,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
@ -50,7 +53,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :repositories_encodings => 'UTF-8' do
|
with_settings :repositories_encodings => 'UTF-8' do
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
# 060719210727_changeset_iso8859-1.diff
|
# 060719210727_changeset_iso8859-1.diff
|
||||||
get :show, :id => 5, :type => dt
|
get :show, :params => {
|
||||||
|
:id => 5,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
@ -65,7 +71,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
# 060719210727_changeset_iso8859-1.diff
|
# 060719210727_changeset_iso8859-1.diff
|
||||||
get :show, :id => 5, :type => dt
|
get :show, :params => {
|
||||||
|
:id => 5,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
@ -84,12 +93,17 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_nil user.pref[:diff_type]
|
assert_nil user.pref[:diff_type]
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
|
|
||||||
get :show, :id => 5
|
get :show, :params => {
|
||||||
|
:id => 5
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
user.reload
|
user.reload
|
||||||
assert_equal "inline", user.pref[:diff_type]
|
assert_equal "inline", user.pref[:diff_type]
|
||||||
|
|
||||||
get :show, :id => 5, :type => 'sbs'
|
get :show, :params => {
|
||||||
|
:id => 5,
|
||||||
|
:type => 'sbs'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
user.reload
|
user.reload
|
||||||
assert_equal "sbs", user.pref[:diff_type]
|
assert_equal "sbs", user.pref[:diff_type]
|
||||||
@ -103,14 +117,19 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert a.save
|
assert a.save
|
||||||
assert_equal 'hg-export.diff', a.filename
|
assert_equal 'hg-export.diff', a.filename
|
||||||
|
|
||||||
get :show, :id => a.id, :type => 'inline'
|
get :show, :params => {
|
||||||
|
:id => a.id,
|
||||||
|
:type => 'inline'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'th.filename', :text => 'test1.txt'
|
assert_select 'th.filename', :text => 'test1.txt'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_text_file
|
def test_show_text_file
|
||||||
get :show, :id => 4
|
get :show, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@ -126,7 +145,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||||||
|
|
||||||
get :show, :id => a.id
|
get :show, :params => {
|
||||||
|
:id => a.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'tr#L1' do
|
assert_select 'tr#L1' do
|
||||||
@ -144,7 +165,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert a.save
|
assert a.save
|
||||||
assert_equal 'iso8859-1.txt', a.filename
|
assert_equal 'iso8859-1.txt', a.filename
|
||||||
|
|
||||||
get :show, :id => a.id
|
get :show, :params => {
|
||||||
|
:id => a.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'tr#L7' do
|
assert_select 'tr#L7' do
|
||||||
@ -163,7 +186,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert a.save
|
assert a.save
|
||||||
assert_equal 'iso8859-1.txt', a.filename
|
assert_equal 'iso8859-1.txt', a.filename
|
||||||
|
|
||||||
get :show, :id => a.id
|
get :show, :params => {
|
||||||
|
:id => a.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'tr#L7' do
|
assert_select 'tr#L7' do
|
||||||
@ -177,7 +202,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
with_settings :file_max_size_displayed => 512 do
|
with_settings :file_max_size_displayed => 512 do
|
||||||
Attachment.find(4).update_attribute :filesize, 754.kilobyte
|
Attachment.find(4).update_attribute :filesize, 754.kilobyte
|
||||||
get :show, :id => 4
|
get :show, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select '.nodata', :text => 'No preview available'
|
assert_select '.nodata', :text => 'No preview available'
|
||||||
@ -187,7 +214,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_image
|
def test_show_image
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => 16
|
get :show, :params => {
|
||||||
|
:id => 16
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename
|
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename
|
||||||
@ -195,21 +224,27 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_other
|
def test_show_other
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => 6
|
get :show, :params => {
|
||||||
|
:id => 6
|
||||||
|
}
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select '.nodata', :text => 'No preview available'
|
assert_select '.nodata', :text => 'No preview available'
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_file_from_private_issue_without_permission
|
def test_show_file_from_private_issue_without_permission
|
||||||
get :show, :id => 15
|
get :show, :params => {
|
||||||
|
:id => 15
|
||||||
|
}
|
||||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F15'
|
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F15'
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_file_from_private_issue_with_permission
|
def test_show_file_from_private_issue_with_permission
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => 15
|
get :show, :params => {
|
||||||
|
:id => 15
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /private.diff/
|
assert_select 'h2', :text => /private.diff/
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@ -220,7 +255,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :id => attachment.id
|
get :show, :params => {
|
||||||
|
:id => attachment.id
|
||||||
|
}
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -229,24 +266,32 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
||||||
|
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
get :show, :id => attachment.id
|
get :show, :params => {
|
||||||
|
:id => attachment.id
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_invalid_should_respond_with_404
|
def test_show_invalid_should_respond_with_404
|
||||||
get :show, :id => 999
|
get :show, :params => {
|
||||||
|
:id => 999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_text_file
|
def test_download_text_file
|
||||||
get :download, :id => 4
|
get :download, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/x-ruby', @response.content_type
|
assert_equal 'application/x-ruby', @response.content_type
|
||||||
etag = @response.etag
|
etag = @response.etag
|
||||||
assert_not_nil etag
|
assert_not_nil etag
|
||||||
|
|
||||||
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
||||||
get :download, :id => 4
|
get :download, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response 304
|
assert_response 304
|
||||||
|
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@ -260,21 +305,27 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
:container => Issue.find(1)
|
:container => Issue.find(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
get :download, :id => attachment.id
|
get :download, :params => {
|
||||||
|
:id => attachment.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', @response.content_type
|
assert_equal 'text/javascript', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_version_file_with_issue_tracking_disabled
|
def test_download_version_file_with_issue_tracking_disabled
|
||||||
Project.find(1).disable_module! :issue_tracking
|
Project.find(1).disable_module! :issue_tracking
|
||||||
get :download, :id => 9
|
get :download, :params => {
|
||||||
|
:id => 9
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_should_assign_content_type_if_blank
|
def test_download_should_assign_content_type_if_blank
|
||||||
Attachment.find(4).update_attribute(:content_type, '')
|
Attachment.find(4).update_attribute(:content_type, '')
|
||||||
|
|
||||||
get :download, :id => 4
|
get :download, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/x-ruby', @response.content_type
|
assert_equal 'text/x-ruby', @response.content_type
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@ -283,20 +334,26 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_download_should_assign_better_content_type_than_application_octet_stream
|
def test_download_should_assign_better_content_type_than_application_octet_stream
|
||||||
Attachment.find(4).update! :content_type => "application/octet-stream"
|
Attachment.find(4).update! :content_type => "application/octet-stream"
|
||||||
|
|
||||||
get :download, :id => 4
|
get :download, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/x-ruby', @response.content_type
|
assert_equal 'text/x-ruby', @response.content_type
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_missing_file
|
def test_download_missing_file
|
||||||
get :download, :id => 2
|
get :download, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_should_be_denied_without_permission
|
def test_download_should_be_denied_without_permission
|
||||||
get :download, :id => 7
|
get :download, :params => {
|
||||||
|
:id => 7
|
||||||
|
}
|
||||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7'
|
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7'
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
@ -305,7 +362,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_thumbnail
|
def test_thumbnail
|
||||||
Attachment.clear_thumbnails
|
Attachment.clear_thumbnails
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :thumbnail, :id => 16
|
get :thumbnail, :params => {
|
||||||
|
:id => 16
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'image/png', response.content_type
|
assert_equal 'image/png', response.content_type
|
||||||
|
|
||||||
@ -313,7 +372,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_not_nil etag
|
assert_not_nil etag
|
||||||
|
|
||||||
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
||||||
get :thumbnail, :id => 16
|
get :thumbnail, :params => {
|
||||||
|
:id => 16
|
||||||
|
}
|
||||||
assert_response 304
|
assert_response 304
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -321,20 +382,28 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
|
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :thumbnail, :id => 16, :size => 2000
|
get :thumbnail, :params => {
|
||||||
|
:id => 16,
|
||||||
|
:size => 2000
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_thumbnail_should_round_size
|
def test_thumbnail_should_round_size
|
||||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 250}
|
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 250}
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :thumbnail, :id => 16, :size => 260
|
get :thumbnail, :params => {
|
||||||
|
:id => 16,
|
||||||
|
:size => 260
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_thumbnail_should_return_404_for_non_image_attachment
|
def test_thumbnail_should_return_404_for_non_image_attachment
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :thumbnail, :id => 15
|
get :thumbnail, :params => {
|
||||||
|
:id => 15
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -342,12 +411,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
Attachment.any_instance.stubs(:thumbnail).returns(nil)
|
Attachment.any_instance.stubs(:thumbnail).returns(nil)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :thumbnail, :id => 16
|
get :thumbnail, :params => {
|
||||||
|
:id => 16
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_thumbnail_should_be_denied_without_permission
|
def test_thumbnail_should_be_denied_without_permission
|
||||||
get :thumbnail, :id => 16
|
get :thumbnail, :params => {
|
||||||
|
:id => 16
|
||||||
|
}
|
||||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fthumbnail%2F16'
|
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fthumbnail%2F16'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -356,7 +429,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_all
|
def test_edit_all
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit_all, :object_type => 'issues', :object_id => '2'
|
get :edit_all, :params => {
|
||||||
|
:object_type => 'issues',
|
||||||
|
:object_id => '2'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form[action=?]', '/attachments/issues/2' do
|
assert_select 'form[action=?]', '/attachments/issues/2' do
|
||||||
@ -372,25 +448,45 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_all_with_invalid_container_class_should_return_404
|
def test_edit_all_with_invalid_container_class_should_return_404
|
||||||
get :edit_all, :object_type => 'nuggets', :object_id => '3'
|
get :edit_all, :params => {
|
||||||
|
:object_type => 'nuggets',
|
||||||
|
:object_id => '3'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_all_with_invalid_object_should_return_404
|
def test_edit_all_with_invalid_object_should_return_404
|
||||||
get :edit_all, :object_type => 'issues', :object_id => '999'
|
get :edit_all, :params => {
|
||||||
|
:object_type => 'issues',
|
||||||
|
:object_id => '999'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_all_for_object_that_is_not_visible_should_return_403
|
def test_edit_all_for_object_that_is_not_visible_should_return_403
|
||||||
get :edit_all, :object_type => 'issues', :object_id => '4'
|
get :edit_all, :params => {
|
||||||
|
:object_type => 'issues',
|
||||||
|
:object_id => '4'
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_all
|
def test_update_all
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
patch :update_all, :object_type => 'issues', :object_id => '2', :attachments => {
|
patch :update_all, :params => {
|
||||||
'1' => {:filename => 'newname.text', :description => ''},
|
:object_type => 'issues',
|
||||||
'4' => {:filename => 'newname.rb', :description => 'Renamed'},
|
:object_id => '2',
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
:filename => 'newname.text',
|
||||||
|
:description => ''
|
||||||
|
},
|
||||||
|
'4' => {
|
||||||
|
:filename => 'newname.rb',
|
||||||
|
:description => 'Renamed'
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@ -401,9 +497,20 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_all_with_failure
|
def test_update_all_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
patch :update_all, :object_type => 'issues', :object_id => '3', :attachments => {
|
patch :update_all, :params => {
|
||||||
'1' => {:filename => '', :description => ''},
|
:object_type => 'issues',
|
||||||
'4' => {:filename => 'newname.rb', :description => 'Renamed'},
|
:object_id => '3',
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
:filename => '',
|
||||||
|
:description => ''
|
||||||
|
},
|
||||||
|
'4' => {
|
||||||
|
:filename => 'newname.rb',
|
||||||
|
:description => 'Renamed'
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -422,7 +529,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
assert_difference 'issue.attachments.count', -1 do
|
assert_difference 'issue.attachments.count', -1 do
|
||||||
assert_difference 'Journal.count' do
|
assert_difference 'Journal.count' do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook'
|
assert_redirected_to '/projects/ecookbook'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -439,7 +548,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Attachment.count', -1 do
|
assert_difference 'Attachment.count', -1 do
|
||||||
delete :destroy, :id => 3
|
delete :destroy, :params => {
|
||||||
|
:id => 3
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -448,7 +559,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Attachment.count', -1 do
|
assert_difference 'Attachment.count', -1 do
|
||||||
delete :destroy, :id => 8
|
delete :destroy, :params => {
|
||||||
|
:id => 8
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -457,7 +570,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Attachment.count', -1 do
|
assert_difference 'Attachment.count', -1 do
|
||||||
delete :destroy, :id => 9
|
delete :destroy, :params => {
|
||||||
|
:id => 9
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -467,7 +582,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Attachment.count', -1 do
|
assert_difference 'Attachment.count', -1 do
|
||||||
delete :destroy, :id => 9
|
delete :destroy, :params => {
|
||||||
|
:id => 9
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -475,7 +592,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy_without_permission
|
def test_destroy_without_permission
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
assert_no_difference 'Attachment.count' do
|
assert_no_difference 'Attachment.count' do
|
||||||
delete :destroy, :id => 3
|
delete :destroy, :params => {
|
||||||
|
:id => 3
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert Attachment.find_by_id(3)
|
assert Attachment.find_by_id(3)
|
||||||
|
|||||||
@ -40,13 +40,23 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_with_invalid_type_should_respond_with_404
|
def test_new_with_invalid_type_should_respond_with_404
|
||||||
get :new, :type => 'foo'
|
get :new, :params => {
|
||||||
|
:type => 'foo'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'AuthSourceLdap.count' do
|
assert_difference 'AuthSourceLdap.count' do
|
||||||
post :create, :type => 'AuthSourceLdap', :auth_source => {:name => 'Test', :host => '127.0.0.1', :port => '389', :attr_login => 'cn'}
|
post :create, :params => {
|
||||||
|
:type => 'AuthSourceLdap',
|
||||||
|
:auth_source => {
|
||||||
|
:name => 'Test',
|
||||||
|
:host => '127.0.0.1',
|
||||||
|
:port => '389',
|
||||||
|
:attr_login => 'cn'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -59,16 +69,24 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'AuthSourceLdap.count' do
|
assert_no_difference 'AuthSourceLdap.count' do
|
||||||
post :create, :type => 'AuthSourceLdap',
|
post :create, :params => {
|
||||||
:auth_source => {:name => 'Test', :host => '',
|
:type => 'AuthSourceLdap',
|
||||||
:port => '389', :attr_login => 'cn'}
|
:auth_source => {
|
||||||
|
:name => 'Test',
|
||||||
|
:host => '',
|
||||||
|
:port => '389',
|
||||||
|
:attr_login => 'cn'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
assert_select_error /host cannot be blank/i
|
assert_select_error /host cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form#auth_source_form' do
|
assert_select 'form#auth_source_form' do
|
||||||
@ -79,21 +97,31 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
def test_edit_should_not_contain_password
|
def test_edit_should_not_contain_password
|
||||||
AuthSource.find(1).update_column :account_password, 'secret'
|
AuthSource.find(1).update_column :account_password, 'secret'
|
||||||
|
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[value=secret]', 0
|
assert_select 'input[value=secret]', 0
|
||||||
assert_select 'input[name=dummy_password][value^=xxxxxx]'
|
assert_select 'input[name=dummy_password][value^=xxxxxx]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_invalid_should_respond_with_404
|
def test_edit_invalid_should_respond_with_404
|
||||||
get :edit, :id => 99
|
get :edit, :params => {
|
||||||
|
:id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
:auth_source => {:name => 'Renamed', :host => '192.168.0.10',
|
:id => 1,
|
||||||
:port => '389', :attr_login => 'uid'}
|
:auth_source => {
|
||||||
|
:name => 'Renamed',
|
||||||
|
:host => '192.168.0.10',
|
||||||
|
:port => '389',
|
||||||
|
:attr_login => 'uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
source = AuthSourceLdap.find(1)
|
source = AuthSourceLdap.find(1)
|
||||||
assert_equal 'Renamed', source.name
|
assert_equal 'Renamed', source.name
|
||||||
@ -101,16 +129,24 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
:auth_source => {:name => 'Renamed', :host => '',
|
:id => 1,
|
||||||
:port => '389', :attr_login => 'uid'}
|
:auth_source => {
|
||||||
|
:name => 'Renamed',
|
||||||
|
:host => '',
|
||||||
|
:port => '389',
|
||||||
|
:attr_login => 'uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /host cannot be blank/i
|
assert_select_error /host cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'AuthSourceLdap.count', -1 do
|
assert_difference 'AuthSourceLdap.count', -1 do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -119,7 +155,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
User.find(2).update_attribute :auth_source_id, 1
|
User.find(2).update_attribute :auth_source_id, 1
|
||||||
|
|
||||||
assert_no_difference 'AuthSourceLdap.count' do
|
assert_no_difference 'AuthSourceLdap.count' do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -127,7 +165,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
def test_test_connection
|
def test_test_connection
|
||||||
AuthSourceLdap.any_instance.stubs(:test_connection).returns(true)
|
AuthSourceLdap.any_instance.stubs(:test_connection).returns(true)
|
||||||
|
|
||||||
get :test_connection, :id => 1
|
get :test_connection, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
assert_not_nil flash[:notice]
|
assert_not_nil flash[:notice]
|
||||||
assert_match /successful/i, flash[:notice]
|
assert_match /successful/i, flash[:notice]
|
||||||
@ -136,7 +176,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
def test_test_connection_with_failure
|
def test_test_connection_with_failure
|
||||||
AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong"))
|
AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong"))
|
||||||
|
|
||||||
get :test_connection, :id => 1
|
get :test_connection, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/auth_sources'
|
assert_redirected_to '/auth_sources'
|
||||||
assert_not_nil flash[:error]
|
assert_not_nil flash[:error]
|
||||||
assert_include 'Something went wrong', flash[:error]
|
assert_include 'Something went wrong', flash[:error]
|
||||||
@ -148,7 +190,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
|||||||
{:login => 'Smith', :firstname => 'John', :lastname => 'Doe', :mail => 'foo2@example.net', :auth_source_id => 1}
|
{:login => 'Smith', :firstname => 'John', :lastname => 'Doe', :mail => 'foo2@example.net', :auth_source_id => 1}
|
||||||
])
|
])
|
||||||
|
|
||||||
get :autocomplete_for_new_user, :term => 'foo'
|
get :autocomplete_for_new_user, :params => {
|
||||||
|
:term => 'foo'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/json', response.content_type
|
assert_equal 'application/json', response.content_type
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
|
|||||||
@ -29,49 +29,73 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
|||||||
:journals, :journal_details
|
:journals, :journal_details
|
||||||
|
|
||||||
def test_issues_should_not_be_case_sensitive
|
def test_issues_should_not_be_case_sensitive
|
||||||
get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => 'ReCiPe'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "recipe", response.body
|
assert_include "recipe", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_should_accept_term_param
|
def test_issues_should_accept_term_param
|
||||||
get :issues, :project_id => 'ecookbook', :term => 'ReCiPe'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:term => 'ReCiPe'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "recipe", response.body
|
assert_include "recipe", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_should_return_issue_with_given_id
|
def test_issues_should_return_issue_with_given_id
|
||||||
get :issues, :project_id => 'subproject1', :q => '13'
|
get :issues, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:q => '13'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "Bug #13", response.body
|
assert_include "Bug #13", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_should_return_issue_with_given_id_preceded_with_hash
|
def test_issues_should_return_issue_with_given_id_preceded_with_hash
|
||||||
get :issues, :project_id => 'subproject1', :q => '#13'
|
get :issues, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:q => '#13'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "Bug #13", response.body
|
assert_include "Bug #13", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_with_scope_all_should_search_other_projects
|
def test_auto_complete_with_scope_all_should_search_other_projects
|
||||||
get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => '13',
|
||||||
|
:scope => 'all'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "Bug #13", response.body
|
assert_include "Bug #13", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_without_project_should_search_all_projects
|
def test_auto_complete_without_project_should_search_all_projects
|
||||||
get :issues, :q => '13'
|
get :issues, :params => {
|
||||||
|
:q => '13'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "Bug #13", response.body
|
assert_include "Bug #13", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_without_scope_all_should_not_search_other_projects
|
def test_auto_complete_without_scope_all_should_not_search_other_projects
|
||||||
get :issues, :project_id => 'ecookbook', :q => '13'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => '13'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_include "Bug #13", response.body
|
assert_not_include "Bug #13", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_should_return_json
|
def test_issues_should_return_json
|
||||||
get :issues, :project_id => 'subproject1', :q => '13'
|
get :issues, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:q => '13'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert_kind_of Array, json
|
assert_kind_of Array, json
|
||||||
@ -83,21 +107,33 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_with_status_o_should_return_open_issues_only
|
def test_auto_complete_with_status_o_should_return_open_issues_only
|
||||||
get :issues, :project_id => 'ecookbook', :q => 'issue', :status => 'o'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => 'issue',
|
||||||
|
:status => 'o'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "Issue due today", response.body
|
assert_include "Issue due today", response.body
|
||||||
assert_not_include "closed", response.body
|
assert_not_include "closed", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_with_status_c_should_return_closed_issues_only
|
def test_auto_complete_with_status_c_should_return_closed_issues_only
|
||||||
get :issues, :project_id => 'ecookbook', :q => 'issue', :status => 'c'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => 'issue',
|
||||||
|
:status => 'c'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "closed", response.body
|
assert_include "closed", response.body
|
||||||
assert_not_include "Issue due today", response.body
|
assert_not_include "Issue due today", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_complete_with_issue_id_should_not_return_that_issue
|
def test_auto_complete_with_issue_id_should_not_return_that_issue
|
||||||
get :issues, :project_id => 'ecookbook', :q => 'issue', :issue_id => '12'
|
get :issues, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:q => 'issue',
|
||||||
|
:issue_id => '12'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include "issue", response.body
|
assert_include "issue", response.body
|
||||||
assert_not_include "Bug #12: Closed issue on a locked version", response.body
|
assert_not_include "Bug #12: Closed issue on a locked version", response.body
|
||||||
|
|||||||
@ -25,20 +25,26 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.boards'
|
assert_select 'table.boards'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_not_found
|
def test_index_not_found
|
||||||
get :index, :project_id => 97
|
get :index, :params => {
|
||||||
|
:project_id => 97
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_should_show_messages_if_only_one_board
|
def test_index_should_show_messages_if_only_one_board
|
||||||
Project.find(1).boards.to_a.slice(1..-1).each(&:destroy)
|
Project.find(1).boards.to_a.slice(1..-1).each(&:destroy)
|
||||||
|
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.boards', 0
|
assert_select 'table.boards', 0
|
||||||
@ -46,7 +52,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :project_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.messages tbody' do
|
assert_select 'table.messages tbody' do
|
||||||
@ -58,7 +67,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
Message.update_all(:sticky => 0)
|
Message.update_all(:sticky => 0)
|
||||||
Message.where({:id => 1}).update_all({:sticky => 1})
|
Message.where({:id => 1}).update_all({:sticky => 1})
|
||||||
|
|
||||||
get :show, :project_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.messages tbody' do
|
assert_select 'table.messages tbody' do
|
||||||
@ -77,7 +89,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
reply = Message.new(:board_id => 1, :subject => 'New reply', :content => 'New reply', :author_id => 2)
|
reply = Message.new(:board_id => 1, :subject => 'New reply', :content => 'New reply', :author_id => 2)
|
||||||
old_topic.children << reply
|
old_topic.children << reply
|
||||||
|
|
||||||
get :show, :project_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.messages tbody' do
|
assert_select 'table.messages tbody' do
|
||||||
@ -88,7 +103,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_with_permission_should_display_the_new_message_form
|
def test_show_with_permission_should_display_the_new_message_form
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :project_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form#message-form' do
|
assert_select 'form#message-form' do
|
||||||
@ -97,20 +115,29 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_atom
|
def test_show_atom
|
||||||
get :show, :project_id => 1, :id => 1, :format => 'atom'
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 1,
|
||||||
|
:format => 'atom'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'feed > entry > title', :text => 'Help: RE: post 2'
|
assert_select 'feed > entry > title', :text => 'Help: RE: post 2'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_not_found
|
def test_show_not_found
|
||||||
get :index, :project_id => 1, :id => 97
|
get :index, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 97
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'board[parent_id]' do
|
assert_select 'select[name=?]', 'board[parent_id]' do
|
||||||
@ -128,7 +155,9 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
Project.find(1).boards.delete_all
|
Project.find(1).boards.delete_all
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'board[parent_id]', 0
|
assert_select 'select[name=?]', 'board[parent_id]', 0
|
||||||
@ -137,7 +166,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Board.count' do
|
assert_difference 'Board.count' do
|
||||||
post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing board creation'}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:board => {
|
||||||
|
:name => 'Testing',
|
||||||
|
:description => 'Testing board creation'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||||
board = Board.order('id DESC').first
|
board = Board.order('id DESC').first
|
||||||
@ -148,7 +183,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_parent
|
def test_create_with_parent
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Board.count' do
|
assert_difference 'Board.count' do
|
||||||
post :create, :project_id => 1, :board => { :name => 'Testing', :description => 'Testing', :parent_id => 2}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:board => {
|
||||||
|
:name => 'Testing',
|
||||||
|
:description => 'Testing',
|
||||||
|
:parent_id => 2
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||||
board = Board.order('id DESC').first
|
board = Board.order('id DESC').first
|
||||||
@ -158,7 +200,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Board.count' do
|
assert_no_difference 'Board.count' do
|
||||||
post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:board => {
|
||||||
|
:name => '',
|
||||||
|
:description => 'Testing board creation'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/
|
assert_select_error /Name cannot be blank/
|
||||||
@ -166,7 +214,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :project_id => 1, :id => 2
|
get :edit, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'board[name]', 'Discussion'
|
assert_select 'input[name=?][value=?]', 'board[name]', 'Discussion'
|
||||||
end
|
end
|
||||||
@ -174,7 +225,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_edit_with_parent
|
def test_edit_with_parent
|
||||||
board = Board.generate!(:project_id => 1, :parent_id => 2)
|
board = Board.generate!(:project_id => 1, :parent_id => 2)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :project_id => 1, :id => board.id
|
get :edit, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => board.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'board[parent_id]' do
|
assert_select 'select[name=?]', 'board[parent_id]' do
|
||||||
@ -185,7 +239,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_update
|
def test_update
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Board.count' do
|
assert_no_difference 'Board.count' do
|
||||||
put :update, :project_id => 1, :id => 2, :board => { :name => 'Testing', :description => 'Testing board update'}
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 2,
|
||||||
|
:board => {
|
||||||
|
:name => 'Testing',
|
||||||
|
:description => 'Testing board update'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||||
assert_equal 'Testing', Board.find(2).name
|
assert_equal 'Testing', Board.find(2).name
|
||||||
@ -193,7 +254,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_position
|
def test_update_position
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :project_id => 1, :id => 2, :board => { :position => 1}
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 2,
|
||||||
|
:board => {
|
||||||
|
:position => 1
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||||
board = Board.find(2)
|
board = Board.find(2)
|
||||||
assert_equal 1, board.position
|
assert_equal 1, board.position
|
||||||
@ -201,7 +268,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'}
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 2,
|
||||||
|
:board => {
|
||||||
|
:name => '',
|
||||||
|
:description => 'Testing board update'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/
|
assert_select_error /Name cannot be blank/
|
||||||
end
|
end
|
||||||
@ -209,7 +283,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Board.count', -1 do
|
assert_difference 'Board.count', -1 do
|
||||||
delete :destroy, :project_id => 1, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||||
assert_nil Board.find_by_id(2)
|
assert_nil Board.find_by_id(2)
|
||||||
|
|||||||
@ -32,14 +32,18 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
|||||||
:enumerations
|
:enumerations
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :project_id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_run_custom_queries
|
def test_show_should_run_custom_queries
|
||||||
@query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
|
@query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
|
||||||
|
|
||||||
get :show, :query_id => @query.id
|
get :show, :params => {
|
||||||
|
:query_id => @query.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => 'Calendar Query'
|
assert_select 'h2', :text => 'Calendar Query'
|
||||||
end
|
end
|
||||||
@ -51,7 +55,10 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_week_number_calculation
|
def test_week_number_calculation
|
||||||
with_settings :start_of_week => 7 do
|
with_settings :start_of_week => 7 do
|
||||||
get :show, :month => '1', :year => '2010'
|
get :show, :params => {
|
||||||
|
:month => '1',
|
||||||
|
:year => '2010'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,7 +75,10 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
with_settings :start_of_week => 1 do
|
with_settings :start_of_week => 1 do
|
||||||
get :show, :month => '1', :year => '2010'
|
get :show, :params => {
|
||||||
|
:month => '1',
|
||||||
|
:year => '2010'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_add_comment
|
def test_add_comment
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :id => 1, :comment => { :comments => 'This is a test comment' }
|
post :create, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:comment => {
|
||||||
|
:comments => 'This is a test comment'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/news/1'
|
assert_redirected_to '/news/1'
|
||||||
|
|
||||||
comment = News.find(1).comments.last
|
comment = News.find(1).comments.last
|
||||||
@ -38,7 +43,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_empty_comment_should_not_be_added
|
def test_empty_comment_should_not_be_added
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Comment.count' do
|
assert_no_difference 'Comment.count' do
|
||||||
post :create, :id => 1, :comment => { :comments => '' }
|
post :create, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:comment => {
|
||||||
|
:comments => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/news/1'
|
assert_redirected_to '/news/1'
|
||||||
end
|
end
|
||||||
@ -48,7 +58,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||||||
News.any_instance.stubs(:commentable?).returns(false)
|
News.any_instance.stubs(:commentable?).returns(false)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Comment.count' do
|
assert_no_difference 'Comment.count' do
|
||||||
post :create, :id => 1, :comment => { :comments => 'This is a test comment' }
|
post :create, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:comment => {
|
||||||
|
:comments => 'This is a test comment'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -56,7 +71,10 @@ class CommentsControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy_comment
|
def test_destroy_comment
|
||||||
comments_count = News.find(1).comments.size
|
comments_count = News.find(1).comments.size
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
delete :destroy, :id => 1, :comment_id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:comment_id => 2
|
||||||
|
}
|
||||||
assert_redirected_to '/news/1'
|
assert_redirected_to '/news/1'
|
||||||
assert_nil Comment.find_by_id(2)
|
assert_nil Comment.find_by_id(2)
|
||||||
assert_equal comments_count - 1, News.find(1).comments.size
|
assert_equal comments_count - 1, News.find(1).comments.size
|
||||||
|
|||||||
@ -35,7 +35,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_one_issue
|
def test_context_menu_one_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit'
|
assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit'
|
||||||
@ -56,7 +58,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_one_issue_by_anonymous
|
def test_context_menu_one_issue_by_anonymous
|
||||||
with_settings :default_language => 'en' do
|
with_settings :default_language => 'en' do
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
|
assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
|
||||||
@ -65,7 +69,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_multiple_issues_of_same_project
|
def test_context_menu_multiple_issues_of_same_project
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1, 2]
|
get :issues, :params => {
|
||||||
|
:ids => [1, 2]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&')
|
ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&')
|
||||||
@ -81,7 +87,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_multiple_issues_of_different_projects
|
def test_context_menu_multiple_issues_of_different_projects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1, 2, 6]
|
get :issues, :params => {
|
||||||
|
:ids => [1, 2, 6]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&')
|
ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&')
|
||||||
@ -98,7 +106,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
field = IssueCustomField.create!(:name => 'List', :field_format => 'list',
|
field = IssueCustomField.create!(:name => 'List', :field_format => 'list',
|
||||||
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'List'
|
assert_select 'a[href="#"]', :text => 'List'
|
||||||
@ -114,7 +124,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
field = IssueCustomField.create!(:name => 'List', :is_required => true, :field_format => 'list',
|
field = IssueCustomField.create!(:name => 'List', :is_required => true, :field_format => 'list',
|
||||||
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1, 2]
|
get :issues, :params => {
|
||||||
|
:ids => [1, 2]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'List'
|
assert_select 'a[href="#"]', :text => 'List'
|
||||||
@ -132,7 +144,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
issue.custom_field_values = {field.id => 'Bar'}
|
issue.custom_field_values = {field.id => 'Bar'}
|
||||||
issue.save!
|
issue.save!
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'List'
|
assert_select 'a[href="#"]', :text => 'List'
|
||||||
@ -147,7 +161,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool',
|
field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool',
|
||||||
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'Bool'
|
assert_select 'a[href="#"]', :text => 'Bool'
|
||||||
@ -164,7 +180,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
field = IssueCustomField.create!(:name => 'User', :field_format => 'user',
|
field = IssueCustomField.create!(:name => 'User', :field_format => 'user',
|
||||||
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'User'
|
assert_select 'a[href="#"]', :text => 'User'
|
||||||
@ -179,7 +197,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
def test_context_menu_should_include_version_custom_fields
|
def test_context_menu_should_include_version_custom_fields
|
||||||
field = IssueCustomField.create!(:name => 'Version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1, 2, 3])
|
field = IssueCustomField.create!(:name => 'Version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'Version'
|
assert_select 'a[href="#"]', :text => 'Version'
|
||||||
@ -197,7 +217,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1)
|
issue = Issue.generate!(:project_id => 1, :tracker_id => 1)
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [issue.id]
|
get :issues, :params => {
|
||||||
|
:ids => [issue.id]
|
||||||
|
}
|
||||||
|
|
||||||
assert_select "li.cf_#{enabled_cf.id}"
|
assert_select "li.cf_#{enabled_cf.id}"
|
||||||
assert_select "li.cf_#{disabled_cf.id}", 0
|
assert_select "li.cf_#{disabled_cf.id}", 0
|
||||||
@ -205,7 +227,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_by_assignable_user_should_include_assigned_to_me_link
|
def test_context_menu_by_assignable_user_should_include_assigned_to_me_link
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1]
|
get :issues, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me /
|
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me /
|
||||||
@ -215,14 +239,18 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
version = Version.create!(:name => 'Shared', :sharing => 'system', :project_id => 1)
|
version = Version.create!(:name => 'Shared', :sharing => 'system', :project_id => 1)
|
||||||
|
|
||||||
get :issues, :ids => [1, 4]
|
get :issues, :params => {
|
||||||
|
:ids => [1, 4]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a', :text => 'eCookbook - Shared'
|
assert_select 'a', :text => 'eCookbook - Shared'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_context_menu_with_issue_that_is_not_visible_should_fail
|
def test_context_menu_with_issue_that_is_not_visible_should_fail
|
||||||
get :issues, :ids => [1, 4] # issue 4 is not visible
|
get :issues, :params => {
|
||||||
|
:ids => [1, 4] # issue 4 is not visible
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -233,7 +261,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_time_entries_context_menu
|
def test_time_entries_context_menu
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :time_entries, :ids => [1, 2]
|
get :time_entries, :params => {
|
||||||
|
:ids => [1, 2]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a:not(.disabled)', :text => 'Edit'
|
assert_select 'a:not(.disabled)', :text => 'Edit'
|
||||||
@ -241,7 +271,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_context_menu_for_one_time_entry
|
def test_context_menu_for_one_time_entry
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :time_entries, :ids => [1]
|
get :time_entries, :params => {
|
||||||
|
:ids => [1]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a:not(.disabled)', :text => 'Edit'
|
assert_select 'a:not(.disabled)', :text => 'Edit'
|
||||||
@ -251,7 +283,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
field = TimeEntryCustomField.generate!(:name => "Field", :field_format => "list", :possible_values => ["foo", "bar"])
|
field = TimeEntryCustomField.generate!(:name => "Field", :field_format => "list", :possible_values => ["foo", "bar"])
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :time_entries, :ids => [1, 2]
|
get :time_entries, :params => {
|
||||||
|
:ids => [1, 2]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "li.cf_#{field.id}" do
|
assert_select "li.cf_#{field.id}" do
|
||||||
@ -271,7 +305,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
Role.find_by_name('Manager').add_permission! :edit_own_time_entries
|
Role.find_by_name('Manager').add_permission! :edit_own_time_entries
|
||||||
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id}
|
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id}
|
||||||
|
|
||||||
get :time_entries, :ids => ids
|
get :time_entries, :params => {
|
||||||
|
:ids => ids
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a:not(.disabled)', :text => 'Edit'
|
assert_select 'a:not(.disabled)', :text => 'Edit'
|
||||||
@ -281,7 +317,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
Role.find_by_name('Manager').remove_permission! :edit_time_entries
|
Role.find_by_name('Manager').remove_permission! :edit_time_entries
|
||||||
|
|
||||||
get :time_entries, :ids => [1, 2]
|
get :time_entries, :params => {
|
||||||
|
:ids => [1, 2]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a.disabled', :text => 'Edit'
|
assert_select 'a.disabled', :text => 'Edit'
|
||||||
|
|||||||
@ -30,7 +30,9 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index, :custom_field_id => @field.id
|
get :index, :params => {
|
||||||
|
:custom_field_id => @field.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'ul#custom_field_enumerations' do
|
assert_select 'ul#custom_field_enumerations' do
|
||||||
@ -40,7 +42,12 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'CustomFieldEnumeration.count' do
|
assert_difference 'CustomFieldEnumeration.count' do
|
||||||
post :create, :custom_field_id => @field.id, :custom_field_enumeration => { :name => 'Baz' }
|
post :create, :params => {
|
||||||
|
:custom_field_id => @field.id,
|
||||||
|
:custom_field_enumeration => {
|
||||||
|
:name => 'Baz'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,15 +60,33 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_xhr
|
def test_create_xhr
|
||||||
assert_difference 'CustomFieldEnumeration.count' do
|
assert_difference 'CustomFieldEnumeration.count' do
|
||||||
xhr :post, :create, :custom_field_id => @field.id, :custom_field_enumeration => { :name => 'Baz' }
|
post :create, :params => {
|
||||||
|
:custom_field_id => @field.id,
|
||||||
|
:custom_field_enumeration => {
|
||||||
|
:name => 'Baz'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_each
|
def test_update_each
|
||||||
put :update_each, :custom_field_id => @field.id, :custom_field_enumerations => {
|
put :update_each, :params => {
|
||||||
@bar.id => {:position => "1", :name => "Baz", :active => "1"},
|
:custom_field_id => @field.id,
|
||||||
@foo.id => {:position => "2", :name => "Foo", :active => "0"}
|
:custom_field_enumerations => {
|
||||||
|
@bar.id => {
|
||||||
|
:position => "1",
|
||||||
|
:name => "Baz",
|
||||||
|
:active => "1"
|
||||||
|
},
|
||||||
|
@foo.id => {
|
||||||
|
:position => "2",
|
||||||
|
:name => "Foo",
|
||||||
|
:active => "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
|
|
||||||
@ -78,7 +103,10 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'CustomFieldEnumeration.count', -1 do
|
assert_difference 'CustomFieldEnumeration.count', -1 do
|
||||||
delete :destroy, :custom_field_id => @field.id, :id => @foo.id
|
delete :destroy, :params => {
|
||||||
|
:custom_field_id => @field.id,
|
||||||
|
:id => @foo.id
|
||||||
|
}
|
||||||
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
assert_redirected_to "/custom_fields/#{@field.id}/enumerations"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,7 +121,10 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
group.save!
|
group.save!
|
||||||
|
|
||||||
assert_no_difference 'CustomFieldEnumeration.count' do
|
assert_no_difference 'CustomFieldEnumeration.count' do
|
||||||
delete :destroy, :custom_field_id => @field.id, :id => @foo.id
|
delete :destroy, :params => {
|
||||||
|
:custom_field_id => @field.id,
|
||||||
|
:id => @foo.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'reassign_to_id'
|
assert_select 'select[name=?]', 'reassign_to_id'
|
||||||
@ -106,7 +137,11 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
group.save!
|
group.save!
|
||||||
|
|
||||||
assert_difference 'CustomFieldEnumeration.count', -1 do
|
assert_difference 'CustomFieldEnumeration.count', -1 do
|
||||||
delete :destroy, :custom_field_id => @field.id, :id => @foo.id, :reassign_to_id => @bar.id
|
delete :destroy, :params => {
|
||||||
|
:custom_field_id => @field.id,
|
||||||
|
:id => @foo.id,
|
||||||
|
:reassign_to_id => @bar.id
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
def test_new_should_work_for_each_customized_class_and_format
|
def test_new_should_work_for_each_customized_class_and_format
|
||||||
custom_field_classes.each do |klass|
|
custom_field_classes.each do |klass|
|
||||||
Redmine::FieldFormat.formats_for_custom_field_class(klass).each do |format|
|
Redmine::FieldFormat.formats_for_custom_field_class(klass).each do |format|
|
||||||
get :new, :type => klass.name, :custom_field => {:field_format => format.name}
|
get :new, :params => {
|
||||||
|
:type => klass.name,
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => format.name
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form#custom_field_form' do
|
assert_select 'form#custom_field_form' do
|
||||||
@ -67,7 +72,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_should_have_string_default_format
|
def test_new_should_have_string_default_format
|
||||||
get :new, :type => 'IssueCustomField'
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'custom_field[field_format]' do
|
assert_select 'select[name=?]', 'custom_field[field_format]' do
|
||||||
@ -76,7 +83,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_issue_custom_field
|
def test_new_issue_custom_field
|
||||||
get :new, :type => 'IssueCustomField'
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form#custom_field_form' do
|
assert_select 'form#custom_field_form' do
|
||||||
@ -91,7 +100,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_time_entry_custom_field_should_not_show_trackers_and_projects
|
def test_new_time_entry_custom_field_should_not_show_trackers_and_projects
|
||||||
get :new, :type => 'TimeEntryCustomField'
|
get :new, :params => {
|
||||||
|
:type => 'TimeEntryCustomField'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form#custom_field_form' do
|
assert_select 'form#custom_field_form' do
|
||||||
@ -101,19 +112,34 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_default_value_should_be_an_input_for_string_custom_field
|
def test_default_value_should_be_an_input_for_string_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'string'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?]', 'custom_field[default_value]'
|
assert_select 'input[name=?]', 'custom_field[default_value]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_value_should_be_a_textarea_for_text_custom_field
|
def test_default_value_should_be_a_textarea_for_text_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'text'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'text'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'textarea[name=?]', 'custom_field[default_value]'
|
assert_select 'textarea[name=?]', 'custom_field[default_value]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_value_should_be_a_checkbox_for_bool_custom_field
|
def test_default_value_should_be_a_checkbox_for_bool_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'bool'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'bool'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'custom_field[default_value]' do
|
assert_select 'select[name=?]', 'custom_field[default_value]' do
|
||||||
assert_select 'option', 3
|
assert_select 'option', 3
|
||||||
@ -121,27 +147,54 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_default_value_should_not_be_present_for_user_custom_field
|
def test_default_value_should_not_be_present_for_user_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'user'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'user'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '[name=?]', 'custom_field[default_value]', 0
|
assert_select '[name=?]', 'custom_field[default_value]', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_setting_full_width_layout_shoul_be_present_only_for_long_text_issue_custom_field
|
def test_setting_full_width_layout_shoul_be_present_only_for_long_text_issue_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'text'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'text'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '[name=?]', 'custom_field[full_width_layout]'
|
assert_select '[name=?]', 'custom_field[full_width_layout]'
|
||||||
|
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'list'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '[name=?]', 'custom_field[full_width_layout]', 0
|
assert_select '[name=?]', 'custom_field[full_width_layout]', 0
|
||||||
|
|
||||||
get :new, :type => 'TimeEntryCustomField', :custom_field => {:field_format => 'text'}
|
get :new, :params => {
|
||||||
|
:type => 'TimeEntryCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'text'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '[name=?]', 'custom_field[full_width_layout]', 0
|
assert_select '[name=?]', 'custom_field[full_width_layout]', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_js
|
def test_new_js
|
||||||
xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js'
|
get :new, :params => {
|
||||||
|
:type => 'IssueCustomField',
|
||||||
|
:custom_field => {
|
||||||
|
:field_format => 'list'
|
||||||
|
},
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
|
|
||||||
@ -149,7 +202,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_with_invalid_custom_field_class_should_render_select_type
|
def test_new_with_invalid_custom_field_class_should_render_select_type
|
||||||
get :new, :type => 'UnknownCustomField'
|
get :new, :params => {
|
||||||
|
:type => 'UnknownCustomField'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[type=radio][name=type]'
|
assert_select 'input[type=radio][name=type]'
|
||||||
@ -157,8 +212,10 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_list_custom_field
|
def test_create_list_custom_field
|
||||||
field = new_record(IssueCustomField) do
|
field = new_record(IssueCustomField) do
|
||||||
post :create, :type => "IssueCustomField",
|
post :create, :params => {
|
||||||
:custom_field => {:name => "test_post_new_list",
|
:type => "IssueCustomField",
|
||||||
|
:custom_field => {
|
||||||
|
:name => "test_post_new_list",
|
||||||
:default_value => "",
|
:default_value => "",
|
||||||
:min_length => "0",
|
:min_length => "0",
|
||||||
:searchable => "0",
|
:searchable => "0",
|
||||||
@ -169,7 +226,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
:is_filter => "0",
|
:is_filter => "0",
|
||||||
:is_required =>"0",
|
:is_required =>"0",
|
||||||
:field_format => "list",
|
:field_format => "list",
|
||||||
:tracker_ids => ["1", ""]}
|
:tracker_ids => ["1", ""]
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to "/custom_fields/#{field.id}/edit"
|
assert_redirected_to "/custom_fields/#{field.id}/edit"
|
||||||
assert_equal "test_post_new_list", field.name
|
assert_equal "test_post_new_list", field.name
|
||||||
@ -179,8 +238,15 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_project_ids
|
def test_create_with_project_ids
|
||||||
assert_difference 'CustomField.count' do
|
assert_difference 'CustomField.count' do
|
||||||
post :create, :type => "IssueCustomField", :custom_field => {
|
post :create, :params => {
|
||||||
:name => "foo", :field_format => "string", :is_for_all => "0", :project_ids => ["1", "3", ""]
|
:type => "IssueCustomField",
|
||||||
|
:custom_field => {
|
||||||
|
:name => "foo",
|
||||||
|
:field_format => "string",
|
||||||
|
:is_for_all => "0",
|
||||||
|
:project_ids => ["1", "3", ""]
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
@ -190,7 +256,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'CustomField.count' do
|
assert_no_difference 'CustomField.count' do
|
||||||
post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
|
post :create, :params => {
|
||||||
|
:type => "IssueCustomField",
|
||||||
|
:custom_field => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
@ -198,25 +269,38 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_without_type_should_render_select_type
|
def test_create_without_type_should_render_select_type
|
||||||
assert_no_difference 'CustomField.count' do
|
assert_no_difference 'CustomField.count' do
|
||||||
post :create, :custom_field => {:name => ''}
|
post :create, :params => {
|
||||||
|
:custom_field => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[type=radio][name=type]'
|
assert_select 'input[type=radio][name=type]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
|
assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_invalid_custom_field_should_render_404
|
def test_edit_invalid_custom_field_should_render_404
|
||||||
get :edit, :id => 99
|
get :edit, :params => {
|
||||||
|
:id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
put :update, :id => 1, :custom_field => {:name => 'New name'}
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:custom_field => {
|
||||||
|
:name => 'New name'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/custom_fields/1/edit'
|
assert_redirected_to '/custom_fields/1/edit'
|
||||||
|
|
||||||
field = CustomField.find(1)
|
field = CustomField.find(1)
|
||||||
@ -224,7 +308,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
put :update, :id => 1, :custom_field => {:name => ''}
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:custom_field => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
end
|
end
|
||||||
@ -235,7 +324,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
assert_difference 'CustomField.count', -1 do
|
assert_difference 'CustomField.count', -1 do
|
||||||
assert_difference 'CustomValue.count', - custom_values_count do
|
assert_difference 'CustomValue.count', - custom_values_count do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,9 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||||||
e = Enumeration.find_by_name('Technical documentation')
|
e = Enumeration.find_by_name('Technical documentation')
|
||||||
e.update_attributes(:is_default => true)
|
e.update_attributes(:is_default => true)
|
||||||
|
|
||||||
get :index, :project_id => 'ecookbook'
|
get :index, :params => {
|
||||||
|
:project_id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# Default category selected in the new document form
|
# Default category selected in the new document form
|
||||||
@ -44,19 +46,28 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_grouped_by_date
|
def test_index_grouped_by_date
|
||||||
get :index, :project_id => 'ecookbook', :sort_by => 'date'
|
get :index, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:sort_by => 'date'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h3', :text => '2007-02-12'
|
assert_select 'h3', :text => '2007-02-12'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_grouped_by_title
|
def test_index_grouped_by_title
|
||||||
get :index, :project_id => 'ecookbook', :sort_by => 'title'
|
get :index, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:sort_by => 'title'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h3', :text => 'T'
|
assert_select 'h3', :text => 'T'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_grouped_by_author
|
def test_index_grouped_by_author
|
||||||
get :index, :project_id => 'ecookbook', :sort_by => 'author'
|
get :index, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:sort_by => 'author'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h3', :text => 'John Smith'
|
assert_select 'h3', :text => 'John Smith'
|
||||||
end
|
end
|
||||||
@ -70,7 +81,9 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula
|
|||||||
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
LOREM
|
LOREM
|
||||||
|
|
||||||
get :index, :project_id => 'ecookbook'
|
get :index, :params => {
|
||||||
|
:project_id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# should only truncate on new lines to avoid breaking wiki formatting
|
# should only truncate on new lines to avoid breaking wiki formatting
|
||||||
@ -79,13 +92,17 @@ LOREM
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,11 +112,18 @@ LOREM
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
|
|
||||||
with_settings :notified_events => %w(document_added) do
|
with_settings :notified_events => %w(document_added) do
|
||||||
post :create, :project_id => 'ecookbook',
|
post :create, :params => {
|
||||||
:document => { :title => 'DocumentsControllerTest#test_post_new',
|
:project_id => 'ecookbook',
|
||||||
|
:document => {
|
||||||
|
:title => 'DocumentsControllerTest#test_post_new',
|
||||||
:description => 'This is a new document',
|
:description => 'This is a new document',
|
||||||
:category_id => 2},
|
:category_id => 2
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
},
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/documents'
|
assert_redirected_to '/projects/ecookbook/documents'
|
||||||
|
|
||||||
@ -114,7 +138,12 @@ LOREM
|
|||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Document.count' do
|
assert_no_difference 'Document.count' do
|
||||||
post :create, :project_id => 'ecookbook', :document => { :title => ''}
|
post :create, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:document => {
|
||||||
|
:title => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /title cannot be blank/i
|
assert_select_error /title cannot be blank/i
|
||||||
@ -125,11 +154,14 @@ LOREM
|
|||||||
category2 = Enumeration.find_by_name('User documentation')
|
category2 = Enumeration.find_by_name('User documentation')
|
||||||
category2.update_attributes(:is_default => true)
|
category2.update_attributes(:is_default => true)
|
||||||
category1 = Enumeration.find_by_name('Uncategorized')
|
category1 = Enumeration.find_by_name('Uncategorized')
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:document => { :title => 'no default',
|
:document => {
|
||||||
|
:title => 'no default',
|
||||||
:description => 'This is a new document',
|
:description => 'This is a new document',
|
||||||
:category_id => category1.id }
|
:category_id => category1.id
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/documents'
|
assert_redirected_to '/projects/ecookbook/documents'
|
||||||
doc = Document.find_by_title('no default')
|
doc = Document.find_by_title('no default')
|
||||||
assert_not_nil doc
|
assert_not_nil doc
|
||||||
@ -139,13 +171,20 @@ LOREM
|
|||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :id => 1, :document => {:title => 'test_update'}
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:document => {
|
||||||
|
:title => 'test_update'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/documents/1'
|
assert_redirected_to '/documents/1'
|
||||||
document = Document.find(1)
|
document = Document.find(1)
|
||||||
assert_equal 'test_update', document.title
|
assert_equal 'test_update', document.title
|
||||||
@ -153,7 +192,12 @@ LOREM
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :id => 1, :document => {:title => ''}
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:document => {
|
||||||
|
:title => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /title cannot be blank/i
|
assert_select_error /title cannot be blank/i
|
||||||
end
|
end
|
||||||
@ -161,7 +205,9 @@ LOREM
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Document.count', -1 do
|
assert_difference 'Document.count', -1 do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/documents'
|
assert_redirected_to '/projects/ecookbook/documents'
|
||||||
assert_nil Document.find_by_id(1)
|
assert_nil Document.find_by_id(1)
|
||||||
@ -170,8 +216,13 @@ LOREM
|
|||||||
def test_add_attachment
|
def test_add_attachment
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
post :add_attachment, :id => 1,
|
post :add_attachment, :params => {
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
:id => 1,
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
attachment = Attachment.order('id DESC').first
|
attachment = Attachment.order('id DESC').first
|
||||||
assert_equal Document.find(1), attachment.container
|
assert_equal Document.find(1), attachment.container
|
||||||
|
|||||||
@ -26,7 +26,9 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_index_with_no_additional_emails
|
def test_index_with_no_additional_emails
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,7 +36,9 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
get :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '.email', :text => 'another@somenet.foo'
|
assert_select '.email', :text => 'another@somenet.foo'
|
||||||
end
|
end
|
||||||
@ -43,27 +47,39 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
xhr :get, :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'another@somenet.foo', response.body
|
assert_include 'another@somenet.foo', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_by_admin_should_be_allowed
|
def test_index_by_admin_should_be_allowed
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_by_another_user_should_be_denied
|
def test_index_by_another_user_should_be_denied
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
get :index, :user_id => 2
|
get :index, :params => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'EmailAddress.count' do
|
assert_difference 'EmailAddress.count' do
|
||||||
post :create, :user_id => 2, :email_address => {:address => 'another@somenet.foo'}
|
post :create, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:email_address => {
|
||||||
|
:address => 'another@somenet.foo'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_redirected_to '/users/2/email_addresses'
|
assert_redirected_to '/users/2/email_addresses'
|
||||||
end
|
end
|
||||||
@ -75,7 +91,13 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_as_js
|
def test_create_as_js
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'EmailAddress.count' do
|
assert_difference 'EmailAddress.count' do
|
||||||
xhr :post, :create, :user_id => 2, :email_address => {:address => 'another@somenet.foo'}
|
post :create, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:email_address => {
|
||||||
|
:address => 'another@somenet.foo'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -83,7 +105,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'EmailAddress.count' do
|
assert_no_difference 'EmailAddress.count' do
|
||||||
post :create, :user_id => 2, :email_address => {:address => 'invalid'}
|
post :create, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:email_address => {
|
||||||
|
:address => 'invalid'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /email is invalid/i
|
assert_select_error /email is invalid/i
|
||||||
end
|
end
|
||||||
@ -92,7 +119,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_should_send_security_notification
|
def test_create_should_send_security_notification
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
post :create, :user_id => 2, :email_address => {:address => 'something@example.fr'}
|
post :create, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:email_address => {
|
||||||
|
:address => 'something@example.fr'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||||
assert_mail_body_match '0.0.0.0', mail
|
assert_mail_body_match '0.0.0.0', mail
|
||||||
@ -109,7 +141,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
put :update, :user_id => 2, :id => email.id, :notify => '0'
|
put :update, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id,
|
||||||
|
:notify => '0'
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
|
|
||||||
assert_equal false, email.reload.notify
|
assert_equal false, email.reload.notify
|
||||||
@ -119,7 +155,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
xhr :put, :update, :user_id => 2, :id => email.id, :notify => '0'
|
put :update, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id,
|
||||||
|
:notify => '0'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 200
|
assert_response 200
|
||||||
|
|
||||||
assert_equal false, email.reload.notify
|
assert_equal false, email.reload.notify
|
||||||
@ -130,7 +171,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
xhr :put, :update, :user_id => 2, :id => email.id, :notify => '0'
|
put :update, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id,
|
||||||
|
:notify => '0'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
|
||||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||||
assert_mail_body_match I18n.t(:mail_body_security_notification_notify_disabled, value: 'another@somenet.foo'), mail
|
assert_mail_body_match I18n.t(:mail_body_security_notification_notify_disabled, value: 'another@somenet.foo'), mail
|
||||||
@ -145,7 +191,10 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
assert_difference 'EmailAddress.count', -1 do
|
assert_difference 'EmailAddress.count', -1 do
|
||||||
delete :destroy, :user_id => 2, :id => email.id
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_redirected_to '/users/2/email_addresses'
|
assert_redirected_to '/users/2/email_addresses'
|
||||||
end
|
end
|
||||||
@ -156,7 +205,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
assert_difference 'EmailAddress.count', -1 do
|
assert_difference 'EmailAddress.count', -1 do
|
||||||
xhr :delete, :destroy, :user_id => 2, :id => email.id
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -165,7 +218,10 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_no_difference 'EmailAddress.count' do
|
assert_no_difference 'EmailAddress.count' do
|
||||||
delete :destroy, :user_id => 2, :id => User.find(2).email_address.id
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => User.find(2).email_address.id
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -175,7 +231,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
|||||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||||
|
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
xhr :delete, :destroy, :user_id => 2, :id => email.id
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => email.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
|
||||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||||
assert_mail_body_match I18n.t(:mail_body_security_notification_remove, field: I18n.t(:field_mail), value: 'another@somenet.foo'), mail
|
assert_mail_body_match I18n.t(:mail_body_security_notification_remove, field: I18n.t(:field_mail), value: 'another@somenet.foo'), mail
|
||||||
|
|||||||
@ -37,7 +37,9 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
get :new, :type => 'IssuePriority'
|
get :new, :params => {
|
||||||
|
:type => 'IssuePriority'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
|
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
|
||||||
@ -45,13 +47,20 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_with_invalid_type_should_respond_with_404
|
def test_new_with_invalid_type_should_respond_with_404
|
||||||
get :new, :type => 'UnknownType'
|
get :new, :params => {
|
||||||
|
:type => 'UnknownType'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'IssuePriority.count' do
|
assert_difference 'IssuePriority.count' do
|
||||||
post :create, :enumeration => {:type => 'IssuePriority', :name => 'Lowest'}
|
post :create, :params => {
|
||||||
|
:enumeration => {
|
||||||
|
:type => 'IssuePriority',
|
||||||
|
:name => 'Lowest'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/enumerations'
|
assert_redirected_to '/enumerations'
|
||||||
e = IssuePriority.find_by_name('Lowest')
|
e = IssuePriority.find_by_name('Lowest')
|
||||||
@ -60,26 +69,41 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'IssuePriority.count' do
|
assert_no_difference 'IssuePriority.count' do
|
||||||
post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
|
post :create, :params => {
|
||||||
|
:enumeration => {
|
||||||
|
:type => 'IssuePriority',
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 6
|
get :edit, :params => {
|
||||||
|
:id => 6
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
|
assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_invalid_should_respond_with_404
|
def test_edit_invalid_should_respond_with_404
|
||||||
get :edit, :id => 999
|
get :edit, :params => {
|
||||||
|
:id => 999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
assert_no_difference 'IssuePriority.count' do
|
assert_no_difference 'IssuePriority.count' do
|
||||||
put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => 'New name'}
|
put :update, :params => {
|
||||||
|
:id => 6,
|
||||||
|
:enumeration => {
|
||||||
|
:type => 'IssuePriority',
|
||||||
|
:name => 'New name'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/enumerations'
|
assert_redirected_to '/enumerations'
|
||||||
e = IssuePriority.find(6)
|
e = IssuePriority.find(6)
|
||||||
@ -88,7 +112,13 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
assert_no_difference 'IssuePriority.count' do
|
assert_no_difference 'IssuePriority.count' do
|
||||||
put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
|
put :update, :params => {
|
||||||
|
:id => 6,
|
||||||
|
:enumeration => {
|
||||||
|
:type => 'IssuePriority',
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
@ -96,7 +126,9 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_enumeration_not_in_use
|
def test_destroy_enumeration_not_in_use
|
||||||
assert_difference 'IssuePriority.count', -1 do
|
assert_difference 'IssuePriority.count', -1 do
|
||||||
delete :destroy, :id => 7
|
delete :destroy, :params => {
|
||||||
|
:id => 7
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||||
assert_nil Enumeration.find_by_id(7)
|
assert_nil Enumeration.find_by_id(7)
|
||||||
@ -104,7 +136,9 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_enumeration_in_use
|
def test_destroy_enumeration_in_use
|
||||||
assert_no_difference 'IssuePriority.count' do
|
assert_no_difference 'IssuePriority.count' do
|
||||||
delete :destroy, :id => 4
|
delete :destroy, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
@ -117,7 +151,10 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy_enumeration_in_use_with_reassignment
|
def test_destroy_enumeration_in_use_with_reassignment
|
||||||
issue = Issue.where(:priority_id => 4).first
|
issue = Issue.where(:priority_id => 4).first
|
||||||
assert_difference 'IssuePriority.count', -1 do
|
assert_difference 'IssuePriority.count', -1 do
|
||||||
delete :destroy, :id => 4, :reassign_to_id => 6
|
delete :destroy, :params => {
|
||||||
|
:id => 4,
|
||||||
|
:reassign_to_id => 6
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||||
assert_nil Enumeration.find_by_id(4)
|
assert_nil Enumeration.find_by_id(4)
|
||||||
@ -127,7 +164,10 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_enumeration_in_use_with_blank_reassignment
|
def test_destroy_enumeration_in_use_with_blank_reassignment
|
||||||
assert_no_difference 'IssuePriority.count' do
|
assert_no_difference 'IssuePriority.count' do
|
||||||
delete :destroy, :id => 4, :reassign_to_id => ''
|
delete :destroy, :params => {
|
||||||
|
:id => 4,
|
||||||
|
:reassign_to_id => ''
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,7 +37,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# file attached to the project
|
# file attached to the project
|
||||||
@ -49,7 +51,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'version_id'
|
assert_select 'select[name=?]', 'version_id'
|
||||||
@ -58,7 +62,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
def test_new_without_versions
|
def test_new_without_versions
|
||||||
Version.delete_all
|
Version.delete_all
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'version_id', 0
|
assert_select 'select[name=?]', 'version_id', 0
|
||||||
@ -71,8 +77,14 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
with_settings :notified_events => %w(file_added) do
|
with_settings :notified_events => %w(file_added) do
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
post :create, :project_id => 1, :version_id => '',
|
post :create, :params => {
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
:project_id => 1,
|
||||||
|
:version_id => '',
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -92,8 +104,14 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
post :create, :project_id => 1, :version_id => '2',
|
post :create, :params => {
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
:project_id => 1,
|
||||||
|
:version_id => '2',
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/files'
|
assert_redirected_to '/projects/ecookbook/files'
|
||||||
@ -107,7 +125,10 @@ class FilesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_no_difference 'Attachment.count' do
|
assert_no_difference 'Attachment.count' do
|
||||||
post :create, :project_id => 1, :version_id => ''
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:version_id => ''
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
assert_select 'div.error', 'File is invalid'
|
assert_select 'div.error', 'File is invalid'
|
||||||
|
|||||||
@ -30,7 +30,9 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||||||
def test_gantt_should_work
|
def test_gantt_should_work
|
||||||
i2 = Issue.find(2)
|
i2 = Issue.find(2)
|
||||||
i2.update_attribute(:due_date, 1.month.from_now)
|
i2.update_attribute(:due_date, 1.month.from_now)
|
||||||
get :show, :project_id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# Issue with start and due dates
|
# Issue with start and due dates
|
||||||
@ -43,27 +45,37 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_at_minimal_zoom
|
def test_gantt_at_minimal_zoom
|
||||||
get :show, :project_id => 1, :zoom => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:zoom => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[type=hidden][name=zoom][value=?]', '1'
|
assert_select 'input[type=hidden][name=zoom][value=?]', '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_at_maximal_zoom
|
def test_gantt_at_maximal_zoom
|
||||||
get :show, :project_id => 1, :zoom => 4
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:zoom => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[type=hidden][name=zoom][value=?]', '4'
|
assert_select 'input[type=hidden][name=zoom][value=?]', '4'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_should_work_without_issue_due_dates
|
def test_gantt_should_work_without_issue_due_dates
|
||||||
Issue.update_all("due_date = NULL")
|
Issue.update_all("due_date = NULL")
|
||||||
get :show, :project_id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_should_work_without_issue_and_version_due_dates
|
def test_gantt_should_work_without_issue_and_version_due_dates
|
||||||
Issue.update_all("due_date = NULL")
|
Issue.update_all("due_date = NULL")
|
||||||
Version.update_all("effective_date = NULL")
|
Version.update_all("effective_date = NULL")
|
||||||
get :show, :project_id => 1
|
get :show, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,14 +109,19 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_should_export_to_pdf
|
def test_gantt_should_export_to_pdf
|
||||||
get :show, :project_id => 1, :format => 'pdf'
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:format => 'pdf'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
assert @response.body.starts_with?('%PDF')
|
assert @response.body.starts_with?('%PDF')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gantt_should_export_to_pdf_cross_project
|
def test_gantt_should_export_to_pdf_cross_project
|
||||||
get :show, :format => 'pdf'
|
get :show, :params => {
|
||||||
|
:format => 'pdf'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/pdf', @response.content_type
|
assert_equal 'application/pdf', @response.content_type
|
||||||
assert @response.body.starts_with?('%PDF')
|
assert @response.body.starts_with?('%PDF')
|
||||||
@ -112,7 +129,10 @@ class GanttsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
if Object.const_defined?(:Magick)
|
if Object.const_defined?(:Magick)
|
||||||
def test_gantt_should_export_to_png
|
def test_gantt_should_export_to_png
|
||||||
get :show, :project_id => 1, :format => 'png'
|
get :show, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:format => 'png'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'image/png', @response.content_type
|
assert_equal 'image/png', @response.content_type
|
||||||
end
|
end
|
||||||
|
|||||||
@ -39,19 +39,25 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
def test_index_with_name_filter
|
def test_index_with_name_filter
|
||||||
Group.generate!(:name => "Clients")
|
Group.generate!(:name => "Clients")
|
||||||
|
|
||||||
get :index, :name => "cli"
|
get :index, :params => {
|
||||||
|
:name => "cli"
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.groups tbody tr', 1
|
assert_select 'table.groups tbody tr', 1
|
||||||
assert_select 'table.groups tbody td.name', :text => 'Clients'
|
assert_select 'table.groups tbody td.name', :text => 'Clients'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :id => 10
|
get :show, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_invalid_should_return_404
|
def test_show_invalid_should_return_404
|
||||||
get :show, :id => 99
|
get :show, :params => {
|
||||||
|
:id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,7 +69,11 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'Group.count' do
|
assert_difference 'Group.count' do
|
||||||
post :create, :group => {:name => 'New group'}
|
post :create, :params => {
|
||||||
|
:group => {
|
||||||
|
:name => 'New group'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/groups'
|
assert_redirected_to '/groups'
|
||||||
group = Group.order('id DESC').first
|
group = Group.order('id DESC').first
|
||||||
@ -73,7 +83,12 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_and_continue
|
def test_create_and_continue
|
||||||
assert_difference 'Group.count' do
|
assert_difference 'Group.count' do
|
||||||
post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
|
post :create, :params => {
|
||||||
|
:group => {
|
||||||
|
:name => 'New group'
|
||||||
|
},
|
||||||
|
:continue => 'Create and continue'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/groups/new'
|
assert_redirected_to '/groups/new'
|
||||||
group = Group.order('id DESC').first
|
group = Group.order('id DESC').first
|
||||||
@ -82,14 +97,20 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'Group.count' do
|
assert_no_difference 'Group.count' do
|
||||||
post :create, :group => {:name => ''}
|
post :create, :params => {
|
||||||
|
:group => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/i
|
assert_select_error /Name cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 10
|
get :edit, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'div#tab-content-users'
|
assert_select 'div#tab-content-users'
|
||||||
@ -100,46 +121,70 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
new_name = 'New name'
|
new_name = 'New name'
|
||||||
put :update, :id => 10, :group => {:name => new_name}
|
put :update, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:group => {
|
||||||
|
:name => new_name
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/groups'
|
assert_redirected_to '/groups'
|
||||||
group = Group.find(10)
|
group = Group.find(10)
|
||||||
assert_equal new_name, group.name
|
assert_equal new_name, group.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
put :update, :id => 10, :group => {:name => ''}
|
put :update, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:group => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/i
|
assert_select_error /Name cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'Group.count', -1 do
|
assert_difference 'Group.count', -1 do
|
||||||
post :destroy, :id => 10
|
post :destroy, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/groups'
|
assert_redirected_to '/groups'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_users
|
def test_new_users
|
||||||
get :new_users, :id => 10
|
get :new_users, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?]', 'user_search'
|
assert_select 'input[name=?]', 'user_search'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_new_users
|
def test_xhr_new_users
|
||||||
xhr :get, :new_users, :id => 10
|
get :new_users, :params => {
|
||||||
|
:id => 10
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_users
|
def test_add_users
|
||||||
assert_difference 'Group.find(10).users.count', 2 do
|
assert_difference 'Group.find(10).users.count', 2 do
|
||||||
post :add_users, :id => 10, :user_ids => ['2', '3']
|
post :add_users, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:user_ids => ['2', '3']
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_add_users
|
def test_xhr_add_users
|
||||||
assert_difference 'Group.find(10).users.count', 2 do
|
assert_difference 'Group.find(10).users.count', 2 do
|
||||||
xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
|
post :add_users, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:user_ids => ['2', '3']
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -148,20 +193,32 @@ class GroupsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_remove_user
|
def test_remove_user
|
||||||
assert_difference 'Group.find(10).users.count', -1 do
|
assert_difference 'Group.find(10).users.count', -1 do
|
||||||
delete :remove_user, :id => 10, :user_id => '8'
|
delete :remove_user, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:user_id => '8'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_remove_user
|
def test_xhr_remove_user
|
||||||
assert_difference 'Group.find(10).users.count', -1 do
|
assert_difference 'Group.find(10).users.count', -1 do
|
||||||
xhr :delete, :remove_user, :id => 10, :user_id => '8'
|
delete :remove_user, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:user_id => '8'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_autocomplete_for_user
|
def test_autocomplete_for_user
|
||||||
xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
|
get :autocomplete_for_user, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:q => 'smi',
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'John Smith', response.body
|
assert_include 'John Smith', response.body
|
||||||
end
|
end
|
||||||
|
|||||||
@ -49,7 +49,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_should_save_the_file
|
def test_create_should_save_the_file
|
||||||
import = new_record(Import) do
|
import = new_record(Import) do
|
||||||
post :create, :file => uploaded_test_file('import_issues.csv', 'text/csv')
|
post :create, :params => {
|
||||||
|
:file => uploaded_test_file('import_issues.csv', 'text/csv')
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_equal 2, import.user_id
|
assert_equal 2, import.user_id
|
||||||
@ -59,7 +61,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_get_settings_should_display_settings_form
|
def test_get_settings_should_display_settings_form
|
||||||
import = generate_import
|
import = generate_import
|
||||||
get :settings, :id => import.to_param
|
get :settings, :params => {
|
||||||
|
:id => import.to_param
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'import_settings[separator]'
|
assert_select 'select[name=?]', 'import_settings[separator]'
|
||||||
assert_select 'select[name=?]', 'import_settings[wrapper]'
|
assert_select 'select[name=?]', 'import_settings[wrapper]'
|
||||||
@ -70,8 +74,15 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_settings_should_update_settings
|
def test_post_settings_should_update_settings
|
||||||
import = generate_import
|
import = generate_import
|
||||||
|
|
||||||
post :settings, :id => import.to_param,
|
post :settings, :params => {
|
||||||
:import_settings => {:separator => ":", :wrapper => "|", :encoding => "UTF-8", :date_format => '%m/%d/%Y'}
|
:id => import.to_param,
|
||||||
|
:import_settings => {
|
||||||
|
:separator => ":",
|
||||||
|
:wrapper => "|",
|
||||||
|
:encoding => "UTF-8",
|
||||||
|
:date_format => '%m/%d/%Y'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to "/imports/#{import.to_param}/mapping"
|
assert_redirected_to "/imports/#{import.to_param}/mapping"
|
||||||
|
|
||||||
import.reload
|
import.reload
|
||||||
@ -84,8 +95,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_settings_should_update_total_items_count
|
def test_post_settings_should_update_total_items_count
|
||||||
import = generate_import('import_iso8859-1.csv')
|
import = generate_import('import_iso8859-1.csv')
|
||||||
|
|
||||||
post :settings, :id => import.to_param,
|
post :settings, :params => {
|
||||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "ISO-8859-1"}
|
:id => import.to_param,
|
||||||
|
:import_settings => {
|
||||||
|
:separator => ";",
|
||||||
|
:wrapper => '"',
|
||||||
|
:encoding => "ISO-8859-1"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
import.reload
|
import.reload
|
||||||
assert_equal 2, import.total_items
|
assert_equal 2, import.total_items
|
||||||
@ -94,8 +111,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_settings_with_wrong_encoding_should_display_error
|
def test_post_settings_with_wrong_encoding_should_display_error
|
||||||
import = generate_import('import_iso8859-1.csv')
|
import = generate_import('import_iso8859-1.csv')
|
||||||
|
|
||||||
post :settings, :id => import.to_param,
|
post :settings, :params => {
|
||||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "UTF-8"}
|
:id => import.to_param,
|
||||||
|
:import_settings => {
|
||||||
|
:separator => ";",
|
||||||
|
:wrapper => '"',
|
||||||
|
:encoding => "UTF-8"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 200
|
assert_response 200
|
||||||
import.reload
|
import.reload
|
||||||
assert_nil import.total_items
|
assert_nil import.total_items
|
||||||
@ -105,8 +128,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_settings_with_invalid_encoding_should_display_error
|
def test_post_settings_with_invalid_encoding_should_display_error
|
||||||
import = generate_import('invalid-Shift_JIS.csv')
|
import = generate_import('invalid-Shift_JIS.csv')
|
||||||
|
|
||||||
post :settings, :id => import.to_param,
|
post :settings, :params => {
|
||||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "Shift_JIS"}
|
:id => import.to_param,
|
||||||
|
:import_settings => {
|
||||||
|
:separator => ";",
|
||||||
|
:wrapper => '"',
|
||||||
|
:encoding => "Shift_JIS"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 200
|
assert_response 200
|
||||||
import.reload
|
import.reload
|
||||||
assert_nil import.total_items
|
assert_nil import.total_items
|
||||||
@ -118,7 +147,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
get :mapping, :id => import.to_param
|
get :mapping, :params => {
|
||||||
|
:id => import.to_param
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
|
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
|
||||||
@ -135,8 +166,15 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_mapping_should_update_mapping
|
def test_post_mapping_should_update_mapping
|
||||||
import = generate_import('import_iso8859-1.csv')
|
import = generate_import('import_iso8859-1.csv')
|
||||||
|
|
||||||
post :mapping, :id => import.to_param,
|
post :mapping, :params => {
|
||||||
:import_settings => {:mapping => {:project_id => '1', :tracker_id => '2', :subject => '0'}}
|
:id => import.to_param,
|
||||||
|
:import_settings => {
|
||||||
|
:mapping => {
|
||||||
|
:project_id => '1',
|
||||||
|
:tracker_id => '2',
|
||||||
|
:subject => '0'}
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to "/imports/#{import.to_param}/run"
|
assert_redirected_to "/imports/#{import.to_param}/run"
|
||||||
import.reload
|
import.reload
|
||||||
mapping = import.settings['mapping']
|
mapping = import.settings['mapping']
|
||||||
@ -149,7 +187,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_run
|
def test_get_run
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
|
|
||||||
get :run, :id => import
|
get :run, :params => {
|
||||||
|
:id => import
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '#import-progress'
|
assert_select '#import-progress'
|
||||||
end
|
end
|
||||||
@ -158,7 +198,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
|
|
||||||
assert_difference 'Issue.count', 3 do
|
assert_difference 'Issue.count', 3 do
|
||||||
post :run, :id => import
|
post :run, :params => {
|
||||||
|
:id => import
|
||||||
|
}
|
||||||
assert_redirected_to "/imports/#{import.to_param}"
|
assert_redirected_to "/imports/#{import.to_param}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -175,12 +217,16 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
|
|
||||||
assert_difference 'Issue.count', 2 do
|
assert_difference 'Issue.count', 2 do
|
||||||
post :run, :id => import
|
post :run, :params => {
|
||||||
|
:id => import
|
||||||
|
}
|
||||||
assert_redirected_to "/imports/#{import.to_param}/run"
|
assert_redirected_to "/imports/#{import.to_param}/run"
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_difference 'Issue.count', 1 do
|
assert_difference 'Issue.count', 1 do
|
||||||
post :run, :id => import
|
post :run, :params => {
|
||||||
|
:id => import
|
||||||
|
}
|
||||||
assert_redirected_to "/imports/#{import.to_param}"
|
assert_redirected_to "/imports/#{import.to_param}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,7 +239,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
import.run
|
import.run
|
||||||
assert_equal 0, import.unsaved_items.count
|
assert_equal 0, import.unsaved_items.count
|
||||||
|
|
||||||
get :show, :id => import.to_param
|
get :show, :params => {
|
||||||
|
:id => import.to_param
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'ul#saved-items'
|
assert_select 'ul#saved-items'
|
||||||
@ -207,7 +255,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
import.run
|
import.run
|
||||||
assert_not_equal 0, import.unsaved_items.count
|
assert_not_equal 0, import.unsaved_items.count
|
||||||
|
|
||||||
get :show, :id => import.to_param
|
get :show, :params => {
|
||||||
|
:id => import.to_param
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table#unsaved-items'
|
assert_select 'table#unsaved-items'
|
||||||
|
|||||||
@ -28,14 +28,19 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
get :new, :project_id => '1'
|
get :new, :params => {
|
||||||
|
:project_id => '1'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?]', 'issue_category[name]'
|
assert_select 'input[name=?]', 'issue_category[name]'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_from_issue_form
|
def test_new_from_issue_form
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
xhr :get, :new, :project_id => '1'
|
get :new, :params => {
|
||||||
|
:project_id => '1'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
@ -44,7 +49,12 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
assert_difference 'IssueCategory.count' do
|
assert_difference 'IssueCategory.count' do
|
||||||
post :create, :project_id => '1', :issue_category => {:name => 'New category'}
|
post :create, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:issue_category => {
|
||||||
|
:name => 'New category'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||||
category = IssueCategory.find_by_name('New category')
|
category = IssueCategory.find_by_name('New category')
|
||||||
@ -54,7 +64,12 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_failure
|
def test_create_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :project_id => '1', :issue_category => {:name => ''}
|
post :create, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:issue_category => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/i
|
assert_select_error /Name cannot be blank/i
|
||||||
end
|
end
|
||||||
@ -62,7 +77,13 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_from_issue_form
|
def test_create_from_issue_form
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
assert_difference 'IssueCategory.count' do
|
assert_difference 'IssueCategory.count' do
|
||||||
xhr :post, :create, :project_id => '1', :issue_category => {:name => 'New category'}
|
post :create, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:issue_category => {
|
||||||
|
:name => 'New category'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
end
|
end
|
||||||
category = IssueCategory.order('id DESC').first
|
category = IssueCategory.order('id DESC').first
|
||||||
assert_equal 'New category', category.name
|
assert_equal 'New category', category.name
|
||||||
@ -74,7 +95,13 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_from_issue_form_with_failure
|
def test_create_from_issue_form_with_failure
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
assert_no_difference 'IssueCategory.count' do
|
assert_no_difference 'IssueCategory.count' do
|
||||||
xhr :post, :create, :project_id => '1', :issue_category => {:name => ''}
|
post :create, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:issue_category => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -84,38 +111,59 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 2
|
get :edit, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes'
|
assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
assert_no_difference 'IssueCategory.count' do
|
assert_no_difference 'IssueCategory.count' do
|
||||||
put :update, :id => 2, :issue_category => { :name => 'Testing' }
|
put :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:issue_category => {
|
||||||
|
:name => 'Testing'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||||
assert_equal 'Testing', IssueCategory.find(2).name
|
assert_equal 'Testing', IssueCategory.find(2).name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_failure
|
def test_update_failure
|
||||||
put :update, :id => 2, :issue_category => { :name => '' }
|
put :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:issue_category => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/i
|
assert_select_error /Name cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_not_found
|
def test_update_not_found
|
||||||
put :update, :id => 97, :issue_category => { :name => 'Testing' }
|
put :update, :params => {
|
||||||
|
:id => 97,
|
||||||
|
:issue_category => {
|
||||||
|
:name => 'Testing'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_category_not_in_use
|
def test_destroy_category_not_in_use
|
||||||
delete :destroy, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||||
assert_nil IssueCategory.find_by_id(2)
|
assert_nil IssueCategory.find_by_id(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_category_in_use
|
def test_destroy_category_in_use
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil IssueCategory.find_by_id(1)
|
assert_not_nil IssueCategory.find_by_id(1)
|
||||||
assert_select 'select[name=?]', 'reassign_to_id'
|
assert_select 'select[name=?]', 'reassign_to_id'
|
||||||
@ -123,7 +171,11 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_category_in_use_with_reassignment
|
def test_destroy_category_in_use_with_reassignment
|
||||||
issue = Issue.where(:category_id => 1).first
|
issue = Issue.where(:category_id => 1).first
|
||||||
delete :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:todo => 'reassign',
|
||||||
|
:reassign_to_id => 2
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||||
assert_nil IssueCategory.find_by_id(1)
|
assert_nil IssueCategory.find_by_id(1)
|
||||||
# check that the issue was reassign
|
# check that the issue was reassign
|
||||||
@ -132,7 +184,10 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_category_in_use_without_reassignment
|
def test_destroy_category_in_use_without_reassignment
|
||||||
issue = Issue.where(:category_id => 1).first
|
issue = Issue.where(:category_id => 1).first
|
||||||
delete :destroy, :id => 1, :todo => 'nullify'
|
delete :destroy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:todo => 'nullify'
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||||
assert_nil IssueCategory.find_by_id(1)
|
assert_nil IssueCategory.find_by_id(1)
|
||||||
# check that the issue category was nullified
|
# check that the issue category was nullified
|
||||||
|
|||||||
@ -38,8 +38,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'IssueRelation.count' do
|
assert_difference 'IssueRelation.count' do
|
||||||
post :create, :issue_id => 1,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
|
:issue_id => 1,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '2',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
relation = IssueRelation.order('id DESC').first
|
relation = IssueRelation.order('id DESC').first
|
||||||
assert_equal 1, relation.issue_from_id
|
assert_equal 1, relation.issue_from_id
|
||||||
@ -49,15 +55,29 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_on_invalid_issue
|
def test_create_on_invalid_issue
|
||||||
assert_no_difference 'IssueRelation.count' do
|
assert_no_difference 'IssueRelation.count' do
|
||||||
post :create, :issue_id => 999,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
|
:issue_id => 999,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '2',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_xhr
|
def test_create_xhr
|
||||||
assert_difference 'IssueRelation.count' do
|
assert_difference 'IssueRelation.count' do
|
||||||
xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''}
|
post :create, :params => {
|
||||||
|
:issue_id => 3,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '1',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -70,8 +90,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_should_accept_id_with_hash
|
def test_create_should_accept_id_with_hash
|
||||||
assert_difference 'IssueRelation.count' do
|
assert_difference 'IssueRelation.count' do
|
||||||
post :create, :issue_id => 1,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => '#2', :relation_type => 'relates', :delay => ''}
|
:issue_id => 1,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '#2',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
relation = IssueRelation.order('id DESC').first
|
relation = IssueRelation.order('id DESC').first
|
||||||
assert_equal 2, relation.issue_to_id
|
assert_equal 2, relation.issue_to_id
|
||||||
@ -79,8 +105,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_should_strip_id
|
def test_create_should_strip_id
|
||||||
assert_difference 'IssueRelation.count' do
|
assert_difference 'IssueRelation.count' do
|
||||||
post :create, :issue_id => 1,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => ' 2 ', :relation_type => 'relates', :delay => ''}
|
:issue_id => 1,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => ' 2 ',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
relation = IssueRelation.order('id DESC').first
|
relation = IssueRelation.order('id DESC').first
|
||||||
assert_equal 2, relation.issue_to_id
|
assert_equal 2, relation.issue_to_id
|
||||||
@ -89,8 +121,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_should_not_break_with_non_numerical_id
|
def test_create_should_not_break_with_non_numerical_id
|
||||||
assert_no_difference 'IssueRelation.count' do
|
assert_no_difference 'IssueRelation.count' do
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
post :create, :issue_id => 1,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => 'foo', :relation_type => 'relates', :delay => ''}
|
:issue_id => 1,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => 'foo',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -100,8 +138,15 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
issue2 = Issue.generate!
|
issue2 = Issue.generate!
|
||||||
|
|
||||||
assert_difference 'IssueRelation.count' do
|
assert_difference 'IssueRelation.count' do
|
||||||
xhr :post, :create, :issue_id => issue2.id,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''}
|
:issue_id => issue2.id,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => issue1.id,
|
||||||
|
:relation_type => 'follows',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
end
|
end
|
||||||
assert_include 'Followed issue', response.body
|
assert_include 'Followed issue', response.body
|
||||||
end
|
end
|
||||||
@ -111,14 +156,28 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
assert_nil Issue.visible(User.find(3)).find_by_id(4)
|
assert_nil Issue.visible(User.find(3)).find_by_id(4)
|
||||||
|
|
||||||
assert_no_difference 'IssueRelation.count' do
|
assert_no_difference 'IssueRelation.count' do
|
||||||
post :create, :issue_id => 1,
|
post :create, :params => {
|
||||||
:relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''}
|
:issue_id => 1,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '4',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_xhr_with_failure
|
def test_create_xhr_with_failure
|
||||||
assert_no_difference 'IssueRelation.count' do
|
assert_no_difference 'IssueRelation.count' do
|
||||||
xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '999', :relation_type => 'relates', :delay => ''}
|
post :create, :params => {
|
||||||
|
:issue_id => 3,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => '999',
|
||||||
|
:relation_type => 'relates',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
@ -128,13 +187,17 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'IssueRelation.count', -1 do
|
assert_difference 'IssueRelation.count', -1 do
|
||||||
delete :destroy, :id => '2'
|
delete :destroy, :params => {
|
||||||
|
:id => '2'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_invalid_relation
|
def test_destroy_invalid_relation
|
||||||
assert_no_difference 'IssueRelation.count' do
|
assert_no_difference 'IssueRelation.count' do
|
||||||
delete :destroy, :id => '999'
|
delete :destroy, :params => {
|
||||||
|
:id => '999'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -146,7 +209,10 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_difference 'IssueRelation.count', -1 do
|
assert_difference 'IssueRelation.count', -1 do
|
||||||
xhr :delete, :destroy, :id => '2'
|
delete :destroy, :params => {
|
||||||
|
:id => '2'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
|
|||||||
@ -51,7 +51,11 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'IssueStatus.count' do
|
assert_difference 'IssueStatus.count' do
|
||||||
post :create, :issue_status => {:name => 'New status'}
|
post :create, :params => {
|
||||||
|
:issue_status => {
|
||||||
|
:name => 'New status'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
status = IssueStatus.order('id DESC').first
|
status = IssueStatus.order('id DESC').first
|
||||||
@ -59,26 +63,42 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
post :create, :issue_status => {:name => ''}
|
post :create, :params => {
|
||||||
|
:issue_status => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => '3'
|
get :edit, :params => {
|
||||||
|
:id => '3'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved'
|
assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
|
put :update, :params => {
|
||||||
|
:id => '3',
|
||||||
|
:issue_status => {
|
||||||
|
:name => 'Renamed status'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
status = IssueStatus.find(3)
|
status = IssueStatus.find(3)
|
||||||
assert_equal 'Renamed status', status.name
|
assert_equal 'Renamed status', status.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
put :update, :id => '3', :issue_status => {:name => ''}
|
put :update, :params => {
|
||||||
|
:id => '3',
|
||||||
|
:issue_status => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
end
|
end
|
||||||
@ -88,7 +108,9 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||||||
Tracker.where(:default_status_id => 1).delete_all
|
Tracker.where(:default_status_id => 1).delete_all
|
||||||
|
|
||||||
assert_difference 'IssueStatus.count', -1 do
|
assert_difference 'IssueStatus.count', -1 do
|
||||||
delete :destroy, :id => '1'
|
delete :destroy, :params => {
|
||||||
|
:id => '1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
assert_nil IssueStatus.find_by_id(1)
|
assert_nil IssueStatus.find_by_id(1)
|
||||||
@ -99,7 +121,9 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||||||
Tracker.where(:default_status_id => 1).delete_all
|
Tracker.where(:default_status_id => 1).delete_all
|
||||||
|
|
||||||
assert_no_difference 'IssueStatus.count' do
|
assert_no_difference 'IssueStatus.count' do
|
||||||
delete :destroy, :id => '1'
|
delete :destroy, :params => {
|
||||||
|
:id => '1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
assert_not_nil IssueStatus.find_by_id(1)
|
assert_not_nil IssueStatus.find_by_id(1)
|
||||||
@ -110,7 +134,9 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
|||||||
assert Tracker.where(:default_status_id => 1).any?
|
assert Tracker.where(:default_status_id => 1).any?
|
||||||
|
|
||||||
assert_no_difference 'IssueStatus.count' do
|
assert_no_difference 'IssueStatus.count' do
|
||||||
delete :destroy, :id => '1'
|
delete :destroy, :params => {
|
||||||
|
:id => '1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
assert_not_nil IssueStatus.find_by_id(1)
|
assert_not_nil IssueStatus.find_by_id(1)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -56,14 +56,20 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
assert_no_difference 'Journal.count' do
|
assert_no_difference 'Journal.count' do
|
||||||
assert_no_difference 'TimeEntry.count' do
|
assert_no_difference 'TimeEntry.count' do
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => issue.id,
|
:id => issue.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'My notes',
|
:notes => 'My notes',
|
||||||
:lock_version => (issue.lock_version - 1)
|
:lock_version => (issue.lock_version - 1)
|
||||||
|
|
||||||
},
|
},
|
||||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
|
:time_entry => {
|
||||||
|
:hours => '2.5',
|
||||||
|
:comments => '',
|
||||||
|
:activity_id => TimeEntryActivity.first.id
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,15 +92,24 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
assert_no_difference 'Journal.count' do
|
assert_no_difference 'Journal.count' do
|
||||||
assert_no_difference 'TimeEntry.count' do
|
assert_no_difference 'TimeEntry.count' do
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => issue.id,
|
:id => issue.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'My notes',
|
:notes => 'My notes',
|
||||||
:lock_version => (issue.lock_version - 1)
|
:lock_version => (issue.lock_version - 1)
|
||||||
|
|
||||||
},
|
},
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}},
|
:attachments => {
|
||||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
},
|
||||||
|
:time_entry => {
|
||||||
|
:hours => '2.5',
|
||||||
|
:comments => '',
|
||||||
|
:activity_id => TimeEntryActivity.first.id
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -110,11 +125,14 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
issue = Issue.find(2)
|
issue = Issue.find(2)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
put :update, :id => issue.id,
|
put :update, :params => {
|
||||||
|
:id => issue.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => '',
|
:notes => '',
|
||||||
:lock_version => (issue.lock_version - 1)
|
:lock_version => (issue.lock_version - 1)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
@ -127,13 +145,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
def test_update_stale_issue_should_show_conflicting_journals
|
def test_update_stale_issue_should_show_conflicting_journals
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => '',
|
:notes => '',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:last_journal_id => 1
|
:last_journal_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select '.conflict-journal', 1
|
assert_select '.conflict-journal', 1
|
||||||
@ -143,13 +164,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
def test_update_stale_issue_without_previous_journal_should_show_all_journals
|
def test_update_stale_issue_without_previous_journal_should_show_all_journals
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => '',
|
:notes => '',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:last_journal_id => ''
|
:last_journal_id => ''
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select '.conflict-journal', 2
|
assert_select '.conflict-journal', 2
|
||||||
@ -161,12 +185,26 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
journal = Journal.create!(:journalized => Issue.find(1), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
|
journal = Journal.create!(:journalized => Issue.find(1), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:fixed_version_id => 4,
|
||||||
|
:lock_version => 2
|
||||||
|
},
|
||||||
|
:last_journal_id => ''
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '.conflict-journal', :text => /Privates notes/
|
assert_select '.conflict-journal', :text => /Privates notes/
|
||||||
|
|
||||||
Role.find(1).remove_permission! :view_private_notes
|
Role.find(1).remove_permission! :view_private_notes
|
||||||
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:fixed_version_id => 4,
|
||||||
|
:lock_version => 2
|
||||||
|
},
|
||||||
|
:last_journal_id => ''
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '.conflict-journal', :text => /Privates notes/, :count => 0
|
assert_select '.conflict-journal', :text => /Privates notes/, :count => 0
|
||||||
end
|
end
|
||||||
@ -175,13 +213,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'Journal.count' do
|
assert_difference 'Journal.count' do
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'overwrite_conflict_resolution',
|
:notes => 'overwrite_conflict_resolution',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:conflict_resolution => 'overwrite'
|
:conflict_resolution => 'overwrite'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@ -196,13 +237,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'Journal.count' do
|
assert_difference 'Journal.count' do
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'add_notes_conflict_resolution',
|
:notes => 'add_notes_conflict_resolution',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:conflict_resolution => 'add_notes'
|
:conflict_resolution => 'add_notes'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@ -218,14 +262,17 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
journal = new_record(Journal) do
|
journal = new_record(Journal) do
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'add_privates_notes_conflict_resolution',
|
:notes => 'add_privates_notes_conflict_resolution',
|
||||||
:private_notes => '1',
|
:private_notes => '1',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:conflict_resolution => 'add_notes'
|
:conflict_resolution => 'add_notes'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@ -238,13 +285,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_no_difference 'Journal.count' do
|
assert_no_difference 'Journal.count' do
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:fixed_version_id => 4,
|
:fixed_version_id => 4,
|
||||||
:notes => 'add_notes_conflict_resolution',
|
:notes => 'add_notes_conflict_resolution',
|
||||||
:lock_version => 2
|
:lock_version => 2
|
||||||
|
|
||||||
},
|
},
|
||||||
:conflict_resolution => 'cancel'
|
:conflict_resolution => 'cancel'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to '/issues/1'
|
assert_redirected_to '/issues/1'
|
||||||
@ -256,10 +306,17 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_no_difference('TimeEntry.count') do
|
assert_no_difference('TimeEntry.count') do
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:issue => { :subject => '' },
|
:issue => {
|
||||||
:time_entry => { :hours => '2.5', :comments => 'should not be added', :activity_id => TimeEntryActivity.first.id }
|
:subject => ''
|
||||||
|
},
|
||||||
|
:time_entry => {
|
||||||
|
:hours => '2.5',
|
||||||
|
:comments => 'should not be added',
|
||||||
|
:activity_id => TimeEntryActivity.first.id
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
def test_show_should_show_visible_custom_fields_only
|
def test_show_should_show_visible_custom_fields_only
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :show, :id => @issue.id
|
get :show, :params => {
|
||||||
|
:id => @issue.id
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
assert_select '.value', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
assert_select '.value', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
||||||
@ -79,7 +81,12 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
def test_show_should_show_visible_custom_fields_only_in_api
|
def test_show_should_show_visible_custom_fields_only_in_api
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
with_settings :rest_api_enabled => '1' do
|
with_settings :rest_api_enabled => '1' do
|
||||||
get :show, :id => @issue.id, :format => 'xml', :include => 'custom_fields', :key => user.api_key
|
get :show, :params => {
|
||||||
|
:id => @issue.id,
|
||||||
|
:format => 'xml',
|
||||||
|
:include => 'custom_fields',
|
||||||
|
:key => user.api_key
|
||||||
|
}
|
||||||
end
|
end
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
@ -98,7 +105,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :show, :id => @issue.id
|
get :show, :params => {
|
||||||
|
:id => @issue.id
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
assert_select 'ul.details i', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} change"
|
assert_select 'ul.details i', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} change"
|
||||||
@ -116,7 +125,12 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
with_settings :rest_api_enabled => '1' do
|
with_settings :rest_api_enabled => '1' do
|
||||||
get :show, :id => @issue.id, :format => 'xml', :include => 'journals', :key => user.api_key
|
get :show, :params => {
|
||||||
|
:id => @issue.id,
|
||||||
|
:format => 'xml',
|
||||||
|
:include => 'journals',
|
||||||
|
:key => user.api_key
|
||||||
|
}
|
||||||
end
|
end
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
@ -133,7 +147,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :edit, :id => @issue.id
|
get :edit, :params => {
|
||||||
|
:id => @issue.id
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
assert_select 'input[value=?]', "Value#{i}", 1, "User #{user.id} was not able to edit #{field.name}"
|
assert_select 'input[value=?]', "Value#{i}", 1, "User #{user.id} was not able to edit #{field.name}"
|
||||||
@ -149,12 +165,16 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
put :update, :id => @issue.id,
|
put :update, :params => {
|
||||||
:issue => {:custom_field_values => {
|
:id => @issue.id,
|
||||||
|
:issue => {
|
||||||
|
:custom_field_values => {
|
||||||
@field1.id.to_s => "User#{user.id}Value0",
|
@field1.id.to_s => "User#{user.id}Value0",
|
||||||
@field2.id.to_s => "User#{user.id}Value1",
|
@field2.id.to_s => "User#{user.id}Value1",
|
||||||
@field3.id.to_s => "User#{user.id}Value2",
|
@field3.id.to_s => "User#{user.id}Value2",
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@issue.reload
|
@issue.reload
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
@ -169,7 +189,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
def test_index_should_show_visible_custom_fields_only
|
def test_index_should_show_visible_custom_fields_only
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"})
|
get :index, :params => {
|
||||||
|
:c => (["subject"] + @fields.map{|f| "cf_#{f.id}"})
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
||||||
@ -183,7 +205,10 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
def test_index_as_csv_should_show_visible_custom_fields_only
|
def test_index_as_csv_should_show_visible_custom_fields_only
|
||||||
@users_to_test.each do |user, fields|
|
@users_to_test.each do |user, fields|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"}), :format => 'csv'
|
get :index, :params => {
|
||||||
|
:c => (["subject"] + @fields.map{|f| "cf_#{f.id}"}),
|
||||||
|
:format => 'csv'
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if fields.include?(field)
|
if fields.include?(field)
|
||||||
assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV"
|
assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV"
|
||||||
@ -206,20 +231,29 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueC'})
|
Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueC'})
|
||||||
|
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
get :index, :c => ["subject", "cf_#{@field2.id}"]
|
get :index, :params => {
|
||||||
|
:c => ["subject", "cf_#{@field2.id}"]
|
||||||
|
}
|
||||||
assert_select 'td', :text => 'ValueA'
|
assert_select 'td', :text => 'ValueA'
|
||||||
assert_select 'td', :text => 'ValueB', :count => 0
|
assert_select 'td', :text => 'ValueB', :count => 0
|
||||||
assert_select 'td', :text => 'ValueC'
|
assert_select 'td', :text => 'ValueC'
|
||||||
|
|
||||||
get :index, :sort => "cf_#{@field2.id}"
|
get :index, :params => {
|
||||||
|
:sort => "cf_#{@field2.id}"
|
||||||
|
}
|
||||||
# ValueB is not visible to user and ignored while sorting
|
# ValueB is not visible to user and ignored while sorting
|
||||||
assert_equal %w(ValueB ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
assert_equal %w(ValueB ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||||
|
|
||||||
get :index, :set_filter => '1', "cf_#{@field2.id}" => '*', :sort => "cf_#{@field2.id}"
|
get :index, :params => {
|
||||||
|
:set_filter => '1', "cf_#{@field2.id}" => '*',
|
||||||
|
:sort => "cf_#{@field2.id}"
|
||||||
|
}
|
||||||
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||||
|
|
||||||
CustomField.update_all(:field_format => 'list')
|
CustomField.update_all(:field_format => 'list')
|
||||||
get :index, :group => "cf_#{@field2.id}"
|
get :index, :params => {
|
||||||
|
:group => "cf_#{@field2.id}"
|
||||||
|
}
|
||||||
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -231,15 +265,19 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
with_settings :bcc_recipients => '1' do
|
with_settings :bcc_recipients => '1' do
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 1,
|
:project_id => 1,
|
||||||
:issue => {
|
:issue => {
|
||||||
:tracker_id => 1,
|
:tracker_id => 1,
|
||||||
:status_id => 1,
|
:status_id => 1,
|
||||||
:subject => 'New issue',
|
:subject => 'New issue',
|
||||||
:priority_id => 5,
|
:priority_id => 5,
|
||||||
:custom_field_values => {@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'},
|
:custom_field_values => {
|
||||||
|
@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'
|
||||||
|
},
|
||||||
:watcher_user_ids => users_to_test.keys.map(&:id)
|
:watcher_user_ids => users_to_test.keys.map(&:id)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
@ -270,10 +308,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
with_settings :bcc_recipients => '1' do
|
with_settings :bcc_recipients => '1' do
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => @issue.id,
|
:id => @issue.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
:custom_field_values => {@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
:custom_field_values => {
|
||||||
|
@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
@ -303,10 +345,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
|||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
with_settings :bcc_recipients => '1' do
|
with_settings :bcc_recipients => '1' do
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => @issue.id,
|
:id => @issue.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
:custom_field_values => {@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
:custom_field_values => {
|
||||||
|
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|||||||
@ -26,13 +26,18 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/atom+xml', @response.content_type
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_invalid_query_id
|
def test_index_with_invalid_query_id
|
||||||
get :index, :project_id => 1, :query_id => 999
|
get :index, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:query_id => 999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,18 +45,23 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
|
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}"
|
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}"
|
||||||
|
|
||||||
Role.find(1).remove_permission! :view_private_notes
|
Role.find(1).remove_permission! :view_private_notes
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}", :count => 0
|
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}", :count => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_should_show_visible_custom_fields_only
|
def test_index_should_show_visible_custom_fields_only
|
||||||
Issue.destroy_all
|
Issue.destroy_all
|
||||||
|
Journal.delete_all
|
||||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||||
@fields = []
|
@fields = []
|
||||||
@fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
|
@fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
|
||||||
@ -64,8 +74,8 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
:custom_field_values => {@field1.id => 'Value0', @field2.id => 'Value1', @field3.id => 'Value2'}
|
:custom_field_values => {@field1.id => 'Value0', @field2.id => 'Value1', @field3.id => 'Value2'}
|
||||||
)
|
)
|
||||||
@issue.init_journal(User.find(1))
|
@issue.init_journal(User.find(1))
|
||||||
@issue.update_attribute :custom_field_values, {@field1.id => 'NewValue0', @field2.id => 'NewValue1', @field3.id => 'NewValue2'}
|
@issue.custom_field_values = {@field1.id => 'NewValue0', @field2.id => 'NewValue1', @field3.id => 'NewValue2'}
|
||||||
|
@issue.save!
|
||||||
|
|
||||||
user_with_role_on_other_project = User.generate!
|
user_with_role_on_other_project = User.generate!
|
||||||
User.add_to_project(user_with_role_on_other_project, Project.find(2), Role.find(3))
|
User.add_to_project(user_with_role_on_other_project, Project.find(2), Role.find(3))
|
||||||
@ -78,7 +88,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
users_to_test.each do |user, visible_fields|
|
users_to_test.each do |user, visible_fields|
|
||||||
get :index, :format => 'atom', :key => user.rss_key
|
get :index, :params => {
|
||||||
|
:format => 'atom',
|
||||||
|
:key => user.rss_key
|
||||||
|
}
|
||||||
@fields.each_with_index do |field, i|
|
@fields.each_with_index do |field, i|
|
||||||
if visible_fields.include?(field)
|
if visible_fields.include?(field)
|
||||||
assert_select "content[type=html]", { :text => /NewValue#{i}/, :count => 1 }, "User #{user.id} was not able to view #{field.name} in API"
|
assert_select "content[type=html]", { :text => /NewValue#{i}/, :count => 1 }, "User #{user.id} was not able to view #{field.name} in API"
|
||||||
@ -91,7 +104,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_diff_for_description_change
|
def test_diff_for_description_change
|
||||||
get :diff, :id => 3, :detail_id => 4
|
get :diff, :params => {
|
||||||
|
:id => 3,
|
||||||
|
:detail_id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'span.diff_out', :text => /removed/
|
assert_select 'span.diff_out', :text => /removed/
|
||||||
@ -104,7 +120,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
detail = JournalDetail.create!(:journal => journal, :property => 'cf', :prop_key => field.id,
|
detail = JournalDetail.create!(:journal => journal, :property => 'cf', :prop_key => field.id,
|
||||||
:old_value => 'Foo', :value => 'Bar')
|
:old_value => 'Foo', :value => 'Bar')
|
||||||
|
|
||||||
get :diff, :id => journal.id, :detail_id => detail.id
|
get :diff, :params => {
|
||||||
|
:id => journal.id,
|
||||||
|
:detail_id => detail.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'span.diff_out', :text => /Foo/
|
assert_select 'span.diff_out', :text => /Foo/
|
||||||
@ -117,12 +136,17 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
detail = JournalDetail.create!(:journal => journal, :property => 'cf', :prop_key => field.id,
|
detail = JournalDetail.create!(:journal => journal, :property => 'cf', :prop_key => field.id,
|
||||||
:old_value => 'Foo', :value => 'Bar')
|
:old_value => 'Foo', :value => 'Bar')
|
||||||
|
|
||||||
get :diff, :id => journal.id, :detail_id => detail.id
|
get :diff, :params => {
|
||||||
|
:id => journal.id,
|
||||||
|
:detail_id => detail.id
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_diff_should_default_to_description_diff
|
def test_diff_should_default_to_description_diff
|
||||||
get :diff, :id => 3
|
get :diff, :params => {
|
||||||
|
:id => 3
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'span.diff_out', :text => /removed/
|
assert_select 'span.diff_out', :text => /removed/
|
||||||
@ -131,7 +155,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_reply_to_issue
|
def test_reply_to_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :id => 6
|
get :new, :params => {
|
||||||
|
:id => 6
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
@ -140,13 +167,20 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_reply_to_issue_without_permission
|
def test_reply_to_issue_without_permission
|
||||||
@request.session[:user_id] = 7
|
@request.session[:user_id] = 7
|
||||||
xhr :get, :new, :id => 6
|
get :new, :params => {
|
||||||
|
:id => 6
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reply_to_note
|
def test_reply_to_note
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :id => 6, :journal_id => 4
|
get :new, :params => {
|
||||||
|
:id => 6,
|
||||||
|
:journal_id => 4
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_include '> A comment with a private version', response.body
|
assert_include '> A comment with a private version', response.body
|
||||||
@ -156,19 +190,30 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true)
|
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true)
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
xhr :get, :new, :id => 2, :journal_id => journal.id
|
get :new, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal_id => journal.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_include '> Privates notes', response.body
|
assert_include '> Privates notes', response.body
|
||||||
|
|
||||||
Role.find(1).remove_permission! :view_private_notes
|
Role.find(1).remove_permission! :view_private_notes
|
||||||
xhr :get, :new, :id => 2, :journal_id => journal.id
|
get :new, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal_id => journal.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_xhr
|
def test_edit_xhr
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
xhr :get, :edit, :id => 2
|
get :edit, :params => {
|
||||||
|
:id => 2
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_include 'textarea', response.body
|
assert_include 'textarea', response.body
|
||||||
@ -179,19 +224,31 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
Role.find(1).add_permission! :edit_issue_notes
|
Role.find(1).add_permission! :edit_issue_notes
|
||||||
|
|
||||||
xhr :get, :edit, :id => journal.id
|
get :edit, :params => {
|
||||||
|
:id => journal.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_include 'textarea', response.body
|
assert_include 'textarea', response.body
|
||||||
|
|
||||||
Role.find(1).remove_permission! :view_private_notes
|
Role.find(1).remove_permission! :view_private_notes
|
||||||
xhr :get, :edit, :id => journal.id
|
get :edit, :params => {
|
||||||
|
:id => journal.id
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_xhr
|
def test_update_xhr
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
xhr :post, :update, :id => 2, :journal => {:notes => 'Updated notes'}
|
post :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal => {
|
||||||
|
:notes => 'Updated notes'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_equal 'Updated notes', Journal.find(2).notes
|
assert_equal 'Updated notes', Journal.find(2).notes
|
||||||
@ -200,7 +257,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_xhr_with_private_notes_checked
|
def test_update_xhr_with_private_notes_checked
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
xhr :post, :update, :id => 2, :journal => {:private_notes => '1'}
|
post :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal => {
|
||||||
|
:private_notes => '1'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_equal true, Journal.find(2).private_notes
|
assert_equal true, Journal.find(2).private_notes
|
||||||
@ -211,7 +274,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
def test_update_xhr_with_private_notes_unchecked
|
def test_update_xhr_with_private_notes_unchecked
|
||||||
Journal.find(2).update_attributes(:private_notes => true)
|
Journal.find(2).update_attributes(:private_notes => true)
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
xhr :post, :update, :id => 2, :journal => {:private_notes => '0'}
|
post :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal => {
|
||||||
|
:private_notes => '0'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
assert_equal false, Journal.find(2).private_notes
|
assert_equal false, Journal.find(2).private_notes
|
||||||
@ -225,7 +294,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(1).add_permission! :view_private_notes
|
Role.find(1).add_permission! :view_private_notes
|
||||||
Role.find(1).remove_permission! :set_notes_private
|
Role.find(1).remove_permission! :set_notes_private
|
||||||
|
|
||||||
xhr :post, :update, :id => 2, :journal => {:private_notes => '1'}
|
post :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal => {
|
||||||
|
:private_notes => '1'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal false, Journal.find(2).private_notes
|
assert_equal false, Journal.find(2).private_notes
|
||||||
end
|
end
|
||||||
@ -233,7 +308,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
|||||||
def test_update_xhr_with_empty_notes_should_delete_the_journal
|
def test_update_xhr_with_empty_notes_should_delete_the_journal
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'Journal.count', -1 do
|
assert_difference 'Journal.count', -1 do
|
||||||
xhr :post, :update, :id => 2, :journal => {:notes => ''}
|
post :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:journal => {
|
||||||
|
:notes => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|||||||
@ -33,7 +33,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
post :index, :params => {
|
||||||
|
:key => 'secret',
|
||||||
|
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 201
|
assert_response 201
|
||||||
end
|
end
|
||||||
@ -44,9 +47,13 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
post :index, :key => 'secret',
|
post :index, :params => {
|
||||||
|
:key => 'secret',
|
||||||
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
|
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
|
||||||
:issue => {:is_private => '1'}
|
:issue => {
|
||||||
|
:is_private => '1'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 201
|
assert_response 201
|
||||||
issue = Issue.order(:id => :desc).first
|
issue = Issue.order(:id => :desc).first
|
||||||
@ -60,7 +67,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
assert_no_difference 'Issue.count' do
|
assert_no_difference 'Issue.count' do
|
||||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
post :index, :params => {
|
||||||
|
:key => 'secret',
|
||||||
|
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 422
|
assert_response 422
|
||||||
end
|
end
|
||||||
@ -71,7 +81,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
assert_no_difference 'Issue.count' do
|
assert_no_difference 'Issue.count' do
|
||||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
post :index, :params => {
|
||||||
|
:key => 'secret',
|
||||||
|
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 403
|
assert_response 403
|
||||||
assert_include 'Access denied', response.body
|
assert_include 'Access denied', response.body
|
||||||
@ -82,7 +95,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
assert_no_difference 'Issue.count' do
|
assert_no_difference 'Issue.count' do
|
||||||
post :index, :key => 'wrong', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
post :index, :params => {
|
||||||
|
:key => 'wrong',
|
||||||
|
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 403
|
assert_response 403
|
||||||
assert_include 'Access denied', response.body
|
assert_include 'Access denied', response.body
|
||||||
@ -92,7 +108,9 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
Setting.mail_handler_api_enabled = 1
|
Setting.mail_handler_api_enabled = 1
|
||||||
Setting.mail_handler_api_key = 'secret'
|
Setting.mail_handler_api_key = 'secret'
|
||||||
|
|
||||||
get :new, :key => 'secret'
|
get :new, :params => {
|
||||||
|
:key => 'secret'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -26,7 +26,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -35,7 +37,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
role.update! :all_roles_managed => false
|
role.update! :all_roles_managed => false
|
||||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||||
|
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.roles-selection' do
|
assert_select 'div.roles-selection' do
|
||||||
assert_select 'label', :text => 'Manager', :count => 0
|
assert_select 'label', :text => 'Manager', :count => 0
|
||||||
@ -45,14 +49,23 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_new
|
def test_xhr_new
|
||||||
xhr :get, :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post :create, :project_id => 1, :membership => {:role_ids => [1], :user_id => 7}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1],
|
||||||
|
:user_id => 7
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||||
assert User.find(7).member_of?(Project.find(1))
|
assert User.find(7).member_of?(Project.find(1))
|
||||||
@ -60,7 +73,13 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_multiple
|
def test_create_multiple
|
||||||
assert_difference 'Member.count', 3 do
|
assert_difference 'Member.count', 3 do
|
||||||
post :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1],
|
||||||
|
:user_ids => [7, 8, 9]
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||||
assert User.find(7).member_of?(Project.find(1))
|
assert User.find(7).member_of?(Project.find(1))
|
||||||
@ -72,7 +91,13 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||||
|
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post :create, :project_id => 1, :membership => {:role_ids => [1, 2], :user_id => 7}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1, 2],
|
||||||
|
:user_id => 7
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
member = Member.order(:id => :desc).first
|
member = Member.order(:id => :desc).first
|
||||||
assert_equal [2], member.role_ids
|
assert_equal [2], member.role_ids
|
||||||
@ -83,7 +108,13 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post :create, :project_id => 1, :membership => {:role_ids => [1, 2], :user_id => 7}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1, 2],
|
||||||
|
:user_id => 7
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
member = Member.order(:id => :desc).first
|
member = Member.order(:id => :desc).first
|
||||||
assert_equal [1, 2], member.role_ids
|
assert_equal [1, 2], member.role_ids
|
||||||
@ -91,7 +122,14 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_create
|
def test_xhr_create
|
||||||
assert_difference 'Member.count', 3 do
|
assert_difference 'Member.count', 3 do
|
||||||
xhr :post, :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1],
|
||||||
|
:user_ids => [7, 8, 9]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -103,7 +141,14 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_create_with_failure
|
def test_xhr_create_with_failure
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
xhr :post, :create, :project_id => 1, :membership => {:role_ids => [], :user_ids => [7, 8, 9]}
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [],
|
||||||
|
:user_ids => [7, 8, 9]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -111,19 +156,30 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 2
|
get :edit, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '2'
|
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '2'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_edit
|
def test_xhr_edit
|
||||||
xhr :get, :edit, :id => 2
|
get :edit, :params => {
|
||||||
|
:id => 2
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
put :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3}
|
put :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1],
|
||||||
|
:user_id => 3
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||||
end
|
end
|
||||||
@ -131,7 +187,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
def test_update_locked_member_should_be_allowed
|
def test_update_locked_member_should_be_allowed
|
||||||
User.find(3).lock!
|
User.find(3).lock!
|
||||||
|
|
||||||
put :update, :id => 2, :membership => {:role_ids => [1]}
|
put :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
member = Member.find(2)
|
member = Member.find(2)
|
||||||
assert member.user.locked?
|
assert member.user.locked?
|
||||||
@ -144,7 +205,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||||
member = Member.create!(:user => User.find(9), :role_ids => [3], :project_id => 1)
|
member = Member.create!(:user => User.find(9), :role_ids => [3], :project_id => 1)
|
||||||
|
|
||||||
put :update, :id => member.id, :membership => {:role_ids => [1, 2, 3]}
|
put :update, :params => {
|
||||||
|
:id => member.id,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1, 2, 3]
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_equal [2, 3], member.reload.role_ids.sort
|
assert_equal [2, 3], member.reload.role_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -154,13 +220,25 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||||
member = Member.create!(:user => User.find(9), :role_ids => [1, 3], :project_id => 1)
|
member = Member.create!(:user => User.find(9), :role_ids => [1, 3], :project_id => 1)
|
||||||
|
|
||||||
put :update, :id => member.id, :membership => {:role_ids => [2]}
|
put :update, :params => {
|
||||||
|
:id => member.id,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [2]
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_equal [1, 2], member.reload.role_ids.sort
|
assert_equal [1, 2], member.reload.role_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_update
|
def test_xhr_update
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
xhr :put, :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3}
|
put :update, :params => {
|
||||||
|
:id => 2,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [1],
|
||||||
|
:user_id => 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -172,7 +250,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
delete :destroy, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||||
assert !User.find(3).member_of?(Project.find(1))
|
assert !User.find(3).member_of?(Project.find(1))
|
||||||
@ -182,7 +262,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
assert User.find(3).lock!
|
assert User.find(3).lock!
|
||||||
|
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
delete :destroy, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,7 +275,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
member = Member.create!(:user => User.find(9), :role_ids => [1, 3], :project_id => 1)
|
member = Member.create!(:user => User.find(9), :role_ids => [1, 3], :project_id => 1)
|
||||||
|
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
delete :destroy, :id => member.id
|
delete :destroy, :params => {
|
||||||
|
:id => member.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -204,13 +288,18 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
member = Member.create!(:user => User.find(9), :role_ids => [3], :project_id => 1)
|
member = Member.create!(:user => User.find(9), :role_ids => [3], :project_id => 1)
|
||||||
|
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
delete :destroy, :id => member.id
|
delete :destroy, :params => {
|
||||||
|
:id => member.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_destroy
|
def test_xhr_destroy
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
xhr :delete, :destroy, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 2
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -219,7 +308,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_autocomplete
|
def test_autocomplete
|
||||||
xhr :get, :autocomplete, :project_id => 1, :q => 'mis', :format => 'js'
|
get :autocomplete, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:q => 'mis',
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'User Misc', response.body
|
assert_include 'User Misc', response.body
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,7 +25,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :board_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h2', :text => 'First post'
|
assert_select 'h2', :text => 'First post'
|
||||||
@ -33,7 +36,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_should_contain_reply_field_tags_for_quoting
|
def test_show_should_contain_reply_field_tags_for_quoting
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :board_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# tags required by MessagesController#quote
|
# tags required by MessagesController#quote
|
||||||
@ -54,7 +60,11 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
reply_ids = message.children.map(&:id).sort
|
reply_ids = message.children.map(&:id).sort
|
||||||
|
|
||||||
get :show, :board_id => 1, :id => 1, :r => reply_ids.last
|
get :show, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1,
|
||||||
|
:r => reply_ids.last
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}"
|
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}"
|
||||||
@ -63,25 +73,36 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_with_reply_permission
|
def test_show_with_reply_permission
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show, :board_id => 1, :id => 1
|
get :show, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'div#reply textarea#message_content'
|
assert_select 'div#reply textarea#message_content'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_message_not_found
|
def test_show_message_not_found
|
||||||
get :show, :board_id => 1, :id => 99999
|
get :show, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 99999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_message_from_invalid_board_should_respond_with_404
|
def test_show_message_from_invalid_board_should_respond_with_404
|
||||||
get :show, :board_id => 999, :id => 1
|
get :show, :params => {
|
||||||
|
:board_id => 999,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :board_id => 1
|
get :new, :params => {
|
||||||
|
:board_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?]', 'message[subject]'
|
assert_select 'input[name=?]', 'message[subject]'
|
||||||
@ -89,7 +110,9 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_get_new_with_invalid_board
|
def test_get_new_with_invalid_board
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :board_id => 99
|
get :new, :params => {
|
||||||
|
:board_id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,9 +121,13 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
with_settings :notified_events => %w(message_posted) do
|
with_settings :notified_events => %w(message_posted) do
|
||||||
post :new, :board_id => 1,
|
post :new, :params => {
|
||||||
:message => { :subject => 'Test created message',
|
:board_id => 1,
|
||||||
:content => 'Message body'}
|
:message => {
|
||||||
|
:subject => 'Test created message',
|
||||||
|
:content => 'Message body'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
message = Message.find_by_subject('Test created message')
|
message = Message.find_by_subject('Test created message')
|
||||||
assert_not_nil message
|
assert_not_nil message
|
||||||
@ -121,7 +148,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_get_edit
|
def test_get_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :board_id => 1, :id => 1
|
get :edit, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value=?]', 'message[subject]', 'First post'
|
assert_select 'input[name=?][value=?]', 'message[subject]', 'First post'
|
||||||
@ -129,9 +159,14 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_edit
|
def test_post_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :edit, :board_id => 1, :id => 1,
|
post :edit, :params => {
|
||||||
:message => { :subject => 'New subject',
|
:board_id => 1,
|
||||||
:content => 'New body'}
|
:id => 1,
|
||||||
|
:message => {
|
||||||
|
:subject => 'New subject',
|
||||||
|
:content => 'New body'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/boards/1/topics/1'
|
assert_redirected_to '/boards/1/topics/1'
|
||||||
message = Message.find(1)
|
message = Message.find(1)
|
||||||
assert_equal 'New subject', message.subject
|
assert_equal 'New subject', message.subject
|
||||||
@ -140,11 +175,16 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_edit_sticky_and_locked
|
def test_post_edit_sticky_and_locked
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :edit, :board_id => 1, :id => 1,
|
post :edit, :params => {
|
||||||
:message => { :subject => 'New subject',
|
:board_id => 1,
|
||||||
|
:id => 1,
|
||||||
|
:message => {
|
||||||
|
:subject => 'New subject',
|
||||||
:content => 'New body',
|
:content => 'New body',
|
||||||
:locked => '1',
|
:locked => '1',
|
||||||
:sticky => '1'}
|
:sticky => '1'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/boards/1/topics/1'
|
assert_redirected_to '/boards/1/topics/1'
|
||||||
message = Message.find(1)
|
message = Message.find(1)
|
||||||
assert_equal true, message.sticky?
|
assert_equal true, message.sticky?
|
||||||
@ -153,10 +193,15 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_edit_should_allow_to_change_board
|
def test_post_edit_should_allow_to_change_board
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :edit, :board_id => 1, :id => 1,
|
post :edit, :params => {
|
||||||
:message => { :subject => 'New subject',
|
:board_id => 1,
|
||||||
|
:id => 1,
|
||||||
|
:message => {
|
||||||
|
:subject => 'New subject',
|
||||||
:content => 'New body',
|
:content => 'New body',
|
||||||
:board_id => 2}
|
:board_id => 2
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/boards/2/topics/1'
|
assert_redirected_to '/boards/2/topics/1'
|
||||||
message = Message.find(1)
|
message = Message.find(1)
|
||||||
assert_equal Board.find(2), message.board
|
assert_equal Board.find(2), message.board
|
||||||
@ -164,7 +209,14 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_reply
|
def test_reply
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
|
post :reply, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1,
|
||||||
|
:reply => {
|
||||||
|
:content => 'This is a test reply',
|
||||||
|
:subject => 'Test reply'
|
||||||
|
}
|
||||||
|
}
|
||||||
reply = Message.order('id DESC').first
|
reply = Message.order('id DESC').first
|
||||||
assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
|
assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
|
||||||
assert Message.find_by_subject('Test reply')
|
assert Message.find_by_subject('Test reply')
|
||||||
@ -173,7 +225,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy_topic
|
def test_destroy_topic
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Message.count', -3 do
|
assert_difference 'Message.count', -3 do
|
||||||
post :destroy, :board_id => 1, :id => 1
|
post :destroy, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/boards/1'
|
assert_redirected_to '/projects/ecookbook/boards/1'
|
||||||
assert_nil Message.find_by_id(1)
|
assert_nil Message.find_by_id(1)
|
||||||
@ -182,7 +237,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy_reply
|
def test_destroy_reply
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Message.count', -1 do
|
assert_difference 'Message.count', -1 do
|
||||||
post :destroy, :board_id => 1, :id => 2
|
post :destroy, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/boards/1/topics/1?r=2'
|
assert_redirected_to '/boards/1/topics/1?r=2'
|
||||||
assert_nil Message.find_by_id(2)
|
assert_nil Message.find_by_id(2)
|
||||||
@ -190,7 +248,11 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_quote
|
def test_quote
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :quote, :board_id => 1, :id => 3
|
get :quote, :params => {
|
||||||
|
:board_id => 1,
|
||||||
|
:id => 3
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
|
|
||||||
@ -200,19 +262,27 @@ class MessagesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview_new
|
def test_preview_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :preview,
|
post :preview, :params => {
|
||||||
:board_id => 1,
|
:board_id => 1,
|
||||||
:message => {:subject => "", :content => "Previewed text"}
|
:message => {
|
||||||
|
:subject => "",
|
||||||
|
:content => "Previewed text"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'Previewed text', response.body
|
assert_include 'Previewed text', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_edit
|
def test_preview_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :preview,
|
post :preview, :params => {
|
||||||
:id => 4,
|
:id => 4,
|
||||||
:board_id => 1,
|
:board_id => 1,
|
||||||
:message => {:subject => "", :content => "Previewed text"}
|
:message => {
|
||||||
|
:subject => "",
|
||||||
|
:content => "Previewed text"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'Previewed text', response.body
|
assert_include 'Previewed text', response.body
|
||||||
end
|
end
|
||||||
|
|||||||
@ -238,13 +238,17 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_account
|
def test_update_account
|
||||||
post :account,
|
post :account, :params => {
|
||||||
:user => {
|
:user => {
|
||||||
:firstname => "Joe",
|
:firstname => "Joe",
|
||||||
:login => "root",
|
:login => "root",
|
||||||
:admin => 1,
|
:admin => 1,
|
||||||
:group_ids => ['10'],
|
:group_ids => ['10'],
|
||||||
:custom_field_values => {"4" => "0100562500"}
|
:custom_field_values => {
|
||||||
|
"4" => "0100562500"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
@ -259,9 +263,11 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_account_should_send_security_notification
|
def test_update_account_should_send_security_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
post :account,
|
post :account, :params => {
|
||||||
:user => {
|
:user => {
|
||||||
:mail => 'foobar@example.com'
|
:mail => 'foobar@example.com'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||||
@ -297,7 +303,9 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_destroy_without_confirmation_should_destroy_account
|
def test_post_destroy_without_confirmation_should_destroy_account
|
||||||
assert_difference 'User.count', -1 do
|
assert_difference 'User.count', -1 do
|
||||||
post :destroy, :confirm => '1'
|
post :destroy, :params => {
|
||||||
|
:confirm => '1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
assert_match /deleted/i, flash[:notice]
|
assert_match /deleted/i, flash[:notice]
|
||||||
@ -307,7 +315,9 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
User.any_instance.stubs(:own_account_deletable?).returns(false)
|
User.any_instance.stubs(:own_account_deletable?).returns(false)
|
||||||
|
|
||||||
assert_no_difference 'User.count' do
|
assert_no_difference 'User.count' do
|
||||||
post :destroy, :confirm => '1'
|
post :destroy, :params => {
|
||||||
|
:confirm => '1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
end
|
end
|
||||||
@ -321,17 +331,21 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_password
|
def test_update_password
|
||||||
post :password, :password => 'jsmith',
|
post :password, :params => {
|
||||||
|
:password => 'jsmith',
|
||||||
:new_password => 'secret123',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'secret123'
|
:new_password_confirmation => 'secret123'
|
||||||
|
}
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
assert User.try_to_login('jsmith', 'secret123')
|
assert User.try_to_login('jsmith', 'secret123')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_password_with_non_matching_confirmation
|
def test_update_password_with_non_matching_confirmation
|
||||||
post :password, :password => 'jsmith',
|
post :password, :params => {
|
||||||
|
:password => 'jsmith',
|
||||||
:new_password => 'secret123',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'secret1234'
|
:new_password_confirmation => 'secret1234'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Password doesn.*t match confirmation/
|
assert_select_error /Password doesn.*t match confirmation/
|
||||||
assert User.try_to_login('jsmith', 'jsmith')
|
assert User.try_to_login('jsmith', 'jsmith')
|
||||||
@ -339,9 +353,11 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_password_with_wrong_password
|
def test_update_password_with_wrong_password
|
||||||
# wrong password
|
# wrong password
|
||||||
post :password, :password => 'wrongpassword',
|
post :password, :params => {
|
||||||
|
:password => 'wrongpassword',
|
||||||
:new_password => 'secret123',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'secret123'
|
:new_password_confirmation => 'secret123'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'Wrong password', flash[:error]
|
assert_equal 'Wrong password', flash[:error]
|
||||||
assert User.try_to_login('jsmith', 'jsmith')
|
assert User.try_to_login('jsmith', 'jsmith')
|
||||||
@ -357,9 +373,11 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_password_should_send_security_notification
|
def test_update_password_should_send_security_notification
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
post :password, :password => 'jsmith',
|
post :password, :params => {
|
||||||
|
:password => 'jsmith',
|
||||||
:new_password => 'secret123',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'secret123'
|
:new_password_confirmation => 'secret123'
|
||||||
|
}
|
||||||
|
|
||||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||||
assert_mail_body_no_match 'secret123', mail # just to be sure: pw should never be sent!
|
assert_mail_body_no_match 'secret123', mail # just to be sure: pw should never be sent!
|
||||||
@ -372,7 +390,13 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
user = User.generate!(:language => 'en')
|
user = User.generate!(:language => 'en')
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
|
|
||||||
xhr :post, :update_page, :settings => {'issuesassignedtome' => {'columns' => ['subject', 'due_date']}}
|
post :update_page, :params => {
|
||||||
|
:settings => {
|
||||||
|
'issuesassignedtome' => {
|
||||||
|
'columns' => ['subject', 'due_date']}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$("#block-issuesassignedtome").replaceWith(', response.body
|
assert_include '$("#block-issuesassignedtome").replaceWith(', response.body
|
||||||
assert_include 'Due date', response.body
|
assert_include 'Due date', response.body
|
||||||
@ -381,30 +405,42 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_add_block
|
def test_add_block
|
||||||
post :add_block, :block => 'issueswatched'
|
post :add_block, :params => {
|
||||||
|
:block => 'issueswatched'
|
||||||
|
}
|
||||||
assert_redirected_to '/my/page'
|
assert_redirected_to '/my/page'
|
||||||
assert User.find(2).pref[:my_page_layout]['top'].include?('issueswatched')
|
assert User.find(2).pref[:my_page_layout]['top'].include?('issueswatched')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_block_xhr
|
def test_add_block_xhr
|
||||||
xhr :post, :add_block, :block => 'issueswatched'
|
post :add_block, :params => {
|
||||||
|
:block => 'issueswatched'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'issueswatched', User.find(2).pref[:my_page_layout]['top']
|
assert_include 'issueswatched', User.find(2).pref[:my_page_layout]['top']
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_invalid_block_should_error
|
def test_add_invalid_block_should_error
|
||||||
post :add_block, :block => 'invalid'
|
post :add_block, :params => {
|
||||||
|
:block => 'invalid'
|
||||||
|
}
|
||||||
assert_response 422
|
assert_response 422
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_block
|
def test_remove_block
|
||||||
post :remove_block, :block => 'issuesassignedtome'
|
post :remove_block, :params => {
|
||||||
|
:block => 'issuesassignedtome'
|
||||||
|
}
|
||||||
assert_redirected_to '/my/page'
|
assert_redirected_to '/my/page'
|
||||||
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_block_xhr
|
def test_remove_block_xhr
|
||||||
xhr :post, :remove_block, :block => 'issuesassignedtome'
|
post :remove_block, :params => {
|
||||||
|
:block => 'issuesassignedtome'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$("#block-issuesassignedtome").remove();', response.body
|
assert_include '$("#block-issuesassignedtome").remove();', response.body
|
||||||
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
||||||
@ -415,7 +451,11 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
pref.my_page_layout = {'left' => ['news', 'calendar','documents']}
|
pref.my_page_layout = {'left' => ['news', 'calendar','documents']}
|
||||||
pref.save!
|
pref.save!
|
||||||
|
|
||||||
xhr :post, :order_blocks, :group => 'left', :blocks => ['documents', 'calendar', 'news']
|
post :order_blocks, :params => {
|
||||||
|
:group => 'left',
|
||||||
|
:blocks => ['documents', 'calendar', 'news']
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal ['documents', 'calendar', 'news'], User.find(2).pref.my_page_layout['left']
|
assert_equal ['documents', 'calendar', 'news'], User.find(2).pref.my_page_layout['left']
|
||||||
end
|
end
|
||||||
@ -425,7 +465,11 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
pref.my_page_layout = {'left' => ['news','documents'], 'right' => ['calendar']}
|
pref.my_page_layout = {'left' => ['news','documents'], 'right' => ['calendar']}
|
||||||
pref.save!
|
pref.save!
|
||||||
|
|
||||||
xhr :post, :order_blocks, :group => 'left', :blocks => ['news', 'calendar', 'documents']
|
post :order_blocks, :params => {
|
||||||
|
:group => 'left',
|
||||||
|
:blocks => ['news', 'calendar', 'documents']
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal({'left' => ['news', 'calendar', 'documents'], 'right' => []}, User.find(2).pref.my_page_layout)
|
assert_equal({'left' => ['news', 'calendar', 'documents'], 'right' => []}, User.find(2).pref.my_page_layout)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -33,18 +33,24 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_project
|
def test_index_with_project
|
||||||
get :index, :project_id => 1
|
get :index, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h3 a', :text => 'eCookbook first release !'
|
assert_select 'h3 a', :text => 'eCookbook first release !'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_invalid_project_should_respond_with_404
|
def test_index_with_invalid_project_should_respond_with_404
|
||||||
get :index, :project_id => 999
|
get :index, :params => {
|
||||||
|
:project_id => 999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => 'eCookbook first release !'
|
assert_select 'h2', :text => 'eCookbook first release !'
|
||||||
end
|
end
|
||||||
@ -54,7 +60,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
attachment.container = News.find(1)
|
attachment.container = News.find(1)
|
||||||
attachment.save!
|
attachment.save!
|
||||||
|
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a', :text => attachment.filename
|
assert_select 'a', :text => attachment.filename
|
||||||
end
|
end
|
||||||
@ -65,7 +73,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
user.pref.save!
|
user.pref.save!
|
||||||
|
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
|
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
|
||||||
@ -73,13 +83,17 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_not_found
|
def test_show_not_found
|
||||||
get :show, :id => 999
|
get :show, :params => {
|
||||||
|
:id => 999
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?]', 'news[title]'
|
assert_select 'input[name=?]', 'news[title]'
|
||||||
end
|
end
|
||||||
@ -89,9 +103,14 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
with_settings :notified_events => %w(news_added) do
|
with_settings :notified_events => %w(news_added) do
|
||||||
post :create, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:news => {
|
||||||
|
:title => 'NewsControllerTest',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
:summary => '' }
|
:summary => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/ecookbook/news'
|
assert_redirected_to '/projects/ecookbook/news'
|
||||||
|
|
||||||
@ -108,9 +127,17 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'News.count' do
|
assert_difference 'News.count' do
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
post :create, :project_id => 1,
|
post :create, :params => {
|
||||||
:news => { :title => 'Test', :description => 'This is the description' },
|
:project_id => 1,
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
:news => {
|
||||||
|
:title => 'Test',
|
||||||
|
:description => 'This is the description'
|
||||||
|
},
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
attachment = Attachment.order('id DESC').first
|
attachment = Attachment.order('id DESC').first
|
||||||
@ -120,23 +147,35 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_create_with_validation_failure
|
def test_post_create_with_validation_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create, :project_id => 1, :news => { :title => '',
|
post :create, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:news => {
|
||||||
|
:title => '',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
:summary => '' }
|
:summary => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /title cannot be blank/i
|
assert_select_error /title cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_edit
|
def test_get_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !'
|
assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_update
|
def test_put_update
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' }
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:news => {
|
||||||
|
:description => 'Description changed by test_post_edit'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/news/1'
|
assert_redirected_to '/news/1'
|
||||||
news = News.find(1)
|
news = News.find(1)
|
||||||
assert_equal 'Description changed by test_post_edit', news.description
|
assert_equal 'Description changed by test_post_edit', news.description
|
||||||
@ -147,9 +186,16 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'News.count' do
|
assert_no_difference 'News.count' do
|
||||||
assert_difference 'Attachment.count' do
|
assert_difference 'Attachment.count' do
|
||||||
put :update, :id => 1,
|
put :update, :params => {
|
||||||
:news => { :description => 'This is the description' },
|
:id => 1,
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
:news => {
|
||||||
|
:description => 'This is the description'
|
||||||
|
},
|
||||||
|
:attachments => {
|
||||||
|
'1' => {
|
||||||
|
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
attachment = Attachment.order('id DESC').first
|
attachment = Attachment.order('id DESC').first
|
||||||
@ -158,14 +204,21 @@ class NewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
put :update, :id => 1, :news => { :description => '' }
|
put :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:news => {
|
||||||
|
:description => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /description cannot be blank/i
|
assert_select_error /description cannot be blank/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/news'
|
assert_redirected_to '/projects/ecookbook/news'
|
||||||
assert_nil News.find_by_id(1)
|
assert_nil News.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -30,7 +30,12 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview_new_issue
|
def test_preview_new_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :issue => {:description => 'Foo'}
|
post :issue, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:issue => {
|
||||||
|
:description => 'Foo'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'fieldset' do
|
assert_select 'fieldset' do
|
||||||
assert_select 'legend', :text => 'Description'
|
assert_select 'legend', :text => 'Description'
|
||||||
@ -40,8 +45,14 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview_issue_notes_with_no_change_to_description
|
def test_preview_issue_notes_with_no_change_to_description
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :id => 1,
|
post :issue, :params => {
|
||||||
:issue => {:description => Issue.find(1).description, :notes => 'Foo'}
|
:project_id => '1',
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:description => Issue.find(1).description,
|
||||||
|
:notes => 'Foo'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'legend', :text => 'Description', :count => 0
|
assert_select 'legend', :text => 'Description', :count => 0
|
||||||
assert_select 'legend', :text => 'Notes'
|
assert_select 'legend', :text => 'Notes'
|
||||||
@ -49,8 +60,14 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview_issue_notes_with_change_to_description
|
def test_preview_issue_notes_with_change_to_description
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :id => 1,
|
post :issue, :params => {
|
||||||
:issue => {:description => 'Changed description', :notes => 'Foo'}
|
:project_id => '1',
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:description => 'Changed description',
|
||||||
|
:notes => 'Foo'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'legend', :text => 'Description'
|
assert_select 'legend', :text => 'Description'
|
||||||
assert_select 'legend', :text => 'Notes'
|
assert_select 'legend', :text => 'Notes'
|
||||||
@ -58,7 +75,13 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview_journal_notes_for_update
|
def test_preview_journal_notes_for_update
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :id => 1, :journal => {:notes => 'Foo'}
|
post :issue, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:id => 1,
|
||||||
|
:journal => {
|
||||||
|
:notes => 'Foo'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'legend', :text => 'Notes'
|
assert_select 'legend', :text => 'Notes'
|
||||||
assert_select 'p', :text => 'Foo'
|
assert_select 'p', :text => 'Foo'
|
||||||
@ -67,32 +90,54 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
|||||||
def test_preview_issue_notes_should_support_links_to_existing_attachments
|
def test_preview_issue_notes_should_support_links_to_existing_attachments
|
||||||
Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar')
|
Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar')
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'attachment:foo.bar'}
|
post :issue, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:notes => 'attachment:foo.bar'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a.attachment', :text => 'foo.bar'
|
assert_select 'a.attachment', :text => 'foo.bar'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_issue_with_project_changed
|
def test_preview_issue_with_project_changed
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2}
|
post :issue, :params => {
|
||||||
|
:project_id => '1',
|
||||||
|
:id => 1,
|
||||||
|
:issue => {
|
||||||
|
:notes => 'notes',
|
||||||
|
:project_id => 2
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'legend', :text => 'Notes'
|
assert_select 'legend', :text => 'Notes'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_new_news
|
def test_preview_new_news
|
||||||
get :news, :project_id => 1,
|
get :news, :params => {
|
||||||
:news => {:title => '',
|
:project_id => 1,
|
||||||
|
:news => {
|
||||||
|
:title => '',
|
||||||
:description => 'News description',
|
:description => 'News description',
|
||||||
:summary => ''}
|
:summary => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'fieldset.preview', :text => /News description/
|
assert_select 'fieldset.preview', :text => /News description/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_existing_news
|
def test_preview_existing_news
|
||||||
get :news, :project_id => 1, :id => 2,
|
get :news, :params => {
|
||||||
:news => {:title => '',
|
:project_id => 1,
|
||||||
|
:id => 2,
|
||||||
|
:news => {
|
||||||
|
:title => '',
|
||||||
:description => 'News description',
|
:description => 'News description',
|
||||||
:summary => ''}
|
:summary => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'fieldset.preview', :text => /News description/
|
assert_select 'fieldset.preview', :text => /News description/
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,7 +25,9 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_new_user_membership
|
def test_new_user_membership
|
||||||
get :new, :user_id => 7
|
get :new, :params => {
|
||||||
|
:user_id => 7
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'label', :text => 'eCookbook' do
|
assert_select 'label', :text => 'eCookbook' do
|
||||||
assert_select 'input[name=?][value="1"]:not([disabled])', 'membership[project_ids][]'
|
assert_select 'input[name=?][value="1"]:not([disabled])', 'membership[project_ids][]'
|
||||||
@ -35,7 +37,9 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
def test_new_user_membership_should_disable_user_projects
|
def test_new_user_membership_should_disable_user_projects
|
||||||
Member.create!(:user_id => 7, :project_id => 1, :role_ids => [1])
|
Member.create!(:user_id => 7, :project_id => 1, :role_ids => [1])
|
||||||
|
|
||||||
get :new, :user_id => 7
|
get :new, :params => {
|
||||||
|
:user_id => 7
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'label', :text => 'eCookbook' do
|
assert_select 'label', :text => 'eCookbook' do
|
||||||
assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]'
|
assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]'
|
||||||
@ -43,14 +47,23 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_new_user_membership
|
def test_xhr_new_user_membership
|
||||||
xhr :get, :new, :user_id => 7
|
get :new, :params => {
|
||||||
|
:user_id => 7
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_user_membership
|
def test_create_user_membership
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}
|
post :create, :params => {
|
||||||
|
:user_id => 7,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [3],
|
||||||
|
:role_ids => [2]
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/users/7/edit?tab=memberships'
|
assert_redirected_to '/users/7/edit?tab=memberships'
|
||||||
member = Member.order('id DESC').first
|
member = Member.order('id DESC').first
|
||||||
@ -61,7 +74,13 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_user_membership_with_multiple_roles
|
def test_create_user_membership_with_multiple_roles
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2, 3]}
|
post :create, :params => {
|
||||||
|
:user_id => 7,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [3],
|
||||||
|
:role_ids => [2, 3]
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
member = Member.order('id DESC').first
|
member = Member.order('id DESC').first
|
||||||
assert_equal User.find(7), member.principal
|
assert_equal User.find(7), member.principal
|
||||||
@ -71,7 +90,13 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_user_membership_with_multiple_projects_and_roles
|
def test_create_user_membership_with_multiple_projects_and_roles
|
||||||
assert_difference 'Member.count', 2 do
|
assert_difference 'Member.count', 2 do
|
||||||
post :create, :user_id => 7, :membership => {:project_ids => [1, 3], :role_ids => [2, 3]}
|
post :create, :params => {
|
||||||
|
:user_id => 7,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [1, 3],
|
||||||
|
:role_ids => [2, 3]
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
members = Member.order('id DESC').limit(2).sort_by(&:project_id)
|
members = Member.order('id DESC').limit(2).sort_by(&:project_id)
|
||||||
assert_equal 1, members[0].project_id
|
assert_equal 1, members[0].project_id
|
||||||
@ -84,7 +109,15 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_create_user_membership
|
def test_xhr_create_user_membership
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}, :format => 'js'
|
post :create, :params => {
|
||||||
|
:user_id => 7,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [3],
|
||||||
|
:role_ids => [2]
|
||||||
|
},
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -97,7 +130,14 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_create_user_membership_with_failure
|
def test_xhr_create_user_membership_with_failure
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3]}, :format => 'js'
|
post :create, :params => {
|
||||||
|
:user_id => 7,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [3]
|
||||||
|
},
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -106,19 +146,32 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_user_membership
|
def test_edit_user_membership
|
||||||
get :edit, :user_id => 2, :id => 1
|
get :edit, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '1'
|
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_edit_user_membership
|
def test_xhr_edit_user_membership
|
||||||
xhr :get, :edit, :user_id => 2, :id => 1
|
get :edit, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_user_membership
|
def test_update_user_membership
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
put :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}
|
put :update, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [2]
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/users/2/edit?tab=memberships'
|
assert_redirected_to '/users/2/edit?tab=memberships'
|
||||||
end
|
end
|
||||||
assert_equal [2], Member.find(1).role_ids
|
assert_equal [2], Member.find(1).role_ids
|
||||||
@ -126,7 +179,15 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_update_user_membership
|
def test_xhr_update_user_membership
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
xhr :put, :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}, :format => 'js'
|
put :update, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => [2]
|
||||||
|
},
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -136,7 +197,10 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_user_membership
|
def test_destroy_user_membership
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
delete :destroy, :user_id => 2, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/users/2/edit?tab=memberships'
|
assert_redirected_to '/users/2/edit?tab=memberships'
|
||||||
assert_nil Member.find_by_id(1)
|
assert_nil Member.find_by_id(1)
|
||||||
@ -144,7 +208,11 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_destroy_user_membership_js_format
|
def test_xhr_destroy_user_membership_js_format
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
xhr :delete, :destroy, :user_id => 2, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:user_id => 2,
|
||||||
|
:id => 1
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -153,20 +221,36 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_new_group_membership
|
def test_xhr_new_group_membership
|
||||||
xhr :get, :new, :group_id => 10
|
get :new, :params => {
|
||||||
|
:group_id => 10
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_group_membership
|
def test_create_group_membership
|
||||||
assert_difference 'Group.find(10).members.count' do
|
assert_difference 'Group.find(10).members.count' do
|
||||||
post :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']}
|
post :create, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [2],
|
||||||
|
:role_ids => ['1', '2']
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_create_group_membership
|
def test_xhr_create_group_membership
|
||||||
assert_difference 'Group.find(10).members.count' do
|
assert_difference 'Group.find(10).members.count' do
|
||||||
xhr :post, :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']}
|
post :create, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [2],
|
||||||
|
:role_ids => ['1', '2']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -175,7 +259,14 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_xhr_create_group_membership_with_failure
|
def test_xhr_create_group_membership_with_failure
|
||||||
assert_no_difference 'Group.find(10).members.count' do
|
assert_no_difference 'Group.find(10).members.count' do
|
||||||
xhr :post, :create, :group_id => 10, :membership => {:project_ids => [999], :role_ids => ['1', '2']}
|
post :create, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:membership => {
|
||||||
|
:project_ids => [999],
|
||||||
|
:role_ids => ['1', '2']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -184,13 +275,26 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_group_membership
|
def test_update_group_membership
|
||||||
assert_no_difference 'Group.find(10).members.count' do
|
assert_no_difference 'Group.find(10).members.count' do
|
||||||
put :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']}
|
put :update, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:id => 6,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => ['1', '3']
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_update_group_membership
|
def test_xhr_update_group_membership
|
||||||
assert_no_difference 'Group.find(10).members.count' do
|
assert_no_difference 'Group.find(10).members.count' do
|
||||||
xhr :post, :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']}
|
post :update, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:id => 6,
|
||||||
|
:membership => {
|
||||||
|
:role_ids => ['1', '3']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -198,13 +302,20 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_destroy_group_membership
|
def test_destroy_group_membership
|
||||||
assert_difference 'Group.find(10).members.count', -1 do
|
assert_difference 'Group.find(10).members.count', -1 do
|
||||||
delete :destroy, :group_id => 10, :id => 6
|
delete :destroy, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:id => 6
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_xhr_destroy_group_membership
|
def test_xhr_destroy_group_membership
|
||||||
assert_difference 'Group.find(10).members.count', -1 do
|
assert_difference 'Group.find(10).members.count', -1 do
|
||||||
xhr :delete, :destroy, :group_id => 10, :id => 6
|
delete :destroy, :params => {
|
||||||
|
:group_id => 10,
|
||||||
|
:id => 6
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,12 +40,15 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
|
billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
|
||||||
|
|
||||||
put :update, :project_id => 1, :enumerations => {
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:enumerations => {
|
||||||
"9"=> {"parent_id"=>"9", "custom_field_values"=> {"7" => "1"}, "active"=>"0"}, # Design, De-activate
|
"9"=> {"parent_id"=>"9", "custom_field_values"=> {"7" => "1"}, "active"=>"0"}, # Design, De-activate
|
||||||
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value
|
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value
|
||||||
"14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value
|
"14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value
|
||||||
"11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes
|
"11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||||
@ -105,10 +108,13 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
assert project_activity_two.save
|
assert project_activity_two.save
|
||||||
|
|
||||||
|
|
||||||
put :update, :project_id => 1, :enumerations => {
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:enumerations => {
|
||||||
project_activity.id => {"custom_field_values"=> {"7" => "1"}, "active"=>"0"}, # De-activate
|
project_activity.id => {"custom_field_values"=> {"7" => "1"}, "active"=>"0"}, # De-activate
|
||||||
project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate
|
project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||||
@ -132,8 +138,14 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 3, TimeEntry.where(:activity_id => 9, :project_id => 1).count
|
assert_equal 3, TimeEntry.where(:activity_id => 9, :project_id => 1).count
|
||||||
|
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
put :update, :project_id => 1, :enumerations => {
|
put :update, :params => {
|
||||||
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate
|
:project_id => 1,
|
||||||
|
:enumerations => {
|
||||||
|
"9"=> {
|
||||||
|
"parent_id"=>"9", "custom_field_values"=> {
|
||||||
|
"7" => "1"}, "active"=>"0"} # Design, De-activate
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
|
|
||||||
@ -160,12 +172,15 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 1, TimeEntry.where(:activity_id => 10, :project_id => 1).count
|
assert_equal 1, TimeEntry.where(:activity_id => 10, :project_id => 1).count
|
||||||
|
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
put :update, :project_id => 1, :enumerations => {
|
put :update, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:enumerations => {
|
||||||
# Design
|
# Design
|
||||||
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"},
|
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"},
|
||||||
# Development, Change custom value
|
# Development, Change custom value
|
||||||
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}
|
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
|
|
||||||
# TimeEntries shouldn't have been reassigned on the failed record
|
# TimeEntries shouldn't have been reassigned on the failed record
|
||||||
@ -195,7 +210,9 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
})
|
})
|
||||||
assert project_activity_two.save
|
assert project_activity_two.save
|
||||||
|
|
||||||
delete :destroy, :project_id => 1
|
delete :destroy, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||||
|
|
||||||
@ -216,7 +233,9 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||||||
update_all("activity_id = '#{project_activity.id}'")
|
update_all("activity_id = '#{project_activity.id}'")
|
||||||
assert_equal 3, TimeEntry.where(:activity_id => project_activity.id,
|
assert_equal 3, TimeEntry.where(:activity_id => project_activity.id,
|
||||||
:project_id => 1).count
|
:project_id => 1).count
|
||||||
delete :destroy, :project_id => 1
|
delete :destroy, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||||
|
|
||||||
|
|||||||
@ -46,14 +46,20 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_atom
|
def test_index_atom
|
||||||
get :index, :format => 'atom'
|
get :index, :params => {
|
||||||
|
:format => 'atom'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_autocomplete_js
|
def test_autocomplete_js
|
||||||
xhr :get, :autocomplete, :format => 'js', :q => 'coo'
|
get :autocomplete, :params => {
|
||||||
|
:format => 'js',
|
||||||
|
:q => 'coo'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -106,7 +112,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(1).add_permission! :add_subprojects
|
Role.find(1).add_permission! :add_subprojects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :new, :parent_id => 'ecookbook'
|
get :new, :params => {
|
||||||
|
:parent_id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'project[parent_id]' do
|
assert_select 'select[name=?]', 'project[parent_id]' do
|
||||||
@ -145,19 +153,22 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
test "#create by admin user should create a new project" do
|
test "#create by admin user should create a new project" do
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project => {
|
:project => {
|
||||||
:name => "blog",
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:homepage => 'http://weblog',
|
:homepage => 'http://weblog',
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:tracker_ids => ['1', '3'],
|
:tracker_ids => ['1', '3'],
|
||||||
# an issue custom field that is not for all project
|
# an issue custom field that is not for all project
|
||||||
:issue_custom_field_ids => ['9'],
|
:issue_custom_field_ids => ['9'],
|
||||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/blog/settings'
|
assert_redirected_to '/projects/blog/settings'
|
||||||
|
|
||||||
project = Project.find_by_name('blog')
|
project = Project.find_by_name('blog')
|
||||||
@ -177,12 +188,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
assert_difference 'Project.count' do
|
assert_difference 'Project.count' do
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:parent_id => 1
|
:parent_id => 1
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_redirected_to '/projects/blog/settings'
|
assert_redirected_to '/projects/blog/settings'
|
||||||
end
|
end
|
||||||
@ -196,7 +213,13 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
assert_difference 'Project.count' do
|
assert_difference 'Project.count' do
|
||||||
post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue'
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
|
:identifier => "blog"
|
||||||
|
},
|
||||||
|
:continue => 'Create and continue'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_redirected_to '/projects/new'
|
assert_redirected_to '/projects/new'
|
||||||
end
|
end
|
||||||
@ -205,13 +228,19 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Role.non_member.add_permission! :add_project
|
Role.non_member.add_permission! :add_project
|
||||||
@request.session[:user_id] = 9
|
@request.session[:user_id] = 9
|
||||||
|
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:tracker_ids => ['1', '3'],
|
:tracker_ids => ['1', '3'],
|
||||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_redirected_to '/projects/blog/settings'
|
assert_redirected_to '/projects/blog/settings'
|
||||||
@ -234,12 +263,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 9
|
@request.session[:user_id] = 9
|
||||||
|
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:parent_id => 1
|
:parent_id => 1
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -251,12 +286,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(1).add_permission! :add_subprojects
|
Role.find(1).add_permission! :add_subprojects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:parent_id => 1
|
:parent_id => 1
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_redirected_to '/projects/blog/settings'
|
assert_redirected_to '/projects/blog/settings'
|
||||||
project = Project.find_by_name('blog')
|
project = Project.find_by_name('blog')
|
||||||
@ -269,11 +310,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' }
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -287,12 +334,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
assert !User.find(2).member_of?(Project.find(6))
|
assert !User.find(2).member_of?(Project.find(6))
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
post :create, :project => { :name => "blog",
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
|
:name => "blog",
|
||||||
:description => "weblog",
|
:description => "weblog",
|
||||||
:identifier => "blog",
|
:identifier => "blog",
|
||||||
:is_public => 1,
|
:is_public => 1,
|
||||||
:custom_field_values => { '3' => 'Beta' },
|
:custom_field_values => {
|
||||||
|
'3' => 'Beta'
|
||||||
|
},
|
||||||
:parent_id => 6
|
:parent_id => 6
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -307,20 +360,26 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
with_settings :new_project_user_role_id => default_role.id.to_s, :default_projects_modules => %w(news files) do
|
with_settings :new_project_user_role_id => default_role.id.to_s, :default_projects_modules => %w(news files) do
|
||||||
project = new_record(Project) do
|
project = new_record(Project) do
|
||||||
post :create, :project => {
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
:name => "blog1",
|
:name => "blog1",
|
||||||
:identifier => "blog1",
|
:identifier => "blog1",
|
||||||
:enabled_module_names => ["issue_tracking", "repository"]
|
:enabled_module_names => ["issue_tracking", "repository"]
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_equal %w(files news), project.enabled_module_names.sort
|
assert_equal %w(files news), project.enabled_module_names.sort
|
||||||
|
|
||||||
default_role.add_permission!(:select_project_modules)
|
default_role.add_permission!(:select_project_modules)
|
||||||
project = new_record(Project) do
|
project = new_record(Project) do
|
||||||
post :create, :project => {
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
:name => "blog2",
|
:name => "blog2",
|
||||||
:identifier => "blog2",
|
:identifier => "blog2",
|
||||||
:enabled_module_names => ["issue_tracking", "repository"]
|
:enabled_module_names => ["issue_tracking", "repository"]
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_equal %w(issue_tracking repository), project.enabled_module_names.sort
|
assert_equal %w(issue_tracking repository), project.enabled_module_names.sort
|
||||||
@ -333,8 +392,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'Project.count' do
|
assert_difference 'Project.count' do
|
||||||
post :create, :project => {
|
post :create, :params => {
|
||||||
:name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1'
|
:project => {
|
||||||
|
:name => 'inherited',
|
||||||
|
:identifier => 'inherited',
|
||||||
|
:parent_id => parent.id,
|
||||||
|
:inherit_members => '1'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
@ -350,10 +415,13 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
|
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
post :create, :project => {
|
post :create, :params => {
|
||||||
|
:project => {
|
||||||
:name => "blog",
|
:name => "blog",
|
||||||
:identifier => "",
|
:identifier => "",
|
||||||
:enabled_module_names => %w(issue_tracking news)
|
:enabled_module_names => %w(issue_tracking news)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -365,13 +433,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_by_id
|
def test_show_by_id
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '#header h1', :text => "eCookbook"
|
assert_select '#header h1', :text => "eCookbook"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_by_identifier
|
def test_show_by_identifier
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '#header h1', :text => "eCookbook"
|
assert_select '#header h1', :text => "eCookbook"
|
||||||
end
|
end
|
||||||
@ -381,14 +453,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
p.enabled_module_names = []
|
p.enabled_module_names = []
|
||||||
p.save!
|
p.save!
|
||||||
|
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '#main.nosidebar'
|
assert_select '#main.nosidebar'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_display_visible_custom_fields
|
def test_show_should_display_visible_custom_fields
|
||||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
|
ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'li', :text => /Development status/
|
assert_select 'li', :text => /Development status/
|
||||||
@ -396,7 +472,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_should_not_display_hidden_custom_fields
|
def test_show_should_not_display_hidden_custom_fields
|
||||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'li', :text => /Development status/, :count => 0
|
assert_select 'li', :text => /Development status/, :count => 0
|
||||||
@ -407,7 +485,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
f2 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Baz Qux), :multiple => true
|
f2 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Baz Qux), :multiple => true
|
||||||
project = Project.generate!(:custom_field_values => {f2.id.to_s => %w(Qux)})
|
project = Project.generate!(:custom_field_values => {f2.id.to_s => %w(Qux)})
|
||||||
|
|
||||||
get :show, :id => project.id
|
get :show, :params => {
|
||||||
|
:id => project.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'li', :text => /#{f1.name}/, :count => 0
|
assert_select 'li', :text => /#{f1.name}/, :count => 0
|
||||||
@ -417,7 +497,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_show_should_not_display_blank_text_custom_fields
|
def test_show_should_not_display_blank_text_custom_fields
|
||||||
f1 = ProjectCustomField.generate! :field_format => 'text'
|
f1 = ProjectCustomField.generate! :field_format => 'text'
|
||||||
|
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'li', :text => /#{f1.name}/, :count => 0
|
assert_select 'li', :text => /#{f1.name}/, :count => 0
|
||||||
@ -426,7 +508,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_show_should_not_fail_when_custom_values_are_nil
|
def test_show_should_not_fail_when_custom_values_are_nil
|
||||||
project = Project.find_by_identifier('ecookbook')
|
project = Project.find_by_identifier('ecookbook')
|
||||||
project.custom_values.first.update_attribute(:value, nil)
|
project.custom_values.first.update_attribute(:value, nil)
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -434,28 +518,36 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
project = Project.find_by_identifier('ecookbook')
|
project = Project.find_by_identifier('ecookbook')
|
||||||
project.archive!
|
project.archive!
|
||||||
|
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
assert_select 'p', :text => /archived/
|
assert_select 'p', :text => /archived/
|
||||||
assert_not_include project.name, response.body
|
assert_not_include project.name, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_not_show_private_subprojects_that_are_not_visible
|
def test_show_should_not_show_private_subprojects_that_are_not_visible
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a', :text => /Private child/, :count => 0
|
assert_select 'a', :text => /Private child/, :count => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_should_show_private_subprojects_that_are_visible
|
def test_show_should_show_private_subprojects_that_are_visible
|
||||||
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
||||||
get :show, :id => 'ecookbook'
|
get :show, :params => {
|
||||||
|
:id => 'ecookbook'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a', :text => /Private child/
|
assert_select 'a', :text => /Private child/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_settings
|
def test_settings
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
get :settings, :id => 1
|
get :settings, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?]', 'project[name]'
|
assert_select 'input[name=?]', 'project[name]'
|
||||||
@ -463,7 +555,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_settings_of_subproject
|
def test_settings_of_subproject
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :settings, :id => 'private-child'
|
get :settings, :params => {
|
||||||
|
:id => 'private-child'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
|
assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
|
||||||
@ -473,14 +567,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
|
|
||||||
get :settings, :id => 1
|
get :settings, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_settings_should_be_denied_for_anonymous_on_closed_project
|
def test_settings_should_be_denied_for_anonymous_on_closed_project
|
||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
|
|
||||||
get :settings, :id => 1
|
get :settings, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -489,7 +587,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(1).add_permission! :manage_wiki
|
Role.find(1).add_permission! :manage_wiki
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :settings, :id => 1
|
get :settings, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
||||||
@ -500,7 +600,11 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_settings_should_accept_version_status_filter
|
def test_settings_should_accept_version_status_filter
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => 'locked'
|
get :settings, :params => {
|
||||||
|
:id => 'ecookbook',
|
||||||
|
:tab => 'versions',
|
||||||
|
:version_status => 'locked'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=version_status]' do
|
assert_select 'select[name=version_status]' do
|
||||||
@ -516,7 +620,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_settings_should_accept_version_name_filter
|
def test_settings_should_accept_version_name_filter
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => '', :version_name => '.1'
|
get :settings, :params => {
|
||||||
|
:id => 'ecookbook',
|
||||||
|
:tab => 'versions',
|
||||||
|
:version_status => '',
|
||||||
|
:version_name => '.1'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=version_name][value=?]', '.1'
|
assert_select 'input[name=version_name][value=?]', '.1'
|
||||||
@ -534,15 +643,23 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
assert user.reload.locked?
|
assert user.reload.locked?
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :settings, :id => 'ecookbook', :tab => 'members'
|
get :settings, :params => {
|
||||||
|
:id => 'ecookbook',
|
||||||
|
:tab => 'members'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "tr#member-#{member.id}"
|
assert_select "tr#member-#{member.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
post :update, :id => 1, :project => {:name => 'Test changed name',
|
post :update, :params => {
|
||||||
:issue_custom_field_ids => ['']}
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => 'Test changed name',
|
||||||
|
:issue_custom_field_ids => ['']
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings'
|
assert_redirected_to '/projects/ecookbook/settings'
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
assert_equal 'Test changed name', project.name
|
assert_equal 'Test changed name', project.name
|
||||||
@ -550,7 +667,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
post :update, :id => 1, :project => {:name => ''}
|
post :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /name cannot be blank/i
|
assert_select_error /name cannot be blank/i
|
||||||
end
|
end
|
||||||
@ -559,7 +681,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
|
|
||||||
post :update, :id => 1, :project => {:name => 'Closed'}
|
post :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => 'Closed'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 403
|
assert_response 403
|
||||||
assert_equal 'eCookbook', Project.find(1).name
|
assert_equal 'eCookbook', Project.find(1).name
|
||||||
end
|
end
|
||||||
@ -567,7 +694,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_update_should_be_denied_for_anonymous_on_closed_project
|
def test_update_should_be_denied_for_anonymous_on_closed_project
|
||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
|
|
||||||
post :update, :id => 1, :project => {:name => 'Closed'}
|
post :update, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => 'Closed'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_equal 'eCookbook', Project.find(1).name
|
assert_equal 'eCookbook', Project.find(1).name
|
||||||
end
|
end
|
||||||
@ -578,7 +710,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project]))
|
User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project]))
|
||||||
@request.session[:user_id] = user.id
|
@request.session[:user_id] = user.id
|
||||||
|
|
||||||
post :update, :id => child.id, :project => {:name => 'Updated'}
|
post :update, :params => {
|
||||||
|
:id => child.id,
|
||||||
|
:project => {
|
||||||
|
:name => 'Updated'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_match /Successful update/, flash[:notice]
|
assert_match /Successful update/, flash[:notice]
|
||||||
end
|
end
|
||||||
@ -587,7 +724,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
Project.find(1).enabled_module_names = ['issue_tracking', 'news']
|
Project.find(1).enabled_module_names = ['issue_tracking', 'news']
|
||||||
|
|
||||||
post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents']
|
post :modules, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:enabled_module_names => ['issue_tracking', 'repository', 'documents']
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/settings/modules'
|
assert_redirected_to '/projects/ecookbook/settings/modules'
|
||||||
assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
|
assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
|
||||||
end
|
end
|
||||||
@ -596,7 +736,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
|
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
delete :destroy, :id => 2
|
delete :destroy, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
assert_select '.warning', :text => /Are you sure you want to delete this project/
|
assert_select '.warning', :text => /Are you sure you want to delete this project/
|
||||||
@ -606,7 +748,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
|
|
||||||
assert_no_difference 'Project.count' do
|
assert_no_difference 'Project.count' do
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
assert_select 'strong',
|
assert_select 'strong',
|
||||||
@ -619,7 +763,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
|
|
||||||
assert_difference 'Project.count', -5 do
|
assert_difference 'Project.count', -5 do
|
||||||
delete :destroy, :id => 1, :confirm => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:confirm => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/admin/projects'
|
assert_redirected_to '/admin/projects'
|
||||||
end
|
end
|
||||||
assert_nil Project.find_by_id(1)
|
assert_nil Project.find_by_id(1)
|
||||||
@ -627,7 +774,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_archive
|
def test_archive
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
post :archive, :id => 1
|
post :archive, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/admin/projects'
|
assert_redirected_to '/admin/projects'
|
||||||
assert !Project.find(1).active?
|
assert !Project.find(1).active?
|
||||||
end
|
end
|
||||||
@ -635,7 +784,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_archive_with_failure
|
def test_archive_with_failure
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
Project.any_instance.stubs(:archive).returns(false)
|
Project.any_instance.stubs(:archive).returns(false)
|
||||||
post :archive, :id => 1
|
post :archive, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/admin/projects'
|
assert_redirected_to '/admin/projects'
|
||||||
assert_match /project cannot be archived/i, flash[:error]
|
assert_match /project cannot be archived/i, flash[:error]
|
||||||
end
|
end
|
||||||
@ -643,14 +794,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_unarchive
|
def test_unarchive
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
Project.find(1).archive
|
Project.find(1).archive
|
||||||
post :unarchive, :id => 1
|
post :unarchive, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/admin/projects'
|
assert_redirected_to '/admin/projects'
|
||||||
assert Project.find(1).active?
|
assert Project.find(1).active?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_close
|
def test_close
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :close, :id => 1
|
post :close, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook'
|
assert_redirected_to '/projects/ecookbook'
|
||||||
assert_equal Project::STATUS_CLOSED, Project.find(1).status
|
assert_equal Project::STATUS_CLOSED, Project.find(1).status
|
||||||
end
|
end
|
||||||
@ -658,7 +813,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
def test_reopen
|
def test_reopen
|
||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :reopen, :id => 1
|
post :reopen, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook'
|
assert_redirected_to '/projects/ecookbook'
|
||||||
assert Project.find(1).active?
|
assert Project.find(1).active?
|
||||||
end
|
end
|
||||||
@ -668,7 +825,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
parent = nil
|
parent = nil
|
||||||
6.times do |i|
|
6.times do |i|
|
||||||
p = Project.generate_with_parent!(parent)
|
p = Project.generate_with_parent!(parent)
|
||||||
get :show, :id => p
|
get :show, :params => {
|
||||||
|
:id => p
|
||||||
|
}
|
||||||
assert_select '#header h1' do
|
assert_select '#header h1' do
|
||||||
assert_select 'a', :count => [i, 3].min
|
assert_select 'a', :count => [i, 3].min
|
||||||
end
|
end
|
||||||
@ -681,7 +840,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
orig = Project.find(1)
|
orig = Project.find(1)
|
||||||
|
|
||||||
get :copy, :id => orig.id
|
get :copy, :params => {
|
||||||
|
:id => orig.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'textarea[name=?]', 'project[description]', :text => orig.description
|
assert_select 'textarea[name=?]', 'project[description]', :text => orig.description
|
||||||
@ -690,7 +851,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_get_copy_with_invalid_source_should_respond_with_404
|
def test_get_copy_with_invalid_source_should_respond_with_404
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :copy, :id => 99
|
get :copy, :params => {
|
||||||
|
:id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -700,7 +863,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
source = Project.generate!(:issue_custom_fields => [field1])
|
source = Project.generate!(:issue_custom_fields => [field1])
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
get :copy, :id => source.id
|
get :copy, :params => {
|
||||||
|
:id => source.id
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'fieldset#project_issue_custom_fields' do
|
assert_select 'fieldset#project_issue_custom_fields' do
|
||||||
assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s
|
assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s
|
||||||
@ -713,14 +878,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
CustomField.delete_all
|
CustomField.delete_all
|
||||||
|
|
||||||
assert_difference 'Project.count' do
|
assert_difference 'Project.count' do
|
||||||
post :copy, :id => 1,
|
post :copy, :params => {
|
||||||
|
:id => 1,
|
||||||
:project => {
|
:project => {
|
||||||
:name => 'Copy',
|
:name => 'Copy',
|
||||||
:identifier => 'unique-copy',
|
:identifier => 'unique-copy',
|
||||||
:tracker_ids => ['1', '2', '3', ''],
|
:tracker_ids => ['1', '2', '3', ''],
|
||||||
:enabled_module_names => %w(issue_tracking time_tracking)
|
:enabled_module_names => %w(issue_tracking time_tracking)
|
||||||
|
|
||||||
},
|
},
|
||||||
:only => %w(issues versions)
|
:only => %w(issues versions)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
project = Project.find('unique-copy')
|
project = Project.find('unique-copy')
|
||||||
source = Project.find(1)
|
source = Project.find(1)
|
||||||
@ -733,45 +901,72 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_post_copy_should_redirect_to_settings_when_successful
|
def test_post_copy_should_redirect_to_settings_when_successful
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
|
post :copy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => 'Copy',
|
||||||
|
:identifier => 'unique-copy'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
|
assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_copy_with_failure
|
def test_post_copy_with_failure
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''}
|
post :copy, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:project => {
|
||||||
|
:name => 'Copy',
|
||||||
|
:identifier => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Identifier cannot be blank/
|
assert_select_error /Identifier cannot be blank/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_jump_without_project_id_should_redirect_to_active_tab
|
def test_jump_without_project_id_should_redirect_to_active_tab
|
||||||
get :index, :jump => 'issues'
|
get :index, :params => {
|
||||||
|
:jump => 'issues'
|
||||||
|
}
|
||||||
assert_redirected_to '/issues'
|
assert_redirected_to '/issues'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_jump_should_not_redirect_to_unknown_tab
|
def test_jump_should_not_redirect_to_unknown_tab
|
||||||
get :index, :jump => 'foobar'
|
get :index, :params => {
|
||||||
|
:jump => 'foobar'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_jump_should_redirect_to_active_tab
|
def test_jump_should_redirect_to_active_tab
|
||||||
get :show, :id => 1, :jump => 'issues'
|
get :show, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:jump => 'issues'
|
||||||
|
}
|
||||||
assert_redirected_to '/projects/ecookbook/issues'
|
assert_redirected_to '/projects/ecookbook/issues'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_jump_should_not_redirect_to_inactive_tab
|
def test_jump_should_not_redirect_to_inactive_tab
|
||||||
get :show, :id => 3, :jump => 'documents'
|
get :show, :params => {
|
||||||
|
:id => 3,
|
||||||
|
:jump => 'documents'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_jump_should_not_redirect_to_unknown_tab
|
def test_jump_should_not_redirect_to_unknown_tab
|
||||||
get :show, :id => 3, :jump => 'foobar'
|
get :show, :params => {
|
||||||
|
:id => 3,
|
||||||
|
:jump => 'foobar'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_body_should_have_project_css_class
|
def test_body_should_have_project_css_class
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_select 'body.project-ecookbook'
|
assert_select 'body.project-ecookbook'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,7 +37,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new_project_query
|
def test_new_project_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1
|
get :new, :params => {
|
||||||
|
:project_id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
|
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
|
||||||
@ -59,26 +61,38 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new_on_invalid_project
|
def test_new_on_invalid_project
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 'invalid'
|
get :new, :params => {
|
||||||
|
:project_id => 'invalid'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_time_entry_query
|
def test_new_time_entry_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :project_id => 1, :type => 'TimeEntryQuery'
|
get :new, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:type => 'TimeEntryQuery'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=type][value=?]', 'TimeEntryQuery'
|
assert_select 'input[name=type][value=?]', 'TimeEntryQuery'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_project_public_query
|
def test_create_project_public_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:f => ["status_id", "assigned_to_id"],
|
:f => ["status_id", "assigned_to_id"],
|
||||||
:op => {"assigned_to_id" => "=", "status_id" => "o"},
|
:op => {
|
||||||
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_new_project_public_query", "visibility" => "2"}
|
},
|
||||||
|
:v => {
|
||||||
|
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
q = Query.find_by_name('test_new_project_public_query')
|
q = Query.find_by_name('test_new_project_public_query')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
||||||
@ -89,13 +103,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_project_private_query
|
def test_create_project_private_query
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:fields => ["status_id", "assigned_to_id"],
|
:fields => ["status_id", "assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_new_project_private_query", "visibility" => "0"}
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_new_project_private_query", "visibility" => "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
q = Query.find_by_name('test_new_project_private_query')
|
q = Query.find_by_name('test_new_project_private_query')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
||||||
@ -106,13 +127,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_project_roles_query
|
def test_create_project_roles_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:fields => ["status_id", "assigned_to_id"],
|
:fields => ["status_id", "assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]}
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
q = Query.find_by_name('test_create_project_roles_query')
|
q = Query.find_by_name('test_create_project_roles_query')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
||||||
@ -122,12 +150,19 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_global_private_query_with_custom_columns
|
def test_create_global_private_query_with_custom_columns
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:fields => ["status_id", "assigned_to_id"],
|
:fields => ["status_id", "assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_new_global_private_query", "visibility" => "0"},
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["me"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_new_global_private_query", "visibility" => "0"
|
||||||
|
},
|
||||||
:c => ["", "tracker", "subject", "priority", "category"]
|
:c => ["", "tracker", "subject", "priority", "category"]
|
||||||
|
}
|
||||||
|
|
||||||
q = Query.find_by_name('test_new_global_private_query')
|
q = Query.find_by_name('test_new_global_private_query')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
|
||||||
@ -139,11 +174,18 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_global_query_with_custom_filters
|
def test_create_global_query_with_custom_filters
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:fields => ["assigned_to_id"],
|
:fields => ["assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "="},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["me"]},
|
"assigned_to_id" => "="
|
||||||
:query => {"name" => "test_new_global_query"}
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["me"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_new_global_query"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
q = Query.find_by_name('test_new_global_query')
|
q = Query.find_by_name('test_new_global_query')
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
|
||||||
@ -155,13 +197,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_create_with_sort
|
def test_create_with_sort
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:operators => {"status_id" => "o"},
|
:operators => {
|
||||||
:values => {"status_id" => ["1"]},
|
"status_id" => "o"
|
||||||
:query => {:name => "test_new_with_sort",
|
},
|
||||||
|
:values => {
|
||||||
|
"status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
:name => "test_new_with_sort",
|
||||||
:visibility => "2",
|
:visibility => "2",
|
||||||
:sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}}
|
:sort_criteria => {
|
||||||
|
"0" => ["due_date", "desc"], "1" => ["tracker", ""]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query = Query.find_by_name("test_new_with_sort")
|
query = Query.find_by_name("test_new_with_sort")
|
||||||
assert_not_nil query
|
assert_not_nil query
|
||||||
@ -171,7 +221,12 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference '::Query.count' do
|
assert_no_difference '::Query.count' do
|
||||||
post :create, :project_id => 'ecookbook', :query => {:name => ''}
|
post :create, :params => {
|
||||||
|
:project_id => 'ecookbook',
|
||||||
|
:query => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
@ -181,13 +236,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_global_query_from_gantt
|
def test_create_global_query_from_gantt
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'IssueQuery.count' do
|
assert_difference 'IssueQuery.count' do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:gantt => 1,
|
:gantt => 1,
|
||||||
:operators => {"status_id" => "o"},
|
:operators => {
|
||||||
:values => {"status_id" => ["1"]},
|
"status_id" => "o"
|
||||||
:query => {:name => "test_create_from_gantt",
|
},
|
||||||
|
:values => {
|
||||||
|
"status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
:name => "test_create_from_gantt",
|
||||||
:draw_relations => '1',
|
:draw_relations => '1',
|
||||||
:draw_progress_line => '1'}
|
:draw_progress_line => '1'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
query = IssueQuery.order('id DESC').first
|
query = IssueQuery.order('id DESC').first
|
||||||
@ -199,14 +261,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_project_query_from_gantt
|
def test_create_project_query_from_gantt
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'IssueQuery.count' do
|
assert_difference 'IssueQuery.count' do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:gantt => 1,
|
:gantt => 1,
|
||||||
:operators => {"status_id" => "o"},
|
:operators => {
|
||||||
:values => {"status_id" => ["1"]},
|
"status_id" => "o"
|
||||||
:query => {:name => "test_create_from_gantt",
|
},
|
||||||
|
:values => {
|
||||||
|
"status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
:name => "test_create_from_gantt",
|
||||||
:draw_relations => '0',
|
:draw_relations => '0',
|
||||||
:draw_progress_line => '0'}
|
:draw_progress_line => '0'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
query = IssueQuery.order('id DESC').first
|
query = IssueQuery.order('id DESC').first
|
||||||
@ -218,9 +287,12 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
|
def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
query = new_record(Query) do
|
query = new_record(Query) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:query => {"name" => "name", "visibility" => "2"}
|
:query => {
|
||||||
|
"name" => "name", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_not_nil query.project
|
assert_not_nil query.project
|
||||||
@ -230,9 +302,13 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_global_public_query_should_force_private_without_manage_public_queries_permission
|
def test_create_global_public_query_should_force_private_without_manage_public_queries_permission
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
query = new_record(Query) do
|
query = new_record(Query) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
:project_id => 'ecookbook',
|
||||||
:query => {"name" => "name", "visibility" => "2"}
|
:query_is_for_all => '1',
|
||||||
|
:query => {
|
||||||
|
"name" => "name", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_nil query.project
|
assert_nil query.project
|
||||||
@ -242,9 +318,12 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_project_public_query_with_manage_public_queries_permission
|
def test_create_project_public_query_with_manage_public_queries_permission
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
query = new_record(Query) do
|
query = new_record(Query) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:query => {"name" => "name", "visibility" => "2"}
|
:query => {
|
||||||
|
"name" => "name", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_not_nil query.project
|
assert_not_nil query.project
|
||||||
@ -254,9 +333,13 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_global_public_query_should_force_private_with_manage_public_queries_permission
|
def test_create_global_public_query_should_force_private_with_manage_public_queries_permission
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
query = new_record(Query) do
|
query = new_record(Query) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
:project_id => 'ecookbook',
|
||||||
:query => {"name" => "name", "visibility" => "2"}
|
:query_is_for_all => '1',
|
||||||
|
:query => {
|
||||||
|
"name" => "name", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_nil query.project
|
assert_nil query.project
|
||||||
@ -266,9 +349,13 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_global_public_query_by_admin
|
def test_create_global_public_query_by_admin
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
query = new_record(Query) do
|
query = new_record(Query) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
:project_id => 'ecookbook',
|
||||||
:query => {"name" => "name", "visibility" => "2"}
|
:query_is_for_all => '1',
|
||||||
|
:query => {
|
||||||
|
"name" => "name", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
end
|
end
|
||||||
assert_nil query.project
|
assert_nil query.project
|
||||||
@ -279,14 +366,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
q = new_record(TimeEntryQuery) do
|
q = new_record(TimeEntryQuery) do
|
||||||
post :create,
|
post :create, :params => {
|
||||||
:project_id => 'ecookbook',
|
:project_id => 'ecookbook',
|
||||||
:type => 'TimeEntryQuery',
|
:type => 'TimeEntryQuery',
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:f => ["spent_on"],
|
:f => ["spent_on"],
|
||||||
:op => {"spent_on" => "="},
|
:op => {
|
||||||
:v => { "spent_on" => ["2016-07-14"]},
|
"spent_on" => "="
|
||||||
:query => {"name" => "test_new_project_public_query", "visibility" => "2"}
|
},
|
||||||
|
:v => {
|
||||||
|
"spent_on" => ["2016-07-14"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id
|
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id
|
||||||
@ -297,7 +391,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_global_public_query
|
def test_edit_global_public_query
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :edit, :id => 4
|
get :edit, :params => {
|
||||||
|
:id => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||||
@ -306,7 +402,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_global_private_query
|
def test_edit_global_private_query
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
get :edit, :id => 3
|
get :edit, :params => {
|
||||||
|
:id => 3
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||||
@ -315,7 +413,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_project_private_query
|
def test_edit_project_private_query
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
get :edit, :id => 2
|
get :edit, :params => {
|
||||||
|
:id => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||||
@ -324,7 +424,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_project_public_query
|
def test_edit_project_public_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 1
|
get :edit, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||||
@ -333,7 +435,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_sort_criteria
|
def test_edit_sort_criteria
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :edit, :id => 5
|
get :edit, :params => {
|
||||||
|
:id => 5
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
|
assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
|
||||||
@ -344,19 +448,28 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit_invalid_query
|
def test_edit_invalid_query
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 99
|
get :edit, :params => {
|
||||||
|
:id => 99
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_udpate_global_private_query
|
def test_udpate_global_private_query
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => 3,
|
:id => 3,
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:fields => ["status_id", "assigned_to_id"],
|
:fields => ["status_id", "assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_edit_global_private_query", "visibility" => "2"}
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["me"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_edit_global_private_query", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
|
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
|
||||||
q = Query.find_by_name('test_edit_global_private_query')
|
q = Query.find_by_name('test_edit_global_private_query')
|
||||||
@ -367,13 +480,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_global_public_query
|
def test_update_global_public_query
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
put :update,
|
put :update, :params => {
|
||||||
:id => 4,
|
:id => 4,
|
||||||
:default_columns => '1',
|
:default_columns => '1',
|
||||||
:fields => ["status_id", "assigned_to_id"],
|
:fields => ["status_id", "assigned_to_id"],
|
||||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
:operators => {
|
||||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
"assigned_to_id" => "=", "status_id" => "o"
|
||||||
:query => {"name" => "test_edit_global_public_query", "visibility" => "2"}
|
},
|
||||||
|
:values => {
|
||||||
|
"assigned_to_id" => ["1"], "status_id" => ["1"]
|
||||||
|
},
|
||||||
|
:query => {
|
||||||
|
"name" => "test_edit_global_public_query", "visibility" => "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
|
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
|
||||||
q = Query.find_by_name('test_edit_global_public_query')
|
q = Query.find_by_name('test_edit_global_public_query')
|
||||||
@ -384,28 +504,40 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
put :update, :id => 4, :query => {:name => ''}
|
put :update, :params => {
|
||||||
|
:id => 4,
|
||||||
|
:query => {
|
||||||
|
:name => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Name cannot be blank/
|
assert_select_error /Name cannot be blank/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
delete :destroy, :id => 1
|
delete :destroy, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
|
||||||
assert_nil Query.find_by_id(1)
|
assert_nil Query.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_backslash_should_be_escaped_in_filters
|
def test_backslash_should_be_escaped_in_filters
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :new, :subject => 'foo/bar'
|
get :new, :params => {
|
||||||
|
:subject => 'foo/bar'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
|
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_filter_with_project_id_should_return_filter_values
|
def test_filter_with_project_id_should_return_filter_values
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :filter, :project_id => 1, :name => 'fixed_version_id'
|
get :filter, :params => {
|
||||||
|
:project_id => 1,
|
||||||
|
:name => 'fixed_version_id'
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/json', response.content_type
|
assert_equal 'application/json', response.content_type
|
||||||
@ -415,7 +547,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_filter_without_project_id_should_return_filter_values
|
def test_filter_without_project_id_should_return_filter_values
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :filter, :name => 'fixed_version_id'
|
get :filter, :params => {
|
||||||
|
:name => 'fixed_version_id'
|
||||||
|
}
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/json', response.content_type
|
assert_equal 'application/json', response.content_type
|
||||||
|
|||||||
@ -28,13 +28,18 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||||||
:versions
|
:versions
|
||||||
|
|
||||||
def test_get_issue_report
|
def test_get_issue_report
|
||||||
get :issue_report, :id => 1
|
get :issue_report, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_issue_report_details
|
def test_get_issue_report_details
|
||||||
%w(tracker version priority category assigned_to author subproject).each do |detail|
|
%w(tracker version priority category assigned_to author subproject).each do |detail|
|
||||||
get :issue_report_details, :id => 1, :detail => detail
|
get :issue_report_details, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:detail => detail
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -46,7 +51,10 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||||||
Issue.generate!(:tracker_id => 1, :status_id => 5)
|
Issue.generate!(:tracker_id => 1, :status_id => 5)
|
||||||
Issue.generate!(:tracker_id => 2)
|
Issue.generate!(:tracker_id => 2)
|
||||||
|
|
||||||
get :issue_report_details, :id => 1, :detail => 'tracker'
|
get :issue_report_details, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:detail => 'tracker'
|
||||||
|
}
|
||||||
assert_select 'table.list tbody :nth-child(1)' do
|
assert_select 'table.list tbody :nth-child(1)' do
|
||||||
assert_select 'td', :text => 'Bug'
|
assert_select 'td', :text => 'Bug'
|
||||||
assert_select ':nth-child(2)', :text => '2' # status:1
|
assert_select ':nth-child(2)', :text => '2' # status:1
|
||||||
@ -58,7 +66,10 @@ class ReportsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_get_issue_report_details_with_an_invalid_detail
|
def test_get_issue_report_details_with_an_invalid_detail
|
||||||
get :issue_report_details, :id => 1, :detail => 'invalid'
|
get :issue_report_details, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:detail => 'invalid'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -42,7 +42,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Bazaar'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Bazaar'
|
assert_select 'option[value=?][selected=selected]', 'Bazaar'
|
||||||
@ -50,7 +53,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_browse_root
|
def test_browse_root
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 2
|
assert_select 'tr', 2
|
||||||
@ -60,7 +65,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_browse_directory
|
def test_browse_directory
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['directory'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['directory'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 3
|
assert_select 'tr', 3
|
||||||
@ -71,8 +79,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_browse_at_given_revision
|
def test_browse_at_given_revision
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash([])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash([])[:param],
|
||||||
:rev => 3
|
:rev => 3
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 4
|
assert_select 'tr', 4
|
||||||
@ -84,32 +95,40 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_changes
|
def test_changes
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /doc-mkdir.txt/
|
assert_select 'h2', :text => /doc-mkdir.txt/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_show
|
def test_entry_show
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
|
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 19
|
# Line 19
|
||||||
assert_select 'tr#L29 td.line-code', :text => /Show help message/
|
assert_select 'tr#L29 td.line-code', :text => /Show help message/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_download
|
def test_entry_download
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
|
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
|
||||||
:format => 'raw'
|
:format => 'raw'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# File content
|
# File content
|
||||||
assert @response.body.include?('Show help message')
|
assert @response.body.include?('Show help message')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_directory_entry
|
def test_directory_entry
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['directory'])[:param]
|
:path => repository_path_hash(['directory'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody'
|
assert_select 'table.entries tbody'
|
||||||
end
|
end
|
||||||
@ -117,7 +136,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
def test_diff
|
def test_diff
|
||||||
# Full diff of changeset 3
|
# Full diff of changeset 3
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 3, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 3,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 11 removed
|
# Line 11 removed
|
||||||
assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/
|
assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/
|
||||||
@ -125,8 +148,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_annotate
|
def test_annotate
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '2' do
|
assert_select "th.line-num", :text => '2' do
|
||||||
@ -147,8 +172,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
:identifier => 'author_escaping',
|
:identifier => 'author_escaping',
|
||||||
:log_encoding => 'UTF-8')
|
:log_encoding => 'UTF-8')
|
||||||
assert repository
|
assert repository
|
||||||
get :annotate, :id => PRJ_ID, :repository_id => 'author_escaping',
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:repository_id => 'author_escaping',
|
||||||
:path => repository_path_hash(['author-escaping-test.txt'])[:param]
|
:path => repository_path_hash(['author-escaping-test.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num", :text => '1' do
|
||||||
@ -175,8 +203,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
:identifier => 'author_non_ascii',
|
:identifier => 'author_non_ascii',
|
||||||
:log_encoding => log_encoding)
|
:log_encoding => log_encoding)
|
||||||
assert repository
|
assert repository
|
||||||
get :annotate, :id => PRJ_ID, :repository_id => 'author_non_ascii',
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:repository_id => 'author_non_ascii',
|
||||||
:path => repository_path_hash(['author-non-ascii-test.txt'])[:param]
|
:path => repository_path_hash(['author-non-ascii-test.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num", :text => '1' do
|
||||||
@ -198,7 +229,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
assert @repository.changesets.count > 0
|
assert @repository.changesets.count > 0
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -217,7 +250,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -28,7 +28,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :new, :project_id => 'subproject1'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
||||||
@ -39,7 +41,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_new_should_propose_enabled_scm_only
|
def test_new_should_propose_enabled_scm_only
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
with_settings :enabled_scm => ['Mercurial', 'Git'] do
|
with_settings :enabled_scm => ['Mercurial', 'Git'] do
|
||||||
get :new, :project_id => 'subproject1'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
@ -52,7 +56,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_get_new_with_type
|
def test_get_new_with_type
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Git'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Git'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
@ -63,9 +70,15 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'Repository.count' do
|
assert_difference 'Repository.count' do
|
||||||
post :create, :project_id => 'subproject1',
|
post :create, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
:repository_scm => 'Subversion',
|
:repository_scm => 'Subversion',
|
||||||
:repository => {:url => 'file:///test', :is_default => '1', :identifier => ''}
|
:repository => {
|
||||||
|
:url => 'file:///test',
|
||||||
|
:is_default => '1',
|
||||||
|
:identifier => ''
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
repository = Repository.order('id DESC').first
|
repository = Repository.order('id DESC').first
|
||||||
@ -76,9 +89,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_no_difference 'Repository.count' do
|
assert_no_difference 'Repository.count' do
|
||||||
post :create, :project_id => 'subproject1',
|
post :create, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
:repository_scm => 'Subversion',
|
:repository_scm => 'Subversion',
|
||||||
:repository => {:url => 'invalid'}
|
:repository => {
|
||||||
|
:url => 'invalid'
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /URL is invalid/
|
assert_select_error /URL is invalid/
|
||||||
@ -89,21 +106,33 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
get :edit, :id => 11
|
get :edit, :params => {
|
||||||
|
:id => 11
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test'
|
assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
put :update, :id => 11, :repository => {:password => 'test_update'}
|
put :update, :params => {
|
||||||
|
:id => 11,
|
||||||
|
:repository => {
|
||||||
|
:password => 'test_update'
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_equal 'test_update', Repository.find(11).password
|
assert_equal 'test_update', Repository.find(11).password
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_failure
|
def test_update_with_failure
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
put :update, :id => 11, :repository => {:password => 'x'*260}
|
put :update, :params => {
|
||||||
|
:id => 11,
|
||||||
|
:repository => {
|
||||||
|
:password => 'x'*260
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select_error /Password is too long/
|
assert_select_error /Password is too long/
|
||||||
end
|
end
|
||||||
@ -111,7 +140,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => 11
|
delete :destroy, :params => {
|
||||||
|
:id => 11
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_nil Repository.find_by_id(11)
|
assert_nil Repository.find_by_id(11)
|
||||||
@ -121,7 +152,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Repository::Subversion.any_instance.expects(:fetch_changesets).once
|
Repository::Subversion.any_instance.expects(:fetch_changesets).once
|
||||||
|
|
||||||
with_settings :autofetch_changesets => '1' do
|
with_settings :autofetch_changesets => '1' do
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,7 +162,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Repository::Subversion.any_instance.expects(:fetch_changesets).never
|
Repository::Subversion.any_instance.expects(:fetch_changesets).never
|
||||||
|
|
||||||
with_settings :autofetch_changesets => '0' do
|
with_settings :autofetch_changesets => '0' do
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -138,12 +173,16 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Project.find(1).close
|
Project.find(1).close
|
||||||
|
|
||||||
with_settings :autofetch_changesets => '1' do
|
with_settings :autofetch_changesets => '1' do
|
||||||
get :show, :id => 1
|
get :show, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revisions
|
def test_revisions
|
||||||
get :revisions, :id => 1
|
get :revisions, :params => {
|
||||||
|
:id => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.changesets'
|
assert_select 'table.changesets'
|
||||||
end
|
end
|
||||||
@ -151,18 +190,27 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_revisions_for_other_repository
|
def test_revisions_for_other_repository
|
||||||
repository = Repository::Subversion.create!(:project_id => 1, :identifier => 'foo', :url => 'file:///foo')
|
repository = Repository::Subversion.create!(:project_id => 1, :identifier => 'foo', :url => 'file:///foo')
|
||||||
|
|
||||||
get :revisions, :id => 1, :repository_id => 'foo'
|
get :revisions, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:repository_id => 'foo'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.changesets'
|
assert_select 'table.changesets'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revisions_for_invalid_repository
|
def test_revisions_for_invalid_repository
|
||||||
get :revisions, :id => 1, :repository_id => 'foo'
|
get :revisions, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:repository_id => 'foo'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revision
|
def test_revision
|
||||||
get :revision, :id => 1, :rev => 1
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => 'Revision 1'
|
assert_select 'h2', :text => 'Revision 1'
|
||||||
end
|
end
|
||||||
@ -171,7 +219,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Changeset.where(:id => 100).update_all(:comments => 'Simple *text*')
|
Changeset.where(:id => 100).update_all(:comments => 'Simple *text*')
|
||||||
|
|
||||||
with_settings :commit_logs_formatting => '0' do
|
with_settings :commit_logs_formatting => '0' do
|
||||||
get :revision, :id => 1, :rev => 1
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '.changeset-comments', :text => 'Simple *text*'
|
assert_select '.changeset-comments', :text => 'Simple *text*'
|
||||||
end
|
end
|
||||||
@ -181,7 +232,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(1).add_permission! :manage_related_issues
|
Role.find(1).add_permission! :manage_related_issues
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :revision, :id => 1, :rev => 1
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'form[action=?]', '/projects/ecookbook/repository/revisions/1/issues' do
|
assert_select 'form[action=?]', '/projects/ecookbook/repository/revisions/1/issues' do
|
||||||
@ -190,14 +244,20 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_revision_should_not_change_the_project_menu_link
|
def test_revision_should_not_change_the_project_menu_link
|
||||||
get :revision, :id => 1, :rev => 1
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository'
|
assert_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revision_with_before_nil_and_afer_normal
|
def test_revision_with_before_nil_and_afer_normal
|
||||||
get :revision, {:id => 1, :rev => 1}
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'div.contextual' do
|
assert_select 'div.contextual' do
|
||||||
@ -209,7 +269,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_add_related_issue
|
def test_add_related_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Changeset.find(103).issues.size' do
|
assert_difference 'Changeset.find(103).issues.size' do
|
||||||
xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js'
|
post :add_related_issue, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 4,
|
||||||
|
:issue_id => 2,
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -221,7 +287,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_add_related_issue_should_accept_issue_id_with_sharp
|
def test_add_related_issue_should_accept_issue_id_with_sharp
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Changeset.find(103).issues.size' do
|
assert_difference 'Changeset.find(103).issues.size' do
|
||||||
xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => "#2", :format => 'js'
|
post :add_related_issue, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 4,
|
||||||
|
:issue_id => "#2",
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
end
|
end
|
||||||
assert_equal [2], Changeset.find(103).issue_ids
|
assert_equal [2], Changeset.find(103).issue_ids
|
||||||
end
|
end
|
||||||
@ -229,7 +301,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
def test_add_related_issue_with_invalid_issue_id
|
def test_add_related_issue_with_invalid_issue_id
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Changeset.find(103).issues.size' do
|
assert_no_difference 'Changeset.find(103).issues.size' do
|
||||||
xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999, :format => 'js'
|
post :add_related_issue, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 4,
|
||||||
|
:issue_id => 9999,
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -242,7 +320,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Changeset.find(103).issues.size', -1 do
|
assert_difference 'Changeset.find(103).issues.size', -1 do
|
||||||
xhr :delete, :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js'
|
delete :remove_related_issue, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 4,
|
||||||
|
:issue_id => 2,
|
||||||
|
:format => 'js'
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -256,13 +340,19 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
assert_not_nil latest
|
assert_not_nil latest
|
||||||
Date.stubs(:today).returns(latest.to_date + 10)
|
Date.stubs(:today).returns(latest.to_date + 10)
|
||||||
|
|
||||||
get :graph, :id => 1, :graph => 'commits_per_month'
|
get :graph, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:graph => 'commits_per_month'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'image/svg+xml', @response.content_type
|
assert_equal 'image/svg+xml', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_graph_commits_per_author
|
def test_graph_commits_per_author
|
||||||
get :graph, :id => 1, :graph => 'commits_per_author'
|
get :graph, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:graph => 'commits_per_author'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'image/svg+xml', @response.content_type
|
assert_equal 'image/svg+xml', @response.content_type
|
||||||
end
|
end
|
||||||
@ -278,7 +368,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
:comments => 'Committed by foo.'
|
:comments => 'Committed by foo.'
|
||||||
)
|
)
|
||||||
|
|
||||||
get :committers, :id => 10
|
get :committers, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'input[value=dlopper] + select option[value="3"][selected=selected]', :text => 'Dave Lopper'
|
assert_select 'input[value=dlopper] + select option[value="3"][selected=selected]', :text => 'Dave Lopper'
|
||||||
@ -289,7 +381,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
Changeset.delete_all
|
Changeset.delete_all
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
get :committers, :id => 10
|
get :committers, :params => {
|
||||||
|
:id => 10
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -304,7 +398,12 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
|||||||
:comments => 'Committed by foo.'
|
:comments => 'Committed by foo.'
|
||||||
)
|
)
|
||||||
assert_no_difference "Changeset.where(:user_id => 3).count" do
|
assert_no_difference "Changeset.where(:user_id => 3).count" do
|
||||||
post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
post :committers, :params => {
|
||||||
|
:id => 10,
|
||||||
|
:committers => {
|
||||||
|
'0' => ['foo', '2'], '1' => ['dlopper', '3']
|
||||||
|
}
|
||||||
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
assert_equal User.find(2), c.reload.user
|
assert_equal User.find(2), c.reload.user
|
||||||
end
|
end
|
||||||
|
|||||||
@ -46,7 +46,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Cvs'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Cvs'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
@ -59,7 +62,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -78,7 +83,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -94,8 +102,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param],
|
||||||
:rev => 1
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -110,8 +121,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'td.line-code', :text => /before_filter/, :count => 0
|
assert_select 'td.line-code', :text => /before_filter/, :count => 0
|
||||||
@ -123,9 +136,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:rev => 2
|
:rev => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# this line was removed in r3
|
# this line was removed in r3
|
||||||
@ -137,8 +152,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'zzz.c'])[:param]
|
:path => repository_path_hash(['sources', 'zzz.c'])[:param]
|
||||||
|
}
|
||||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -147,9 +164,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:format => 'raw'
|
:format => 'raw'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -158,8 +177,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources'])[:param]
|
:path => repository_path_hash(['sources'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody'
|
assert_select 'table.entries tbody'
|
||||||
end
|
end
|
||||||
@ -170,7 +191,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 3, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 3,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'td.line-code.diff_out', :text => /before_filter :require_login/
|
assert_select 'td.line-code.diff_out', :text => /before_filter :require_login/
|
||||||
@ -184,7 +209,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 1, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 1,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'td.line-code.diff_in', :text => /watched.remove_watcher/
|
assert_select 'td.line-code.diff_in', :text => /watched.remove_watcher/
|
||||||
@ -200,8 +229,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# 1.1 line
|
# 1.1 line
|
||||||
@ -226,7 +257,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -247,7 +280,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -42,7 +42,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Darcs'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Darcs'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Darcs'
|
assert_select 'option[value=?][selected=selected]', 'Darcs'
|
||||||
@ -54,7 +57,9 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 3
|
assert_select 'tr', 3
|
||||||
assert_select 'tr.dir td.filename a', :text => 'images'
|
assert_select 'tr.dir td.filename a', :text => 'images'
|
||||||
@ -68,7 +73,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 2
|
assert_select 'tr', 2
|
||||||
@ -82,8 +90,11 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param],
|
||||||
:rev => 1
|
:rev => 1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
assert_select 'tr', 1
|
assert_select 'tr', 1
|
||||||
@ -96,8 +107,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /edit.png/
|
assert_select 'h2', :text => /edit.png/
|
||||||
end
|
end
|
||||||
@ -109,7 +122,11 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
# Full diff of changeset 5
|
# Full diff of changeset 5
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 5, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 5,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
||||||
@ -124,7 +141,9 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -144,7 +163,9 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -43,7 +43,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Filesystem'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Filesystem'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Filesystem'
|
assert_select 'option[value=?][selected=selected]', 'Filesystem'
|
||||||
@ -53,7 +56,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
def test_browse_root
|
def test_browse_root
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@repository.reload
|
@repository.reload
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -71,21 +76,29 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_no_extension
|
def test_show_no_extension
|
||||||
get :entry, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param]
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['test'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L1 td.line-code', :text => /TEST CAT/
|
assert_select 'tr#L1 td.line-code', :text => /TEST CAT/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_download_no_extension
|
def test_entry_download_no_extension
|
||||||
get :raw, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param]
|
get :raw, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['test'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/octet-stream', @response.content_type
|
assert_equal 'application/octet-stream', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_non_ascii_contents
|
def test_show_non_ascii_contents
|
||||||
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
|
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param]
|
:path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
||||||
if @ruby19_non_utf8_pass
|
if @ruby19_non_utf8_pass
|
||||||
@ -102,8 +115,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
def test_show_utf16
|
def test_show_utf16
|
||||||
enc = 'UTF-16'
|
enc = 'UTF-16'
|
||||||
with_settings :repositories_encodings => enc do
|
with_settings :repositories_encodings => enc do
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['japanese', 'utf-16.txt'])[:param]
|
:path => repository_path_hash(['japanese', 'utf-16.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
||||||
end
|
end
|
||||||
@ -111,8 +126,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_text_file_should_show_other_if_too_big
|
def test_show_text_file_should_show_other_if_too_big
|
||||||
with_settings :file_max_size_displayed => 1 do
|
with_settings :file_max_size_displayed => 1 do
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['japanese', 'big-file.txt'])[:param]
|
:path => repository_path_hash(['japanese', 'big-file.txt'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'p.nodata'
|
assert_select 'p.nodata'
|
||||||
@ -123,7 +140,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -140,7 +159,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -54,13 +54,16 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_and_update
|
def test_create_and_update
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
assert_difference 'Repository.count' do
|
assert_difference 'Repository.count' do
|
||||||
post :create, :project_id => 'subproject1',
|
post :create, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
:repository_scm => 'Git',
|
:repository_scm => 'Git',
|
||||||
:repository => {
|
:repository => {
|
||||||
:url => '/test',
|
:url => '/test',
|
||||||
:is_default => '0',
|
:is_default => '0',
|
||||||
:identifier => 'test-create',
|
:identifier => 'test-create',
|
||||||
:report_last_commit => '1',
|
:report_last_commit => '1',
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@ -69,9 +72,12 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal '/test', repository.url
|
assert_equal '/test', repository.url
|
||||||
assert_equal true, repository.report_last_commit
|
assert_equal true, repository.report_last_commit
|
||||||
|
|
||||||
put :update, :id => repository.id,
|
put :update, :params => {
|
||||||
|
:id => repository.id,
|
||||||
:repository => {
|
:repository => {
|
||||||
:report_last_commit => '0'
|
:report_last_commit => '0'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_response 302
|
assert_response 302
|
||||||
repo2 = Repository.find(repository.id)
|
repo2 = Repository.find(repository.id)
|
||||||
@ -92,7 +98,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Git'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Git'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Git'
|
assert_select 'option[value=?][selected=selected]', 'Git'
|
||||||
@ -105,7 +114,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -131,7 +142,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :rev => 'test_branch'
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 'test_branch'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -156,7 +170,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
"tag00.lightweight",
|
"tag00.lightweight",
|
||||||
"tag01.annotated",
|
"tag01.annotated",
|
||||||
].each do |t1|
|
].each do |t1|
|
||||||
get :show, :id => PRJ_ID, :rev => t1
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => t1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody tr'
|
assert_select 'table.entries tbody tr'
|
||||||
@ -169,7 +186,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -184,8 +204,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param],
|
||||||
:rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
|
:rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -195,15 +218,19 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_changes
|
def test_changes
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /edit.png/
|
assert_select 'h2', :text => /edit.png/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_show
|
def test_entry_show
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 11
|
# Line 11
|
||||||
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
||||||
@ -219,9 +246,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
else
|
else
|
||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
|
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
|
||||||
end
|
end
|
||||||
@ -230,17 +259,21 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_download
|
def test_entry_download
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:format => 'raw'
|
:format => 'raw'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# File content
|
# File content
|
||||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_directory_entry
|
def test_directory_entry
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources'])[:param]
|
:path => repository_path_hash(['sources'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2 a', :text => 'sources'
|
assert_select 'h2 a', :text => 'sources'
|
||||||
assert_select 'table.entries tbody'
|
assert_select 'table.entries tbody'
|
||||||
@ -255,10 +288,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
# Full diff of changeset 2f9c0091
|
# Full diff of changeset 2f9c0091
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||||
:type => dt
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
||||||
@ -274,11 +308,12 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :diff_max_lines_displayed => 1000 do
|
with_settings :diff_max_lines_displayed => 1000 do
|
||||||
# Full diff of changeset 2f9c0091
|
# Full diff of changeset 2f9c0091
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:type => dt
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
||||||
@ -297,14 +332,20 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
# Truncated diff of changeset 2f9c0091
|
# Truncated diff of changeset 2f9c0091
|
||||||
with_cache do
|
with_cache do
|
||||||
with_settings :default_language => 'en' do
|
with_settings :default_language => 'en' do
|
||||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:type => 'inline',
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert @response.body.include?("... This diff was truncated")
|
assert @response.body.include?("... This diff was truncated")
|
||||||
end
|
end
|
||||||
with_settings :default_language => 'fr' do
|
with_settings :default_language => 'fr' do
|
||||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:type => 'inline',
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert ! @response.body.include?("... This diff was truncated")
|
assert ! @response.body.include?("... This diff was truncated")
|
||||||
assert @response.body.include?("... Ce diff")
|
assert @response.body.include?("... Ce diff")
|
||||||
@ -319,11 +360,12 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
|
:rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
|
||||||
:rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
:rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||||
:type => dt
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /2f9c0091:61b685fb/
|
assert_select 'h2', :text => /2f9c0091:61b685fb/
|
||||||
assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff'
|
assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff'
|
||||||
@ -341,12 +383,13 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert repo
|
assert repo
|
||||||
assert_equal false, repo.is_default
|
assert_equal false, repo.is_default
|
||||||
assert_equal 'test-diff-path', repo.identifier
|
assert_equal 'test-diff-path', repo.identifier
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:repository_id => 'test-diff-path',
|
:repository_id => 'test-diff-path',
|
||||||
:rev => '61b685fbe55ab05b',
|
:rev => '61b685fbe55ab05b',
|
||||||
:rev_to => '2f9c0091c754a91a',
|
:rev_to => '2f9c0091c754a91a',
|
||||||
:type => 'inline'
|
:type => 'inline'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'form[action=?]', '/projects/subproject1/repository/test-diff-path/revisions/61b685fbe55ab05b/diff'
|
assert_select 'form[action=?]', '/projects/subproject1/repository/test-diff-path/revisions/61b685fbe55ab05b/diff'
|
||||||
assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91a'
|
assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91a'
|
||||||
@ -359,7 +402,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r1,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table' do
|
assert_select 'table' do
|
||||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
|
||||||
@ -372,7 +419,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_diff_should_show_filenames
|
def test_diff_should_show_filenames
|
||||||
get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline'
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 'deff712f05a90d96edbd70facc47d944be5897e3',
|
||||||
|
:type => 'inline'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# modified file
|
# modified file
|
||||||
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
||||||
@ -388,24 +439,28 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert_nil user.pref[:diff_type]
|
assert_nil user.pref[:diff_type]
|
||||||
|
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
user.reload
|
user.reload
|
||||||
assert_equal "inline", user.pref[:diff_type]
|
assert_equal "inline", user.pref[:diff_type]
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||||
:type => 'sbs'
|
:type => 'sbs'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
user.reload
|
user.reload
|
||||||
assert_equal "sbs", user.pref[:diff_type]
|
assert_equal "sbs", user.pref[:diff_type]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_annotate
|
def test_annotate
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# Line 23, changeset 2f9c0091
|
# Line 23, changeset 2f9c0091
|
||||||
@ -422,16 +477,21 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :annotate, :id => PRJ_ID, :rev => 'deff7',
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 'deff7',
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /@ deff712f/
|
assert_select 'h2', :text => /@ deff712f/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_annotate_binary_file
|
def test_annotate_binary_file
|
||||||
with_settings :default_language => 'en' do
|
with_settings :default_language => 'en' do
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'p#errorExplanation', :text => /cannot be annotated/
|
assert_select 'p#errorExplanation', :text => /cannot be annotated/
|
||||||
end
|
end
|
||||||
@ -439,15 +499,19 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_annotate_error_when_too_big
|
def test_annotate_error_when_too_big
|
||||||
with_settings :file_max_size_displayed => 1 do
|
with_settings :file_max_size_displayed => 1 do
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:rev => 'deff712f'
|
:rev => 'deff712f'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'p#errorExplanation', :text => /exceeds the maximum text file size/
|
assert_select 'p#errorExplanation', :text => /exceeds the maximum text file size/
|
||||||
|
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['README'])[:param],
|
:path => repository_path_hash(['README'])[:param],
|
||||||
:rev => '7234cb2'
|
:rev => '7234cb2'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -462,9 +526,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
else
|
else
|
||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num", :text => '1' do
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '57ca437c'
|
assert_select "a", :text => '57ca437c'
|
||||||
@ -481,9 +547,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_annotate_latin_1_author
|
def test_annotate_latin_1_author
|
||||||
['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1|
|
['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1|
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash([" filename with a leading space.txt "])[:param],
|
:path => repository_path_hash([" filename with a leading space.txt "])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num", :text => '1' do
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '83ca5fd5'
|
assert_select "a", :text => '83ca5fd5'
|
||||||
@ -501,7 +569,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :revisions, :id => PRJ_ID
|
get :revisions, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_select 'form[method=get][action=?]', '/projects/subproject1/repository/revision'
|
assert_select 'form[method=get][action=?]', '/projects/subproject1/repository/revision'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -511,7 +581,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
|
['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
|
||||||
get :revision, :id => PRJ_ID, :rev => r
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -522,7 +595,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['', ' ', nil].each do |r|
|
['', ' ', nil].each do |r|
|
||||||
get :revision, :id => PRJ_ID, :rev => r
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
@ -536,7 +612,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -556,7 +634,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -56,7 +56,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new
|
def test_get_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Mercurial'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Mercurial'
|
assert_select 'option[value=?][selected=selected]', 'Mercurial'
|
||||||
@ -68,7 +71,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -89,7 +94,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -109,8 +117,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
[0, '0', '0885933ad4f6'].each do |r1|
|
[0, '0', '0885933ad4f6'].each do |r1|
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['images'])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -130,9 +141,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
[13, '13', '3a330eb32958'].each do |r1|
|
[13, '13', '3a330eb32958'].each do |r1|
|
||||||
get :show, :id => PRJ_ID,
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
|
:path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -156,9 +169,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
[21, '21', 'adf805632193'].each do |r1|
|
[21, '21', 'adf805632193'].each do |r1|
|
||||||
get :show, :id => PRJ_ID,
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir'])[:param],
|
:path => repository_path_hash(['latin-1-dir'])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -182,7 +197,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
def show_should_show_branch_selection_form
|
def show_should_show_branch_selection_form
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do
|
assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do
|
||||||
assert_select 'select[name=branch]' do
|
assert_select 'select[name=branch]' do
|
||||||
assert_select 'option[value=?]', 'test-branch-01'
|
assert_select 'option[value=?]', 'test-branch-01'
|
||||||
@ -203,7 +220,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
'test_branch.latin-1',
|
'test_branch.latin-1',
|
||||||
'test-branch-00',
|
'test-branch-00',
|
||||||
].each do |bra|
|
].each do |bra|
|
||||||
get :show, :id => PRJ_ID, :rev => bra
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => bra
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody tr'
|
assert_select 'table.entries tbody tr'
|
||||||
@ -221,7 +241,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
'tag_test.00',
|
'tag_test.00',
|
||||||
'tag-init-revision'
|
'tag-init-revision'
|
||||||
].each do |tag|
|
].each do |tag|
|
||||||
get :show, :id => PRJ_ID, :rev => tag
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => tag
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody tr'
|
assert_select 'table.entries tbody tr'
|
||||||
@ -230,15 +253,19 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_changes
|
def test_changes
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /edit.png/
|
assert_select 'h2', :text => /edit.png/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_show
|
def test_entry_show
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 10
|
# Line 10
|
||||||
assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
||||||
@ -246,9 +273,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_entry_show_latin_1_path
|
def test_entry_show_latin_1_path
|
||||||
[21, '21', 'adf805632193'].each do |r1|
|
[21, '21', 'adf805632193'].each do |r1|
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/
|
assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/
|
||||||
end
|
end
|
||||||
@ -257,9 +286,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
def test_entry_show_latin_1_contents
|
def test_entry_show_latin_1_contents
|
||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
[27, '27', '7bbf4c738e71'].each do |r1|
|
[27, '27', '7bbf4c738e71'].each do |r1|
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||||
end
|
end
|
||||||
@ -267,9 +298,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_download
|
def test_entry_download
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||||
:format => 'raw'
|
:format => 'raw'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# File content
|
# File content
|
||||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||||
@ -280,8 +313,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_directory_entry
|
def test_directory_entry
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources'])[:param]
|
:path => repository_path_hash(['sources'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2 a', :text => 'sources'
|
assert_select 'h2 a', :text => 'sources'
|
||||||
assert_select 'table.entries tbody'
|
assert_select 'table.entries tbody'
|
||||||
@ -295,7 +330,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
[4, '4', 'def6d2f1254a'].each do |r1|
|
[4, '4', 'def6d2f1254a'].each do |r1|
|
||||||
# Full diff of changeset 4
|
# Full diff of changeset 4
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r1,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
if @diff_c_support
|
if @diff_c_support
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
@ -314,11 +353,12 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
[2, '400bb8672109', '400', 400].each do |r1|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
||||||
[4, 'def6d2f1254a'].each do |r2|
|
[4, 'def6d2f1254a'].each do |r2|
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff,
|
get :diff, :params => {
|
||||||
:id => PRJ_ID,
|
:id => PRJ_ID,
|
||||||
:rev => r1,
|
:rev => r1,
|
||||||
:rev_to => r2,
|
:rev_to => r2,
|
||||||
:type => dt
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/
|
assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/
|
||||||
end
|
end
|
||||||
@ -330,7 +370,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
[21, 'adf805632193'].each do |r1|
|
[21, 'adf805632193'].each do |r1|
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r1,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'table' do
|
assert_select 'table' do
|
||||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
|
||||||
@ -342,20 +386,30 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_diff_should_show_modified_filenames
|
def test_diff_should_show_modified_filenames
|
||||||
get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline'
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => '400bb8672109',
|
||||||
|
:type => 'inline'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_diff_should_show_deleted_filenames
|
def test_diff_should_show_deleted_filenames
|
||||||
get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline'
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 'b3a615152df8',
|
||||||
|
:type => 'inline'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'th.filename', :text => 'sources/welcome_controller.rb'
|
assert_select 'th.filename', :text => 'sources/welcome_controller.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_annotate
|
def test_annotate
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# Line 22, revision 4:def6d2f1254a
|
# Line 22, revision 4:def6d2f1254a
|
||||||
@ -372,8 +426,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
@ -384,8 +440,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
[2, '400bb8672109', '400', 400].each do |r1|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
||||||
get :annotate, :id => PRJ_ID, :rev => r1,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r1,
|
||||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /@ 2:400bb8672109/
|
assert_select 'h2', :text => /@ 2:400bb8672109/
|
||||||
end
|
end
|
||||||
@ -393,9 +452,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_annotate_latin_1_path
|
def test_annotate_latin_1_path
|
||||||
[21, '21', 'adf805632193'].each do |r1|
|
[21, '21', 'adf805632193'].each do |r1|
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num", :text => '1' do
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
@ -412,9 +473,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
def test_annotate_latin_1_contents
|
def test_annotate_latin_1_contents
|
||||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||||
[27, '7bbf4c738e71'].each do |r1|
|
[27, '7bbf4c738e71'].each do |r1|
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||||
:rev => r1
|
:rev => r1
|
||||||
|
}
|
||||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -427,7 +490,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['1', '9d5b5b', '9d5b5b004199'].each do |r|
|
['1', '9d5b5b', '9d5b5b004199'].each do |r|
|
||||||
with_settings :default_language => "en" do
|
with_settings :default_language => "en" do
|
||||||
get :revision, :id => PRJ_ID, :rev => r
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'title',
|
assert_select 'title',
|
||||||
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
||||||
@ -441,7 +507,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['', ' ', nil].each do |r|
|
['', ' ', nil].each do |r|
|
||||||
get :revision, :id => PRJ_ID, :rev => r
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
@ -454,7 +523,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -473,7 +544,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -41,7 +41,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
@project.repository.destroy
|
@project.repository.destroy
|
||||||
get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
|
get :new, :params => {
|
||||||
|
:project_id => 'subproject1',
|
||||||
|
:repository_scm => 'Subversion'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'select[name=?]', 'repository_scm' do
|
assert_select 'select[name=?]', 'repository_scm' do
|
||||||
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
||||||
@ -53,7 +56,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -78,7 +83,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
:url => self.class.subversion_repository_url,
|
:url => self.class.subversion_repository_url,
|
||||||
:is_default => false, :identifier => 'svn')
|
:is_default => false, :identifier => 'svn')
|
||||||
|
|
||||||
get :show, :id => PRJ_ID, :repository_id => 'svn'
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:repository_id => 'svn'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]'
|
assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]'
|
||||||
@ -91,7 +99,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param]
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['subversion_test'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -111,8 +122,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param],
|
get :show, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:path => repository_path_hash(['subversion_test'])[:param],
|
||||||
:rev => 4
|
:rev => 4
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.entries tbody' do
|
assert_select 'table.entries tbody' do
|
||||||
@ -130,8 +144,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
|
:path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.changesets tbody' do
|
assert_select 'table.changesets tbody' do
|
||||||
@ -155,8 +171,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :changes, :id => PRJ_ID,
|
get :changes, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'table.changesets tbody' do
|
assert_select 'table.changesets tbody' do
|
||||||
@ -175,8 +193,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2 a', :text => 'subversion_test'
|
assert_select 'h2 a', :text => 'subversion_test'
|
||||||
assert_select 'h2 a', :text => 'helloworld.c'
|
assert_select 'h2 a', :text => 'helloworld.c'
|
||||||
@ -189,8 +209,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
# no files in the test repo is larger than 1KB...
|
# no files in the test repo is larger than 1KB...
|
||||||
with_settings :file_max_size_displayed => 0 do
|
with_settings :file_max_size_displayed => 0 do
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.content_type
|
||||||
assert_select 'p.nodata'
|
assert_select 'p.nodata'
|
||||||
@ -198,8 +220,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_entry_should_display_images
|
def test_entry_should_display_images
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param]
|
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
|
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
|
||||||
end
|
end
|
||||||
@ -209,9 +233,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
|
:path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
|
||||||
:rev => 2
|
:rev => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# this line was removed in r3 and file was moved in r6
|
# this line was removed in r3 and file was moved in r6
|
||||||
assert_select 'td.line-code', :text => /Here's the code/
|
assert_select 'td.line-code', :text => /Here's the code/
|
||||||
@ -222,8 +248,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
|
||||||
|
}
|
||||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -232,8 +260,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :raw, :id => PRJ_ID,
|
get :raw, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
|
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
|
||||||
end
|
end
|
||||||
@ -243,8 +273,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :entry, :id => PRJ_ID,
|
get :entry, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2 a', :text => 'subversion_test'
|
assert_select 'h2 a', :text => 'subversion_test'
|
||||||
assert_select 'h2 a', :text => 'folder'
|
assert_select 'h2 a', :text => 'folder'
|
||||||
@ -252,7 +284,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
# TODO: this test needs fixtures.
|
# TODO: this test needs fixtures.
|
||||||
def test_revision
|
def test_revision
|
||||||
get :revision, :id => 1, :rev => 2
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'ul' do
|
assert_select 'ul' do
|
||||||
@ -270,13 +305,20 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :revision, :id => PRJ_ID, :rev => 'something_weird'
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 'something_weird'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_revision_diff
|
def test_invalid_revision_diff
|
||||||
get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => '1',
|
||||||
|
:rev_to => 'something_weird'
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
@ -287,7 +329,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['', ' ', nil].each do |r|
|
['', ' ', nil].each do |r|
|
||||||
get :revision, :id => PRJ_ID, :rev => r
|
get :revision, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => r
|
||||||
|
}
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select_error /was not found/
|
assert_select_error /was not found/
|
||||||
end
|
end
|
||||||
@ -299,7 +344,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
# Changes repository url to a subdirectory
|
# Changes repository url to a subdirectory
|
||||||
r.update_attribute :url, (r.url + '/test/some')
|
r.update_attribute :url, (r.url + '/test/some')
|
||||||
|
|
||||||
get :revision, :id => 1, :rev => 2
|
get :revision, :params => {
|
||||||
|
:id => 1,
|
||||||
|
:rev => 2
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'ul' do
|
assert_select 'ul' do
|
||||||
@ -318,7 +366,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 3, :type => dt
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 3,
|
||||||
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /Revision 3/
|
assert_select 'h2', :text => /Revision 3/
|
||||||
assert_select 'th.filename', :text => 'subversion_test/textfile.txt'
|
assert_select 'th.filename', :text => 'subversion_test/textfile.txt'
|
||||||
@ -331,7 +383,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
get :diff, :id => PRJ_ID, :rev => 5, :format => 'diff'
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 5,
|
||||||
|
:format => 'diff'
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/x-patch', @response.content_type
|
assert_equal 'text/x-patch', @response.content_type
|
||||||
assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first
|
assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first
|
||||||
@ -343,9 +399,13 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
['inline', 'sbs'].each do |dt|
|
['inline', 'sbs'].each do |dt|
|
||||||
get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2,
|
get :diff, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 6,
|
||||||
|
:rev_to => 2,
|
||||||
:path => repository_path_hash(['subversion_test', 'folder'])[:param],
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param],
|
||||||
:type => dt
|
:type => dt
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h2', :text => /2:6/
|
assert_select 'h2', :text => /2:6/
|
||||||
@ -361,8 +421,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :annotate, :id => PRJ_ID,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
@ -384,8 +446,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@project.reload
|
@project.reload
|
||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
get :annotate, :id => PRJ_ID, :rev => 8,
|
get :annotate, :params => {
|
||||||
|
:id => PRJ_ID,
|
||||||
|
:rev => 8,
|
||||||
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h2', :text => /@ 8/
|
assert_select 'h2', :text => /@ 8/
|
||||||
end
|
end
|
||||||
@ -397,7 +462,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal NUM_REV, @repository.changesets.count
|
assert_equal NUM_REV, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
@ -414,7 +481,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
||||||
assert_difference 'Repository.count', -1 do
|
assert_difference 'Repository.count', -1 do
|
||||||
delete :destroy, :id => @repository.id
|
delete :destroy, :params => {
|
||||||
|
:id => @repository.id
|
||||||
|
}
|
||||||
end
|
end
|
||||||
assert_response 302
|
assert_response 302
|
||||||
@project.reload
|
@project.reload
|
||||||
|
|||||||
@ -35,7 +35,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => 10.hours.ago, :updated_on => 10.hours.ago)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => 10.hours.ago, :updated_on => 10.hours.ago)
|
||||||
created = token.reload.created_on
|
created = token.reload.created_on
|
||||||
|
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
token.reload
|
token.reload
|
||||||
assert_equal created.to_i, token.created_on.to_i
|
assert_equal created.to_i, token.created_on.to_i
|
||||||
@ -48,13 +51,18 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_lifetime => '0', :session_timeout => '0' do
|
with_settings :session_lifetime => '0', :session_timeout => '0' do
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_user_session_without_token_should_be_reset
|
def test_user_session_without_token_should_be_reset
|
||||||
get :index, :session => {:user_id => 2}
|
get :index, :session => {
|
||||||
|
:user_id => 2
|
||||||
|
}
|
||||||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,7 +71,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_timeout => '720' do
|
with_settings :session_timeout => '720' do
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -73,7 +84,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_timeout => '720' do
|
with_settings :session_timeout => '720' do
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -83,7 +97,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_timeout => '60' do
|
with_settings :session_timeout => '60' do
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -93,7 +110,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_timeout => '60' do
|
with_settings :session_timeout => '60' do
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -106,7 +126,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago)
|
autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago)
|
||||||
@request.cookies['autologin'] = autologin_token.value
|
@request.cookies['autologin'] = autologin_token.value
|
||||||
|
|
||||||
get :index, :session => {:user_id => 2, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => 2,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_equal 2, session[:user_id]
|
assert_equal 2, session[:user_id]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_equal token.value, session[:tk]
|
assert_not_equal token.value, session[:tk]
|
||||||
@ -122,7 +145,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
|||||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||||
|
|
||||||
with_settings :session_timeout => '60' do
|
with_settings :session_timeout => '60' do
|
||||||
get :index, :session => {:user_id => user.id, :tk => token.value}
|
get :index, :session => {
|
||||||
|
:user_id => user.id,
|
||||||
|
:tk => token.value
|
||||||
|
}
|
||||||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
|
||||||
assert_include "Veuillez vous reconnecter", flash[:error]
|
assert_include "Veuillez vous reconnecter", flash[:error]
|
||||||
assert_equal :fr, current_language
|
assert_equal :fr, current_language
|
||||||
|
|||||||
@ -136,7 +136,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new_from_issue_form
|
def test_new_from_issue_form
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :params => {:project_id => '1'}
|
get :new, :params => {:project_id => '1'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -155,7 +155,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_from_issue_form
|
def test_create_from_issue_form
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Version.count' do
|
assert_difference 'Version.count' do
|
||||||
xhr :post, :create, :params => {:project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}}
|
post :create, :params => {:project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}}, :xhr => true
|
||||||
end
|
end
|
||||||
version = Version.find_by_name('test_add_version_from_issue_form')
|
version = Version.find_by_name('test_add_version_from_issue_form')
|
||||||
assert_not_nil version
|
assert_not_nil version
|
||||||
@ -169,7 +169,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_from_issue_form_with_failure
|
def test_create_from_issue_form_with_failure
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Version.count' do
|
assert_no_difference 'Version.count' do
|
||||||
xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}}
|
post :create, :params => {:project_id => '1', :version => {:name => ''}}, :xhr => true
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
@ -247,12 +247,12 @@ class VersionsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_issue_status_by
|
def test_issue_status_by
|
||||||
xhr :get, :status_by, :params => {:id => 2}
|
get :status_by, :params => {:id => 2}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issue_status_by_status
|
def test_issue_status_by_status
|
||||||
xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'}
|
get :status_by, :params => {:id => 2, :status_by => 'status'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'Assigned', response.body
|
assert_include 'Assigned', response.body
|
||||||
assert_include 'Closed', response.body
|
assert_include 'Closed', response.body
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_watch_a_single_object
|
def test_watch_a_single_object
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_difference('Watcher.count') do
|
assert_difference('Watcher.count') do
|
||||||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'}
|
post :watch, :params => {:object_type => 'issue', :object_id => '1'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$(".issue-1-watcher")', response.body
|
assert_include '$(".issue-1-watcher")', response.body
|
||||||
end
|
end
|
||||||
@ -48,7 +48,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_watch_a_collection_with_a_single_object
|
def test_watch_a_collection_with_a_single_object
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_difference('Watcher.count') do
|
assert_difference('Watcher.count') do
|
||||||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1']}
|
post :watch, :params => {:object_type => 'issue', :object_id => ['1']}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$(".issue-1-watcher")', response.body
|
assert_include '$(".issue-1-watcher")', response.body
|
||||||
end
|
end
|
||||||
@ -58,7 +58,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_watch_a_collection_with_multiple_objects
|
def test_watch_a_collection_with_multiple_objects
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_difference('Watcher.count', 2) do
|
assert_difference('Watcher.count', 2) do
|
||||||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1', '3']}
|
post :watch, :params => {:object_type => 'issue', :object_id => ['1', '3']}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$(".issue-bulk-watcher")', response.body
|
assert_include '$(".issue-bulk-watcher")', response.body
|
||||||
end
|
end
|
||||||
@ -71,7 +71,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
assert_not_nil m = Project.find(1).enabled_module('news')
|
assert_not_nil m = Project.find(1).enabled_module('news')
|
||||||
|
|
||||||
assert_difference 'Watcher.count' do
|
assert_difference 'Watcher.count' do
|
||||||
xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s}
|
post :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
assert m.reload.watched_by?(User.find(7))
|
assert m.reload.watched_by?(User.find(7))
|
||||||
@ -82,7 +82,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
assert_not_nil m = Project.find(2).enabled_module('news')
|
assert_not_nil m = Project.find(2).enabled_module('news')
|
||||||
|
|
||||||
assert_no_difference 'Watcher.count' do
|
assert_no_difference 'Watcher.count' do
|
||||||
xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s}
|
post :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s}, :xhr => true
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -91,7 +91,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
Role.find(2).remove_permission! :view_issues
|
Role.find(2).remove_permission! :view_issues
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_no_difference('Watcher.count') do
|
assert_no_difference('Watcher.count') do
|
||||||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'}
|
post :watch, :params => {:object_type => 'issue', :object_id => '1'}, :xhr => true
|
||||||
assert_response 403
|
assert_response 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,7 +99,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_watch_invalid_class_should_respond_with_404
|
def test_watch_invalid_class_should_respond_with_404
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_no_difference('Watcher.count') do
|
assert_no_difference('Watcher.count') do
|
||||||
xhr :post, :watch, :params => {:object_type => 'foo', :object_id => '1'}
|
post :watch, :params => {:object_type => 'foo', :object_id => '1'}, :xhr => true
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -107,7 +107,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_watch_invalid_object_should_respond_with_404
|
def test_watch_invalid_object_should_respond_with_404
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_no_difference('Watcher.count') do
|
assert_no_difference('Watcher.count') do
|
||||||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '999'}
|
post :watch, :params => {:object_type => 'issue', :object_id => '999'}, :xhr => true
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -125,7 +125,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_unwatch
|
def test_unwatch
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
assert_difference('Watcher.count', -1) do
|
assert_difference('Watcher.count', -1) do
|
||||||
xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => '2'}
|
delete :unwatch, :params => {:object_type => 'issue', :object_id => '2'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$(".issue-2-watcher")', response.body
|
assert_include '$(".issue-2-watcher")', response.body
|
||||||
end
|
end
|
||||||
@ -138,7 +138,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
Watcher.create!(:user_id => 3, :watchable => Issue.find(3))
|
Watcher.create!(:user_id => 3, :watchable => Issue.find(3))
|
||||||
|
|
||||||
assert_difference('Watcher.count', -2) do
|
assert_difference('Watcher.count', -2) do
|
||||||
xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => ['1', '3']}
|
delete :unwatch, :params => {:object_type => 'issue', :object_id => ['1', '3']}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include '$(".issue-bulk-watcher")', response.body
|
assert_include '$(".issue-bulk-watcher")', response.body
|
||||||
end
|
end
|
||||||
@ -148,28 +148,28 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :params => {:object_type => 'issue', :object_id => '2'}
|
get :new, :params => {:object_type => 'issue', :object_id => '2'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_with_multiple_objects
|
def test_new_with_multiple_objects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :params => {:object_type => 'issue', :object_id => ['1', '2']}
|
get :new, :params => {:object_type => 'issue', :object_id => ['1', '2']}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_for_new_record_with_project_id
|
def test_new_for_new_record_with_project_id
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :params => {:project_id => 1}
|
get :new, :params => {:project_id => 1}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_for_new_record_with_project_identifier
|
def test_new_for_new_record_with_project_identifier
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :new, :params => {:project_id => 'ecookbook'}
|
get :new, :params => {:project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
end
|
end
|
||||||
@ -190,10 +190,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('Watcher.count') do
|
assert_difference('Watcher.count') do
|
||||||
xhr :post, :create, :params => {
|
post :create, :params => {
|
||||||
:object_type => 'issue', :object_id => '2',
|
:object_type => 'issue', :object_id => '2',
|
||||||
:watcher => {:user_id => '4'}
|
:watcher => {:user_id => '4'}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
@ -204,10 +204,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_mutiple_users
|
def test_create_with_mutiple_users
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('Watcher.count', 2) do
|
assert_difference('Watcher.count', 2) do
|
||||||
xhr :post, :create, :params => {
|
post :create, :params => {
|
||||||
:object_type => 'issue', :object_id => '2',
|
:object_type => 'issue', :object_id => '2',
|
||||||
:watcher => {:user_ids => ['4', '7']}
|
:watcher => {:user_ids => ['4', '7']}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
@ -219,10 +219,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_create_with_mutiple_objects
|
def test_create_with_mutiple_objects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('Watcher.count', 4) do
|
assert_difference('Watcher.count', 4) do
|
||||||
xhr :post, :create, :params => {
|
post :create, :params => {
|
||||||
:object_type => 'issue', :object_id => ['1', '2'],
|
:object_type => 'issue', :object_id => ['1', '2'],
|
||||||
:watcher => {:user_ids => ['4', '7']}
|
:watcher => {:user_ids => ['4', '7']}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
@ -235,7 +235,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_autocomplete_on_watchable_creation
|
def test_autocomplete_on_watchable_creation
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :autocomplete_for_user, :params => {:q => 'mi', :project_id => 'ecookbook'}
|
get :autocomplete_for_user, :params => {:q => 'mi', :project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input', :count => 4
|
assert_select 'input', :count => 4
|
||||||
assert_select 'input[name=?][value="1"]', 'watcher[user_ids][]'
|
assert_select 'input[name=?][value="1"]', 'watcher[user_ids][]'
|
||||||
@ -250,17 +250,17 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
user = User.generate!(:firstname => 'issue15622')
|
user = User.generate!(:firstname => 'issue15622')
|
||||||
membership = user.membership(project)
|
membership = user.membership(project)
|
||||||
assert_nil membership
|
assert_nil membership
|
||||||
xhr :get, :autocomplete_for_user, :params => {:q => 'issue15622', :project_id => 'ecookbook'}
|
get :autocomplete_for_user, :params => {:q => 'issue15622', :project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input', :count => 1
|
assert_select 'input', :count => 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_autocomplete_on_watchable_update
|
def test_autocomplete_on_watchable_update
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :autocomplete_for_user, :params => {
|
get :autocomplete_for_user, :params => {
|
||||||
:object_type => 'issue', :object_id => '2',
|
:object_type => 'issue', :object_id => '2',
|
||||||
:project_id => 'ecookbook', :q => 'mi'
|
:project_id => 'ecookbook', :q => 'mi'
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input', :count => 3
|
assert_select 'input', :count => 3
|
||||||
assert_select 'input[name=?][value="2"]', 'watcher[user_ids][]'
|
assert_select 'input[name=?][value="2"]', 'watcher[user_ids][]'
|
||||||
@ -275,18 +275,18 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
membership = user.membership(project)
|
membership = user.membership(project)
|
||||||
assert_nil membership
|
assert_nil membership
|
||||||
|
|
||||||
xhr :get, :autocomplete_for_user, :params => {
|
get :autocomplete_for_user, :params => {
|
||||||
:object_type => 'issue', :object_id => '2',
|
:object_type => 'issue', :object_id => '2',
|
||||||
:project_id => 'ecookbook', :q => 'issue15622'
|
:project_id => 'ecookbook', :q => 'issue15622'
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'input', :count => 1
|
assert_select 'input', :count => 1
|
||||||
|
|
||||||
assert_difference('Watcher.count', 1) do
|
assert_difference('Watcher.count', 1) do
|
||||||
xhr :post, :create, :params => {
|
post :create, :params => {
|
||||||
:object_type => 'issue', :object_id => '2',
|
:object_type => 'issue', :object_id => '2',
|
||||||
:watcher => {:user_ids => ["#{user.id}"]}
|
:watcher => {:user_ids => ["#{user.id}"]}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
assert_match /ajax-modal/, response.body
|
assert_match /ajax-modal/, response.body
|
||||||
@ -302,7 +302,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
User.add_to_project(visible, Project.find(1))
|
User.add_to_project(visible, Project.find(1))
|
||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'}
|
get :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_include visible.name, response.body
|
assert_include visible.name, response.body
|
||||||
@ -312,9 +312,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_append
|
def test_append
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_no_difference 'Watcher.count' do
|
assert_no_difference 'Watcher.count' do
|
||||||
xhr :post, :append, :params => {
|
post :append, :params => {
|
||||||
:watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook'
|
:watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook'
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'watchers_inputs', response.body
|
assert_include 'watchers_inputs', response.body
|
||||||
assert_include 'issue[watcher_user_ids][]', response.body
|
assert_include 'issue[watcher_user_ids][]', response.body
|
||||||
@ -323,7 +323,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_append_without_user_should_render_nothing
|
def test_append_without_user_should_render_nothing
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :append, :params => {:project_id => 'ecookbook'}
|
post :append, :params => {:project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert response.body.blank?
|
assert response.body.blank?
|
||||||
end
|
end
|
||||||
@ -343,9 +343,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('Watcher.count', -1) do
|
assert_difference('Watcher.count', -1) do
|
||||||
xhr :delete, :destroy, :params => {
|
delete :destroy, :params => {
|
||||||
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
end
|
end
|
||||||
@ -359,9 +359,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference('Watcher.count', -1) do
|
assert_difference('Watcher.count', -1) do
|
||||||
xhr :delete, :destroy, :params => {
|
delete :destroy, :params => {
|
||||||
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /watchers/, response.body
|
assert_match /watchers/, response.body
|
||||||
end
|
end
|
||||||
|
|||||||
@ -188,7 +188,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
def test_get_new_xhr
|
def test_get_new_xhr
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
xhr :get, :new, :params => {:project_id => 'ecookbook'}
|
get :new, :params => {:project_id => 'ecookbook'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'Unallowed characters', response.body
|
assert_include 'Unallowed characters', response.body
|
||||||
end
|
end
|
||||||
@ -203,7 +203,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_new_xhr_with_valid_title_should_redirect_to_edit
|
def test_post_new_xhr_with_valid_title_should_redirect_to_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'New Page'}
|
post :new, :params => {:project_id => 'ecookbook', :title => 'New Page'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body
|
assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body
|
||||||
end
|
end
|
||||||
@ -228,7 +228,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
def test_post_new_xhr_with_invalid_title_should_display_errors
|
def test_post_new_xhr_with_invalid_title_should_display_errors
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}
|
post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_include 'Title has already been taken', response.body
|
assert_include 'Title has already been taken', response.body
|
||||||
end
|
end
|
||||||
@ -581,7 +581,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_preview
|
def test_preview
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :preview, :params => {
|
post :preview, :params => {
|
||||||
:project_id => 1,
|
:project_id => 1,
|
||||||
:id => 'CookBook_documentation',
|
:id => 'CookBook_documentation',
|
||||||
:content => {
|
:content => {
|
||||||
@ -589,14 +589,14 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
:text => 'this is a *previewed text*',
|
:text => 'this is a *previewed text*',
|
||||||
:version => 3
|
:version => 3
|
||||||
}
|
}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'strong', :text => /previewed text/
|
assert_select 'strong', :text => /previewed text/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_new_page
|
def test_preview_new_page
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :preview, :params => {
|
post :preview, :params => {
|
||||||
:project_id => 1,
|
:project_id => 1,
|
||||||
:id => 'New page',
|
:id => 'New page',
|
||||||
:content => {
|
:content => {
|
||||||
@ -604,7 +604,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
:comments => '',
|
:comments => '',
|
||||||
:version => 0
|
:version => 0
|
||||||
}
|
}
|
||||||
}
|
}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'h1', :text => /New page/
|
assert_select 'h1', :text => /New page/
|
||||||
end
|
end
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
|||||||
assert_nil Project.find(3).wiki
|
assert_nil Project.find(3).wiki
|
||||||
|
|
||||||
assert_difference 'Wiki.count' do
|
assert_difference 'Wiki.count' do
|
||||||
xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }}
|
post :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -43,7 +43,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
assert_no_difference 'Wiki.count' do
|
assert_no_difference 'Wiki.count' do
|
||||||
xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }}
|
post :edit, :params => {:id => 3, :wiki => { :start_page => '' }}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
@ -56,7 +56,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
|||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
assert_no_difference 'Wiki.count' do
|
assert_no_difference 'Wiki.count' do
|
||||||
xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }}
|
post :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }}, :xhr => true
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|||||||
@ -320,10 +320,12 @@ module Redmine
|
|||||||
assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match"
|
assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match"
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(method, path, parameters={}, session={}, flash={})
|
def process(action, http_method = 'GET', *args)
|
||||||
if parameters.key?(:params) || parameters.key?(:session)
|
parameters, session, flash = *args
|
||||||
raise ArgumentError if session.present?
|
if args.size == 1 && parameters[:xhr] == true
|
||||||
super method, path, parameters[:params], parameters[:session], parameters.except(:params, :session)
|
xhr http_method.downcase.to_sym, action, parameters.except(:xhr)
|
||||||
|
elsif parameters && (parameters.key?(:params) || parameters.key?(:session) || parameters.key?(:flash))
|
||||||
|
super action, http_method, parameters[:params], parameters[:session], parameters[:flash]
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user