mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 03:15:57 +01: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:
@@ -41,13 +41,17 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
existing_user.login = 'cool_user'
|
||||
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'
|
||||
end
|
||||
|
||||
def test_login_with_invalid_openid_provider
|
||||
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
|
||||
end
|
||||
|
||||
@@ -61,13 +65,17 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
existing_user.login = 'cool_user'
|
||||
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'
|
||||
end
|
||||
|
||||
def test_login_with_openid_with_new_user_created
|
||||
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'
|
||||
user = User.find_by_login('cool_user')
|
||||
assert user
|
||||
@@ -77,7 +85,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
|
||||
def test_login_with_openid_with_new_user_and_self_registration_off
|
||||
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
|
||||
user = User.find_by_login('cool_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
|
||||
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'
|
||||
user = User.find_by_login('cool_user')
|
||||
assert user
|
||||
@@ -96,7 +108,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
|
||||
def test_login_with_openid_with_new_user_created_with_manual_activation
|
||||
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'
|
||||
user = User.find_by_login('cool_user')
|
||||
assert user
|
||||
@@ -109,7 +123,9 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
existing_user.login = 'cool_user'
|
||||
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_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
|
||||
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_select 'input[name=?]', 'user[login]'
|
||||
@@ -141,15 +159,18 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
|
||||
Setting.self_registration = '3'
|
||||
|
||||
assert_difference 'User.count' do
|
||||
post :register, :user => {
|
||||
:login => 'good_blank_user',
|
||||
:password => '',
|
||||
:password_confirmation => '',
|
||||
:firstname => 'Cool',
|
||||
:lastname => 'User',
|
||||
:mail => 'user@somedomain.com',
|
||||
:identity_url => 'http://openid.example.com/good_blank_user'
|
||||
}
|
||||
post :register, :params => {
|
||||
:user => {
|
||||
:login => 'good_blank_user',
|
||||
:password => '',
|
||||
:password_confirmation => '',
|
||||
:firstname => 'Cool',
|
||||
:lastname => 'User',
|
||||
:mail => 'user@somedomain.com',
|
||||
:identity_url => 'http://openid.example.com/good_blank_user'
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
@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_equal 2, @request.session[:user_id]
|
||||
end
|
||||
@@ -66,7 +68,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
'/'
|
||||
]
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -80,7 +86,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
'/redmine'
|
||||
]
|
||||
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
|
||||
end
|
||||
ensure
|
||||
@@ -93,7 +103,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
'//test.foo/fake'
|
||||
]
|
||||
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'
|
||||
end
|
||||
end
|
||||
@@ -120,7 +134,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
'.test.foo'
|
||||
]
|
||||
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'
|
||||
end
|
||||
ensure
|
||||
@@ -128,7 +146,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_login_with_wrong_password
|
||||
post :login, :username => 'admin', :password => 'bad'
|
||||
post :login, :params => {
|
||||
:username => 'admin',
|
||||
:password => 'bad'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
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_include 'locked', flash[:error]
|
||||
assert_nil @request.session[:user_id]
|
||||
@@ -150,7 +174,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
||||
|
||||
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_include 'pending administrator approval', flash[:error]
|
||||
end
|
||||
@@ -160,7 +187,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
User.find(2).update_attribute :status, User::STATUS_REGISTERED
|
||||
|
||||
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_equal 2, @request.session[:registered_user_id]
|
||||
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
|
||||
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_select_error /Something wrong/
|
||||
end
|
||||
@@ -180,7 +213,10 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
def test_login_should_reset_session
|
||||
@controller.expects(:reset_session).once
|
||||
|
||||
post :login, :username => 'jsmith', :password => 'jsmith'
|
||||
post :login, :params => {
|
||||
:username => 'jsmith',
|
||||
:password => 'jsmith'
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
@@ -257,14 +293,17 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
def test_post_register_with_registration_on
|
||||
with_settings :self_registration => '3' do
|
||||
assert_difference 'User.count' do
|
||||
post :register, :user => {
|
||||
:login => 'register',
|
||||
:password => 'secret123',
|
||||
:password_confirmation => 'secret123',
|
||||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
}
|
||||
post :register, :params => {
|
||||
:user => {
|
||||
:login => 'register',
|
||||
:password => 'secret123',
|
||||
:password_confirmation => 'secret123',
|
||||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/my/account'
|
||||
end
|
||||
user = User.order('id DESC').first
|
||||
@@ -280,14 +319,17 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
def test_post_register_with_registration_off_should_redirect
|
||||
with_settings :self_registration => '0' do
|
||||
assert_no_difference 'User.count' do
|
||||
post :register, :user => {
|
||||
:login => 'register',
|
||||
:password => 'test',
|
||||
:password_confirmation => 'test',
|
||||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
}
|
||||
post :register, :params => {
|
||||
:user => {
|
||||
:login => 'register',
|
||||
:password => 'test',
|
||||
:password_confirmation => 'test',
|
||||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/'
|
||||
end
|
||||
end
|
||||
@@ -296,14 +338,21 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
def test_post_register_should_create_user_with_hide_mail_preference
|
||||
with_settings :default_users_hide_mail => '0' do
|
||||
user = new_record(User) do
|
||||
post :register, :user => {
|
||||
:login => 'register',
|
||||
:password => 'secret123', :password_confirmation => 'secret123',
|
||||
:firstname => 'John', :lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
}, :pref => {
|
||||
:hide_mail => '1'
|
||||
}
|
||||
post :register, :params => {
|
||||
:user => {
|
||||
:login => 'register',
|
||||
:password => 'secret123',
|
||||
:password_confirmation => 'secret123',
|
||||
:firstname => 'John',
|
||||
:lastname => 'Doe',
|
||||
:mail => 'register@example.com'
|
||||
|
||||
},
|
||||
:pref => {
|
||||
:hide_mail => '1'
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_equal true, user.pref.hide_mail
|
||||
end
|
||||
@@ -320,7 +369,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
assert_difference 'ActionMailer::Base.deliveries.size' 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'
|
||||
end
|
||||
end
|
||||
@@ -340,7 +391,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
|
||||
assert_difference 'ActionMailer::Base.deliveries.size' 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'
|
||||
end
|
||||
end
|
||||
@@ -351,7 +404,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
def test_lost_password_for_unknown_user_should_fail
|
||||
Token.delete_all
|
||||
assert_no_difference 'Token.count' do
|
||||
post :lost_password, :mail => 'invalid@somenet.foo'
|
||||
post :lost_password, :params => {
|
||||
:mail => 'invalid@somenet.foo'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
@@ -361,7 +416,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
assert User.find(2).lock!
|
||||
|
||||
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'
|
||||
end
|
||||
end
|
||||
@@ -370,7 +427,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
User.any_instance.stubs(:change_password_allowed?).returns(false)
|
||||
|
||||
assert_no_difference 'Token.count' do
|
||||
post :lost_password, :mail => 'JSmith@somenet.foo'
|
||||
post :lost_password, :params => {
|
||||
:mail => 'JSmith@somenet.foo'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
@@ -379,7 +438,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
user = User.find(2)
|
||||
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_equal token.value, request.session[:password_recovery_token]
|
||||
@@ -397,7 +458,9 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_get_lost_password_with_invalid_token_should_redirect
|
||||
get :lost_password, :token => "abcdef"
|
||||
get :lost_password, :params => {
|
||||
:token => "abcdef"
|
||||
}
|
||||
assert_redirected_to '/'
|
||||
end
|
||||
|
||||
@@ -406,7 +469,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
user = User.find(2)
|
||||
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'
|
||||
user.reload
|
||||
assert user.check_password?('newpass123')
|
||||
@@ -422,7 +489,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
token = Token.create!(:action => 'recovery', :user => user)
|
||||
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 ! user.check_password?('newpass123')
|
||||
end
|
||||
@@ -431,7 +502,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
user = User.find(2)
|
||||
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_not_nil Token.find_by_id(token.id), "Token was deleted"
|
||||
|
||||
@@ -445,7 +520,11 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
user.save!
|
||||
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_not_nil Token.find_by_id(token.id), "Token was deleted"
|
||||
|
||||
@@ -460,14 +539,22 @@ class AccountControllerTest < Redmine::ControllerTest
|
||||
user.save!
|
||||
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_equal false, user.reload.must_change_passwd
|
||||
end
|
||||
|
||||
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 '/'
|
||||
end
|
||||
|
||||
|
||||
@@ -30,7 +30,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
|
||||
|
||||
def test_project_index
|
||||
get :index, :id => 1, :with_subprojects => 0
|
||||
get :index, :params => {
|
||||
:id => 1,
|
||||
:with_subprojects => 0
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
|
||||
@@ -38,12 +41,17 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_project_index_with_invalid_project_id_should_respond_404
|
||||
get :index, :id => 299
|
||||
get :index, :params => {
|
||||
:id => 299
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
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_select 'h3', :text => /#{3.days.ago.to_date.day}/
|
||||
@@ -64,7 +72,9 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_user_index
|
||||
@request.session[:user_id] = 1
|
||||
get :index, :user_id => 2
|
||||
get :index, :params => {
|
||||
:user_id => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
|
||||
@@ -77,12 +87,17 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_index_atom_feed
|
||||
get :index, :format => 'atom', :with_subprojects => 0
|
||||
get :index, :params => {
|
||||
:format => 'atom',
|
||||
:with_subprojects => 0
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'feed' do
|
||||
@@ -95,15 +110,18 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index_atom_feed_with_explicit_selection
|
||||
get :index, :format => 'atom', :with_subprojects => 0,
|
||||
:show_changesets => 1,
|
||||
:show_documents => 1,
|
||||
:show_files => 1,
|
||||
:show_issues => 1,
|
||||
:show_messages => 1,
|
||||
:show_news => 1,
|
||||
:show_time_entries => 1,
|
||||
:show_wiki_edits => 1
|
||||
get :index, :params => {
|
||||
:format => 'atom',
|
||||
:with_subprojects => 0,
|
||||
:show_changesets => 1,
|
||||
:show_documents => 1,
|
||||
:show_files => 1,
|
||||
:show_issues => 1,
|
||||
:show_messages => 1,
|
||||
:show_news => 1,
|
||||
:show_time_entries => 1,
|
||||
:show_wiki_edits => 1
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
|
||||
@@ -118,7 +136,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_index_atom_feed_with_one_item_type
|
||||
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_select 'title', :text => /Issues/
|
||||
@@ -126,7 +147,10 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_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
|
||||
@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_equal %w(issues messages), User.find(2).pref.activity_scope.sort
|
||||
end
|
||||
@@ -182,7 +210,9 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
||||
def test_index_up_to_yesterday_should_show_next_page_link
|
||||
@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_select '.pagination a', :text => /Previous/
|
||||
assert_select '.pagination a', :text => /Next/
|
||||
|
||||
@@ -43,13 +43,18 @@ class AdminControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_projects_with_status_filter
|
||||
get :projects, :status => 1
|
||||
get :projects, :params => {
|
||||
:status => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr.project.closed', 0
|
||||
end
|
||||
|
||||
def test_projects_with_name_filter
|
||||
get :projects, :name => 'store', :status => ''
|
||||
get :projects, :params => {
|
||||
:name => 'store',
|
||||
:status => ''
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'tr.project td.name', :text => 'OnlineStore'
|
||||
@@ -58,7 +63,9 @@ class AdminControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_load_default_configuration_data
|
||||
delete_configuration_data
|
||||
post :default_configuration, :lang => 'fr'
|
||||
post :default_configuration, :params => {
|
||||
:lang => 'fr'
|
||||
}
|
||||
assert_response :redirect
|
||||
assert_nil flash[:error]
|
||||
assert IssueStatus.find_by_name('Nouveau')
|
||||
@@ -67,7 +74,9 @@ class AdminControllerTest < Redmine::ControllerTest
|
||||
def test_load_default_configuration_data_should_rescue_error
|
||||
delete_configuration_data
|
||||
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_not_nil flash[:error]
|
||||
assert_match /Something went wrong/, flash[:error]
|
||||
|
||||
@@ -36,7 +36,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
def test_show_diff
|
||||
['inline', 'sbs'].each do |dt|
|
||||
# 060719210727_changeset_utf8.diff
|
||||
get :show, :id => 14, :type => dt
|
||||
get :show, :params => {
|
||||
:id => 14,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_equal 'text/html', @response.content_type
|
||||
@@ -50,7 +53,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
with_settings :repositories_encodings => 'UTF-8' do
|
||||
['inline', 'sbs'].each do |dt|
|
||||
# 060719210727_changeset_iso8859-1.diff
|
||||
get :show, :id => 5, :type => dt
|
||||
get :show, :params => {
|
||||
:id => 5,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
['inline', 'sbs'].each do |dt|
|
||||
# 060719210727_changeset_iso8859-1.diff
|
||||
get :show, :id => 5, :type => dt
|
||||
get :show, :params => {
|
||||
:id => 5,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_equal 'text/html', @response.content_type
|
||||
@@ -84,12 +93,17 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert_nil user.pref[:diff_type]
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
get :show, :id => 5
|
||||
get :show, :params => {
|
||||
:id => 5
|
||||
}
|
||||
assert_response :success
|
||||
user.reload
|
||||
assert_equal "inline", user.pref[:diff_type]
|
||||
|
||||
get :show, :id => 5, :type => 'sbs'
|
||||
get :show, :params => {
|
||||
:id => 5,
|
||||
:type => 'sbs'
|
||||
}
|
||||
assert_response :success
|
||||
user.reload
|
||||
assert_equal "sbs", user.pref[:diff_type]
|
||||
@@ -103,14 +117,19 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert a.save
|
||||
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_equal 'text/html', @response.content_type
|
||||
assert_select 'th.filename', :text => 'test1.txt'
|
||||
end
|
||||
|
||||
def test_show_text_file
|
||||
get :show, :id => 4
|
||||
get :show, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
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')
|
||||
|
||||
get :show, :id => a.id
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'tr#L1' do
|
||||
@@ -144,7 +165,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert a.save
|
||||
assert_equal 'iso8859-1.txt', a.filename
|
||||
|
||||
get :show, :id => a.id
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'tr#L7' do
|
||||
@@ -163,7 +186,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert a.save
|
||||
assert_equal 'iso8859-1.txt', a.filename
|
||||
|
||||
get :show, :id => a.id
|
||||
get :show, :params => {
|
||||
:id => a.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'tr#L7' do
|
||||
@@ -177,7 +202,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
with_settings :file_max_size_displayed => 512 do
|
||||
Attachment.find(4).update_attribute :filesize, 754.kilobyte
|
||||
get :show, :id => 4
|
||||
get :show, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select '.nodata', :text => 'No preview available'
|
||||
@@ -187,7 +214,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_show_image
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => 16
|
||||
get :show, :params => {
|
||||
:id => 16
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename
|
||||
@@ -195,21 +224,27 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_show_other
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => 6
|
||||
get :show, :params => {
|
||||
:id => 6
|
||||
}
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select '.nodata', :text => 'No preview available'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
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'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_show_file_from_private_issue_with_permission
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => 15
|
||||
get :show, :params => {
|
||||
:id => 15
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /private.diff/
|
||||
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)
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => attachment.id
|
||||
get :show, :params => {
|
||||
:id => attachment.id
|
||||
}
|
||||
assert_response 200
|
||||
end
|
||||
|
||||
@@ -229,24 +266,32 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
||||
|
||||
@request.session[:user_id] = 3
|
||||
get :show, :id => attachment.id
|
||||
get :show, :params => {
|
||||
:id => attachment.id
|
||||
}
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_show_invalid_should_respond_with_404
|
||||
get :show, :id => 999
|
||||
get :show, :params => {
|
||||
:id => 999
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_download_text_file
|
||||
get :download, :id => 4
|
||||
get :download, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/x-ruby', @response.content_type
|
||||
etag = @response.etag
|
||||
assert_not_nil etag
|
||||
|
||||
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
||||
get :download, :id => 4
|
||||
get :download, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response 304
|
||||
|
||||
set_tmp_attachments_directory
|
||||
@@ -260,21 +305,27 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
:container => Issue.find(1)
|
||||
)
|
||||
|
||||
get :download, :id => attachment.id
|
||||
get :download, :params => {
|
||||
:id => attachment.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', @response.content_type
|
||||
end
|
||||
|
||||
def test_download_version_file_with_issue_tracking_disabled
|
||||
Project.find(1).disable_module! :issue_tracking
|
||||
get :download, :id => 9
|
||||
get :download, :params => {
|
||||
:id => 9
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_download_should_assign_content_type_if_blank
|
||||
Attachment.find(4).update_attribute(:content_type, '')
|
||||
|
||||
get :download, :id => 4
|
||||
get :download, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/x-ruby', @response.content_type
|
||||
set_tmp_attachments_directory
|
||||
@@ -283,20 +334,26 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
def test_download_should_assign_better_content_type_than_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_equal 'text/x-ruby', @response.content_type
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
def test_download_missing_file
|
||||
get :download, :id => 2
|
||||
get :download, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_response 404
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
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'
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
@@ -305,7 +362,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
def test_thumbnail
|
||||
Attachment.clear_thumbnails
|
||||
@request.session[:user_id] = 2
|
||||
get :thumbnail, :id => 16
|
||||
get :thumbnail, :params => {
|
||||
:id => 16
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'image/png', response.content_type
|
||||
|
||||
@@ -313,7 +372,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert_not_nil etag
|
||||
|
||||
@request.env["HTTP_IF_NONE_MATCH"] = etag
|
||||
get :thumbnail, :id => 16
|
||||
get :thumbnail, :params => {
|
||||
:id => 16
|
||||
}
|
||||
assert_response 304
|
||||
end
|
||||
|
||||
@@ -321,20 +382,28 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :thumbnail, :id => 16, :size => 2000
|
||||
get :thumbnail, :params => {
|
||||
:id => 16,
|
||||
:size => 2000
|
||||
}
|
||||
end
|
||||
|
||||
def test_thumbnail_should_round_size
|
||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 250}
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :thumbnail, :id => 16, :size => 260
|
||||
get :thumbnail, :params => {
|
||||
:id => 16,
|
||||
:size => 260
|
||||
}
|
||||
end
|
||||
|
||||
def test_thumbnail_should_return_404_for_non_image_attachment
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :thumbnail, :id => 15
|
||||
get :thumbnail, :params => {
|
||||
:id => 15
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
@@ -342,12 +411,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
Attachment.any_instance.stubs(:thumbnail).returns(nil)
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :thumbnail, :id => 16
|
||||
get :thumbnail, :params => {
|
||||
:id => 16
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
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'
|
||||
end
|
||||
else
|
||||
@@ -356,7 +429,10 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_all
|
||||
@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_select 'form[action=?]', '/attachments/issues/2' do
|
||||
@@ -372,25 +448,45 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_update_all
|
||||
@request.session[:user_id] = 2
|
||||
patch :update_all, :object_type => 'issues', :object_id => '2', :attachments => {
|
||||
'1' => {:filename => 'newname.text', :description => ''},
|
||||
'4' => {:filename => 'newname.rb', :description => 'Renamed'},
|
||||
patch :update_all, :params => {
|
||||
:object_type => 'issues',
|
||||
:object_id => '2',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
:filename => 'newname.text',
|
||||
:description => ''
|
||||
},
|
||||
'4' => {
|
||||
:filename => 'newname.rb',
|
||||
:description => 'Renamed'
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
assert_response 302
|
||||
@@ -401,9 +497,20 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_all_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
patch :update_all, :object_type => 'issues', :object_id => '3', :attachments => {
|
||||
'1' => {:filename => '', :description => ''},
|
||||
'4' => {:filename => 'newname.rb', :description => 'Renamed'},
|
||||
patch :update_all, :params => {
|
||||
:object_type => 'issues',
|
||||
:object_id => '3',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
:filename => '',
|
||||
:description => ''
|
||||
},
|
||||
'4' => {
|
||||
:filename => 'newname.rb',
|
||||
:description => 'Renamed'
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
@@ -422,7 +529,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
assert_difference 'issue.attachments.count', -1 do
|
||||
assert_difference 'Journal.count' do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook'
|
||||
end
|
||||
end
|
||||
@@ -439,7 +548,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
delete :destroy, :id => 3
|
||||
delete :destroy, :params => {
|
||||
:id => 3
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
@@ -448,7 +559,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
delete :destroy, :id => 8
|
||||
delete :destroy, :params => {
|
||||
:id => 8
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
@@ -457,7 +570,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
delete :destroy, :id => 9
|
||||
delete :destroy, :params => {
|
||||
:id => 9
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
@@ -467,7 +582,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
delete :destroy, :id => 9
|
||||
delete :destroy, :params => {
|
||||
:id => 9
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
@@ -475,7 +592,9 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
def test_destroy_without_permission
|
||||
set_tmp_attachments_directory
|
||||
assert_no_difference 'Attachment.count' do
|
||||
delete :destroy, :id => 3
|
||||
delete :destroy, :params => {
|
||||
:id => 3
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
assert Attachment.find_by_id(3)
|
||||
|
||||
@@ -40,13 +40,23 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new_with_invalid_type_should_respond_with_404
|
||||
get :new, :type => 'foo'
|
||||
get :new, :params => {
|
||||
:type => 'foo'
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_create
|
||||
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'
|
||||
end
|
||||
|
||||
@@ -59,16 +69,24 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'AuthSourceLdap.count' do
|
||||
post :create, :type => 'AuthSourceLdap',
|
||||
:auth_source => {:name => 'Test', :host => '',
|
||||
:port => '389', :attr_login => 'cn'}
|
||||
post :create, :params => {
|
||||
:type => 'AuthSourceLdap',
|
||||
:auth_source => {
|
||||
:name => 'Test',
|
||||
:host => '',
|
||||
:port => '389',
|
||||
:attr_login => 'cn'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
assert_select_error /host cannot be blank/i
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#auth_source_form' do
|
||||
@@ -79,21 +97,31 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
def test_edit_should_not_contain_password
|
||||
AuthSource.find(1).update_column :account_password, 'secret'
|
||||
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[value=secret]', 0
|
||||
assert_select 'input[name=dummy_password][value^=xxxxxx]'
|
||||
end
|
||||
|
||||
def test_edit_invalid_should_respond_with_404
|
||||
get :edit, :id => 99
|
||||
get :edit, :params => {
|
||||
:id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_update
|
||||
put :update, :id => 1,
|
||||
:auth_source => {:name => 'Renamed', :host => '192.168.0.10',
|
||||
:port => '389', :attr_login => 'uid'}
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:auth_source => {
|
||||
:name => 'Renamed',
|
||||
:host => '192.168.0.10',
|
||||
:port => '389',
|
||||
:attr_login => 'uid'
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/auth_sources'
|
||||
source = AuthSourceLdap.find(1)
|
||||
assert_equal 'Renamed', source.name
|
||||
@@ -101,16 +129,24 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_update_with_failure
|
||||
put :update, :id => 1,
|
||||
:auth_source => {:name => 'Renamed', :host => '',
|
||||
:port => '389', :attr_login => 'uid'}
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:auth_source => {
|
||||
:name => 'Renamed',
|
||||
:host => '',
|
||||
:port => '389',
|
||||
:attr_login => 'uid'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /host cannot be blank/i
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'AuthSourceLdap.count', -1 do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/auth_sources'
|
||||
end
|
||||
end
|
||||
@@ -119,7 +155,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
User.find(2).update_attribute :auth_source_id, 1
|
||||
|
||||
assert_no_difference 'AuthSourceLdap.count' do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/auth_sources'
|
||||
end
|
||||
end
|
||||
@@ -127,7 +165,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
def test_test_connection
|
||||
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_not_nil flash[:notice]
|
||||
assert_match /successful/i, flash[:notice]
|
||||
@@ -136,7 +176,9 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
|
||||
def test_test_connection_with_failure
|
||||
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_not_nil 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}
|
||||
])
|
||||
|
||||
get :autocomplete_for_new_user, :term => 'foo'
|
||||
get :autocomplete_for_new_user, :params => {
|
||||
:term => 'foo'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
@@ -29,49 +29,73 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
||||
:journals, :journal_details
|
||||
|
||||
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_include "recipe", response.body
|
||||
end
|
||||
|
||||
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_include "recipe", response.body
|
||||
end
|
||||
|
||||
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_include "Bug #13", response.body
|
||||
end
|
||||
|
||||
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_include "Bug #13", response.body
|
||||
end
|
||||
|
||||
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_include "Bug #13", response.body
|
||||
end
|
||||
|
||||
def test_auto_complete_without_project_should_search_all_projects
|
||||
get :issues, :q => '13'
|
||||
get :issues, :params => {
|
||||
:q => '13'
|
||||
}
|
||||
assert_response :success
|
||||
assert_include "Bug #13", response.body
|
||||
end
|
||||
|
||||
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_not_include "Bug #13", response.body
|
||||
end
|
||||
|
||||
def test_issues_should_return_json
|
||||
get :issues, :project_id => 'subproject1', :q => '13'
|
||||
get :issues, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:q => '13'
|
||||
}
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
@@ -83,21 +107,33 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_include "Issue due today", response.body
|
||||
assert_not_include "closed", response.body
|
||||
end
|
||||
|
||||
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_include "closed", response.body
|
||||
assert_not_include "Issue due today", response.body
|
||||
end
|
||||
|
||||
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_include "issue", response.body
|
||||
assert_not_include "Bug #12: Closed issue on a locked version", response.body
|
||||
|
||||
@@ -25,20 +25,26 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.boards'
|
||||
end
|
||||
|
||||
def test_index_not_found
|
||||
get :index, :project_id => 97
|
||||
get :index, :params => {
|
||||
:project_id => 97
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_index_should_show_messages_if_only_one_board
|
||||
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_select 'table.boards', 0
|
||||
@@ -46,7 +52,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :project_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.messages tbody' do
|
||||
@@ -58,7 +67,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
Message.update_all(:sticky => 0)
|
||||
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_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)
|
||||
old_topic.children << reply
|
||||
|
||||
get :show, :project_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :project_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#message-form' do
|
||||
@@ -97,20 +115,29 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'feed > entry > title', :text => 'Help: RE: post 2'
|
||||
end
|
||||
|
||||
def test_show_not_found
|
||||
get :index, :project_id => 1, :id => 97
|
||||
get :index, :params => {
|
||||
:project_id => 1,
|
||||
:id => 97
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'board[parent_id]' do
|
||||
@@ -128,7 +155,9 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
Project.find(1).boards.delete_all
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'board[parent_id]', 0
|
||||
@@ -137,7 +166,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_create
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||
board = Board.order('id DESC').first
|
||||
@@ -148,7 +183,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_parent
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||
board = Board.order('id DESC').first
|
||||
@@ -158,7 +200,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_response :success
|
||||
assert_select_error /Name cannot be blank/
|
||||
@@ -166,7 +214,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :project_id => 1, :id => 2
|
||||
get :edit, :params => {
|
||||
:project_id => 1,
|
||||
:id => 2
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'board[name]', 'Discussion'
|
||||
end
|
||||
@@ -174,7 +225,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_edit_with_parent
|
||||
board = Board.generate!(:project_id => 1, :parent_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_select 'select[name=?]', 'board[parent_id]' do
|
||||
@@ -185,7 +239,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_update
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||
assert_equal 'Testing', Board.find(2).name
|
||||
@@ -193,7 +254,13 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_position
|
||||
@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'
|
||||
board = Board.find(2)
|
||||
assert_equal 1, board.position
|
||||
@@ -201,7 +268,14 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_with_failure
|
||||
@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_select_error /Name cannot be blank/
|
||||
end
|
||||
@@ -209,7 +283,10 @@ class BoardsControllerTest < Redmine::ControllerTest
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Board.count', -1 do
|
||||
delete :destroy, :project_id => 1, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:project_id => 1,
|
||||
:id => 2
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/settings/boards'
|
||||
assert_nil Board.find_by_id(2)
|
||||
|
||||
@@ -32,14 +32,18 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
||||
:enumerations
|
||||
|
||||
def test_show
|
||||
get :show, :project_id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_show_should_run_custom_queries
|
||||
@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_select 'h2', :text => 'Calendar Query'
|
||||
end
|
||||
@@ -51,7 +55,10 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_week_number_calculation
|
||||
with_settings :start_of_week => 7 do
|
||||
get :show, :month => '1', :year => '2010'
|
||||
get :show, :params => {
|
||||
:month => '1',
|
||||
:year => '2010'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -68,7 +75,10 @@ class CalendarsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
with_settings :start_of_week => 1 do
|
||||
get :show, :month => '1', :year => '2010'
|
||||
get :show, :params => {
|
||||
:month => '1',
|
||||
:year => '2010'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
@@ -26,7 +26,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_add_comment
|
||||
@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'
|
||||
|
||||
comment = News.find(1).comments.last
|
||||
@@ -38,7 +43,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
||||
def test_empty_comment_should_not_be_added
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference 'Comment.count' do
|
||||
post :create, :id => 1, :comment => { :comments => '' }
|
||||
post :create, :params => {
|
||||
:id => 1,
|
||||
:comment => {
|
||||
:comments => ''
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
assert_redirected_to '/news/1'
|
||||
end
|
||||
@@ -48,7 +58,12 @@ class CommentsControllerTest < Redmine::ControllerTest
|
||||
News.any_instance.stubs(:commentable?).returns(false)
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -56,7 +71,10 @@ class CommentsControllerTest < Redmine::ControllerTest
|
||||
def test_destroy_comment
|
||||
comments_count = News.find(1).comments.size
|
||||
@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_nil Comment.find_by_id(2)
|
||||
assert_equal comments_count - 1, News.find(1).comments.size
|
||||
|
||||
@@ -35,7 +35,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_context_menu_one_issue
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
with_settings :default_language => 'en' do
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1, 2]
|
||||
get :issues, :params => {
|
||||
:ids => [1, 2]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1, 2, 6]
|
||||
get :issues, :params => {
|
||||
:ids => [1, 2, 6]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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',
|
||||
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
|
||||
assert_select "li.cf_#{field.id}" do
|
||||
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',
|
||||
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||
@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 'a[href="#"]', :text => 'List'
|
||||
@@ -132,7 +144,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
issue.custom_field_values = {field.id => 'Bar'}
|
||||
issue.save!
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
|
||||
assert_select "li.cf_#{field.id}" do
|
||||
assert_select 'a[href="#"]', :text => 'List'
|
||||
@@ -147,7 +161,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool',
|
||||
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
|
||||
assert_select "li.cf_#{field.id}" do
|
||||
assert_select 'a[href="#"]', :text => 'Bool'
|
||||
@@ -164,7 +180,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
field = IssueCustomField.create!(:name => 'User', :field_format => 'user',
|
||||
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
|
||||
assert_select "li.cf_#{field.id}" do
|
||||
assert_select 'a[href="#"]', :text => 'User'
|
||||
@@ -179,7 +197,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
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])
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
|
||||
assert_select "li.cf_#{field.id}" do
|
||||
assert_select 'a[href="#"]', :text => 'Version'
|
||||
@@ -197,7 +217,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1)
|
||||
|
||||
@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_#{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
|
||||
@request.session[:user_id] = 2
|
||||
get :issues, :ids => [1]
|
||||
get :issues, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
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_select 'a', :text => 'eCookbook - Shared'
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@@ -233,7 +261,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_time_entries_context_menu
|
||||
@request.session[:user_id] = 2
|
||||
get :time_entries, :ids => [1, 2]
|
||||
get :time_entries, :params => {
|
||||
:ids => [1, 2]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'a:not(.disabled)', :text => 'Edit'
|
||||
@@ -241,7 +271,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_context_menu_for_one_time_entry
|
||||
@request.session[:user_id] = 2
|
||||
get :time_entries, :ids => [1]
|
||||
get :time_entries, :params => {
|
||||
:ids => [1]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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"])
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :time_entries, :ids => [1, 2]
|
||||
get :time_entries, :params => {
|
||||
:ids => [1, 2]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
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_select 'a:not(.disabled)', :text => 'Edit'
|
||||
@@ -281,7 +317,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_select 'a.disabled', :text => 'Edit'
|
||||
|
||||
@@ -30,7 +30,9 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index, :custom_field_id => @field.id
|
||||
get :index, :params => {
|
||||
:custom_field_id => @field.id
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'ul#custom_field_enumerations' do
|
||||
@@ -40,7 +42,12 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -53,16 +60,34 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_xhr
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
def test_update_each
|
||||
put :update_each, :custom_field_id => @field.id, :custom_field_enumerations => {
|
||||
@bar.id => {:position => "1", :name => "Baz", :active => "1"},
|
||||
@foo.id => {:position => "2", :name => "Foo", :active => "0"}
|
||||
}
|
||||
put :update_each, :params => {
|
||||
:custom_field_id => @field.id,
|
||||
:custom_field_enumerations => {
|
||||
@bar.id => {
|
||||
:position => "1",
|
||||
:name => "Baz",
|
||||
:active => "1"
|
||||
},
|
||||
@foo.id => {
|
||||
:position => "2",
|
||||
:name => "Foo",
|
||||
:active => "0"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
|
||||
@bar.reload
|
||||
@@ -78,7 +103,10 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -93,7 +121,10 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
group.save!
|
||||
|
||||
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_select 'select[name=?]', 'reassign_to_id'
|
||||
@@ -106,7 +137,11 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
|
||||
group.save!
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@@ -53,7 +53,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
def test_new_should_work_for_each_customized_class_and_format
|
||||
custom_field_classes.each do |klass|
|
||||
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_select 'form#custom_field_form' do
|
||||
@@ -67,7 +72,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new_should_have_string_default_format
|
||||
get :new, :type => 'IssueCustomField'
|
||||
get :new, :params => {
|
||||
:type => 'IssueCustomField'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'custom_field[field_format]' do
|
||||
@@ -76,7 +83,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new_issue_custom_field
|
||||
get :new, :type => 'IssueCustomField'
|
||||
get :new, :params => {
|
||||
:type => 'IssueCustomField'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form#custom_field_form' do
|
||||
@@ -91,7 +100,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'form#custom_field_form' do
|
||||
@@ -101,19 +112,34 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'input[name=?]', 'custom_field[default_value]'
|
||||
end
|
||||
|
||||
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_select 'textarea[name=?]', 'custom_field[default_value]'
|
||||
end
|
||||
|
||||
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_select 'select[name=?]', 'custom_field[default_value]' do
|
||||
assert_select 'option', 3
|
||||
@@ -121,27 +147,54 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select '[name=?]', 'custom_field[default_value]', 0
|
||||
end
|
||||
|
||||
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_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_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_select '[name=?]', 'custom_field[full_width_layout]', 0
|
||||
end
|
||||
|
||||
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_equal 'text/javascript', response.content_type
|
||||
|
||||
@@ -149,7 +202,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'input[type=radio][name=type]'
|
||||
@@ -157,19 +212,23 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_list_custom_field
|
||||
field = new_record(IssueCustomField) do
|
||||
post :create, :type => "IssueCustomField",
|
||||
:custom_field => {:name => "test_post_new_list",
|
||||
:default_value => "",
|
||||
:min_length => "0",
|
||||
:searchable => "0",
|
||||
:regexp => "",
|
||||
:is_for_all => "1",
|
||||
:possible_values => "0.1\n0.2\n",
|
||||
:max_length => "0",
|
||||
:is_filter => "0",
|
||||
:is_required =>"0",
|
||||
:field_format => "list",
|
||||
:tracker_ids => ["1", ""]}
|
||||
post :create, :params => {
|
||||
:type => "IssueCustomField",
|
||||
:custom_field => {
|
||||
:name => "test_post_new_list",
|
||||
:default_value => "",
|
||||
:min_length => "0",
|
||||
:searchable => "0",
|
||||
:regexp => "",
|
||||
:is_for_all => "1",
|
||||
:possible_values => "0.1\n0.2\n",
|
||||
:max_length => "0",
|
||||
:is_filter => "0",
|
||||
:is_required =>"0",
|
||||
:field_format => "list",
|
||||
:tracker_ids => ["1", ""]
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to "/custom_fields/#{field.id}/edit"
|
||||
assert_equal "test_post_new_list", field.name
|
||||
@@ -179,9 +238,16 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_project_ids
|
||||
assert_difference 'CustomField.count' do
|
||||
post :create, :type => "IssueCustomField", :custom_field => {
|
||||
:name => "foo", :field_format => "string", :is_for_all => "0", :project_ids => ["1", "3", ""]
|
||||
}
|
||||
post :create, :params => {
|
||||
:type => "IssueCustomField",
|
||||
:custom_field => {
|
||||
:name => "foo",
|
||||
:field_format => "string",
|
||||
:is_for_all => "0",
|
||||
:project_ids => ["1", "3", ""]
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
field = IssueCustomField.order("id desc").first
|
||||
@@ -190,7 +256,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'CustomField.count' do
|
||||
post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
|
||||
post :create, :params => {
|
||||
:type => "IssueCustomField",
|
||||
:custom_field => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
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
|
||||
assert_no_difference 'CustomField.count' do
|
||||
post :create, :custom_field => {:name => ''}
|
||||
post :create, :params => {
|
||||
:custom_field => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select 'input[type=radio][name=type]'
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
|
||||
end
|
||||
|
||||
def test_edit_invalid_custom_field_should_render_404
|
||||
get :edit, :id => 99
|
||||
get :edit, :params => {
|
||||
:id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
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'
|
||||
|
||||
field = CustomField.find(1)
|
||||
@@ -224,7 +308,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_update_with_failure
|
||||
put :update, :id => 1, :custom_field => {:name => ''}
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:custom_field => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
@@ -235,7 +324,9 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
|
||||
assert_difference 'CustomField.count', -1 do
|
||||
assert_difference 'CustomValue.count', - custom_values_count do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
|
||||
get :index, :project_id => 'ecookbook'
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Default category selected in the new document form
|
||||
@@ -44,19 +46,28 @@ class DocumentsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'h3', :text => '2007-02-12'
|
||||
end
|
||||
|
||||
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_select 'h3', :text => 'T'
|
||||
end
|
||||
|
||||
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_select 'h3', :text => 'John Smith'
|
||||
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.
|
||||
LOREM
|
||||
|
||||
get :index, :project_id => 'ecookbook'
|
||||
get :index, :params => {
|
||||
:project_id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# should only truncate on new lines to avoid breaking wiki formatting
|
||||
@@ -79,13 +92,17 @@ LOREM
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -95,11 +112,18 @@ LOREM
|
||||
set_tmp_attachments_directory
|
||||
|
||||
with_settings :notified_events => %w(document_added) do
|
||||
post :create, :project_id => 'ecookbook',
|
||||
:document => { :title => 'DocumentsControllerTest#test_post_new',
|
||||
:description => 'This is a new document',
|
||||
:category_id => 2},
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:document => {
|
||||
:title => 'DocumentsControllerTest#test_post_new',
|
||||
:description => 'This is a new document',
|
||||
:category_id => 2
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/documents'
|
||||
|
||||
@@ -114,7 +138,12 @@ LOREM
|
||||
def test_create_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference 'Document.count' do
|
||||
post :create, :project_id => 'ecookbook', :document => { :title => ''}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:document => {
|
||||
:title => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /title cannot be blank/i
|
||||
@@ -125,11 +154,14 @@ LOREM
|
||||
category2 = Enumeration.find_by_name('User documentation')
|
||||
category2.update_attributes(:is_default => true)
|
||||
category1 = Enumeration.find_by_name('Uncategorized')
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:document => { :title => 'no default',
|
||||
:description => 'This is a new document',
|
||||
:category_id => category1.id }
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:document => {
|
||||
:title => 'no default',
|
||||
:description => 'This is a new document',
|
||||
:category_id => category1.id
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/documents'
|
||||
doc = Document.find_by_title('no default')
|
||||
assert_not_nil doc
|
||||
@@ -139,13 +171,20 @@ LOREM
|
||||
|
||||
def test_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_update
|
||||
@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'
|
||||
document = Document.find(1)
|
||||
assert_equal 'test_update', document.title
|
||||
@@ -153,7 +192,12 @@ LOREM
|
||||
|
||||
def test_update_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
put :update, :id => 1, :document => {:title => ''}
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:document => {
|
||||
:title => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /title cannot be blank/i
|
||||
end
|
||||
@@ -161,7 +205,9 @@ LOREM
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Document.count', -1 do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/documents'
|
||||
assert_nil Document.find_by_id(1)
|
||||
@@ -170,8 +216,13 @@ LOREM
|
||||
def test_add_attachment
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count' do
|
||||
post :add_attachment, :id => 1,
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
post :add_attachment, :params => {
|
||||
:id => 1,
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
attachment = Attachment.order('id DESC').first
|
||||
assert_equal Document.find(1), attachment.container
|
||||
|
||||
@@ -26,7 +26,9 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_index_with_no_additional_emails
|
||||
@request.session[:user_id] = 2
|
||||
get :index, :user_id => 2
|
||||
get :index, :params => {
|
||||
:user_id => 2
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -34,7 +36,9 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||
|
||||
get :index, :user_id => 2
|
||||
get :index, :params => {
|
||||
:user_id => 2
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '.email', :text => 'another@somenet.foo'
|
||||
end
|
||||
@@ -43,27 +47,39 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_include 'another@somenet.foo', response.body
|
||||
end
|
||||
|
||||
def test_index_by_admin_should_be_allowed
|
||||
@request.session[:user_id] = 1
|
||||
get :index, :user_id => 2
|
||||
get :index, :params => {
|
||||
:user_id => 2
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_index_by_another_user_should_be_denied
|
||||
@request.session[:user_id] = 3
|
||||
get :index, :user_id => 2
|
||||
get :index, :params => {
|
||||
:user_id => 2
|
||||
}
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_create
|
||||
@request.session[:user_id] = 2
|
||||
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_redirected_to '/users/2/email_addresses'
|
||||
end
|
||||
@@ -75,7 +91,13 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
def test_create_as_js
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -83,7 +105,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
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_select_error /email is invalid/i
|
||||
end
|
||||
@@ -92,7 +119,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
def test_create_should_send_security_notification
|
||||
@request.session[:user_id] = 2
|
||||
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_mail_body_match '0.0.0.0', mail
|
||||
@@ -109,7 +141,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_equal false, email.reload.notify
|
||||
@@ -119,7 +155,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_equal false, email.reload.notify
|
||||
@@ -130,7 +171,12 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||
|
||||
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_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')
|
||||
|
||||
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_redirected_to '/users/2/email_addresses'
|
||||
end
|
||||
@@ -156,7 +205,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -165,7 +218,10 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -175,7 +231,11 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
email = EmailAddress.create!(:user_id => 2, :address => 'another@somenet.foo')
|
||||
|
||||
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_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
|
||||
|
||||
def test_new
|
||||
get :new, :type => 'IssuePriority'
|
||||
get :new, :params => {
|
||||
:type => 'IssuePriority'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
|
||||
@@ -45,13 +47,20 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new_with_invalid_type_should_respond_with_404
|
||||
get :new, :type => 'UnknownType'
|
||||
get :new, :params => {
|
||||
:type => 'UnknownType'
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_create
|
||||
assert_difference 'IssuePriority.count' do
|
||||
post :create, :enumeration => {:type => 'IssuePriority', :name => 'Lowest'}
|
||||
post :create, :params => {
|
||||
:enumeration => {
|
||||
:type => 'IssuePriority',
|
||||
:name => 'Lowest'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/enumerations'
|
||||
e = IssuePriority.find_by_name('Lowest')
|
||||
@@ -60,26 +69,41 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
|
||||
post :create, :params => {
|
||||
:enumeration => {
|
||||
:type => 'IssuePriority',
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => 6
|
||||
get :edit, :params => {
|
||||
:id => 6
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
|
||||
end
|
||||
|
||||
def test_edit_invalid_should_respond_with_404
|
||||
get :edit, :id => 999
|
||||
get :edit, :params => {
|
||||
:id => 999
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_update
|
||||
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
|
||||
assert_redirected_to '/enumerations'
|
||||
e = IssuePriority.find(6)
|
||||
@@ -88,7 +112,13 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_with_failure
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
|
||||
put :update, :params => {
|
||||
:id => 6,
|
||||
:enumeration => {
|
||||
:type => 'IssuePriority',
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
@@ -96,7 +126,9 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_enumeration_not_in_use
|
||||
assert_difference 'IssuePriority.count', -1 do
|
||||
delete :destroy, :id => 7
|
||||
delete :destroy, :params => {
|
||||
:id => 7
|
||||
}
|
||||
end
|
||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||
assert_nil Enumeration.find_by_id(7)
|
||||
@@ -104,7 +136,9 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_enumeration_in_use
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
delete :destroy, :id => 4
|
||||
delete :destroy, :params => {
|
||||
:id => 4
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
@@ -117,7 +151,10 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
def test_destroy_enumeration_in_use_with_reassignment
|
||||
issue = Issue.where(:priority_id => 4).first
|
||||
assert_difference 'IssuePriority.count', -1 do
|
||||
delete :destroy, :id => 4, :reassign_to_id => 6
|
||||
delete :destroy, :params => {
|
||||
:id => 4,
|
||||
:reassign_to_id => 6
|
||||
}
|
||||
end
|
||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||
assert_nil Enumeration.find_by_id(4)
|
||||
@@ -127,7 +164,10 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_enumeration_in_use_with_blank_reassignment
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
delete :destroy, :id => 4, :reassign_to_id => ''
|
||||
delete :destroy, :params => {
|
||||
:id => 4,
|
||||
:reassign_to_id => ''
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -37,7 +37,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# file attached to the project
|
||||
@@ -49,7 +51,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'version_id'
|
||||
@@ -58,7 +62,9 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
def test_new_without_versions
|
||||
Version.delete_all
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'version_id', 0
|
||||
@@ -71,8 +77,14 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
|
||||
with_settings :notified_events => %w(file_added) do
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:version_id => '',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
end
|
||||
end
|
||||
@@ -92,8 +104,14 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => '2',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:version_id => '2',
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/files'
|
||||
@@ -107,7 +125,10 @@ class FilesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => ''
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:version_id => ''
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
assert_select 'div.error', 'File is invalid'
|
||||
|
||||
@@ -30,7 +30,9 @@ class GanttsControllerTest < Redmine::ControllerTest
|
||||
def test_gantt_should_work
|
||||
i2 = Issue.find(2)
|
||||
i2.update_attribute(:due_date, 1.month.from_now)
|
||||
get :show, :project_id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Issue with start and due dates
|
||||
@@ -43,27 +45,37 @@ class GanttsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'input[type=hidden][name=zoom][value=?]', '1'
|
||||
end
|
||||
|
||||
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_select 'input[type=hidden][name=zoom][value=?]', '4'
|
||||
end
|
||||
|
||||
def test_gantt_should_work_without_issue_due_dates
|
||||
Issue.update_all("due_date = NULL")
|
||||
get :show, :project_id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_gantt_should_work_without_issue_and_version_due_dates
|
||||
Issue.update_all("due_date = NULL")
|
||||
Version.update_all("effective_date = NULL")
|
||||
get :show, :project_id => 1
|
||||
get :show, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -97,14 +109,19 @@ class GanttsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_equal 'application/pdf', @response.content_type
|
||||
assert @response.body.starts_with?('%PDF')
|
||||
end
|
||||
|
||||
def test_gantt_should_export_to_pdf_cross_project
|
||||
get :show, :format => 'pdf'
|
||||
get :show, :params => {
|
||||
:format => 'pdf'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/pdf', @response.content_type
|
||||
assert @response.body.starts_with?('%PDF')
|
||||
@@ -112,7 +129,10 @@ class GanttsControllerTest < Redmine::ControllerTest
|
||||
|
||||
if Object.const_defined?(:Magick)
|
||||
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_equal 'image/png', @response.content_type
|
||||
end
|
||||
|
||||
@@ -39,19 +39,25 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
def test_index_with_name_filter
|
||||
Group.generate!(:name => "Clients")
|
||||
|
||||
get :index, :name => "cli"
|
||||
get :index, :params => {
|
||||
:name => "cli"
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.groups tbody tr', 1
|
||||
assert_select 'table.groups tbody td.name', :text => 'Clients'
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 10
|
||||
get :show, :params => {
|
||||
:id => 10
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_show_invalid_should_return_404
|
||||
get :show, :id => 99
|
||||
get :show, :params => {
|
||||
:id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
@@ -63,7 +69,11 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create
|
||||
assert_difference 'Group.count' do
|
||||
post :create, :group => {:name => 'New group'}
|
||||
post :create, :params => {
|
||||
:group => {
|
||||
:name => 'New group'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/groups'
|
||||
group = Group.order('id DESC').first
|
||||
@@ -73,7 +83,12 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_and_continue
|
||||
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
|
||||
assert_redirected_to '/groups/new'
|
||||
group = Group.order('id DESC').first
|
||||
@@ -82,14 +97,20 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'Group.count' do
|
||||
post :create, :group => {:name => ''}
|
||||
post :create, :params => {
|
||||
:group => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /Name cannot be blank/i
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => 10
|
||||
get :edit, :params => {
|
||||
:id => 10
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div#tab-content-users'
|
||||
@@ -100,46 +121,70 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update
|
||||
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'
|
||||
group = Group.find(10)
|
||||
assert_equal new_name, group.name
|
||||
end
|
||||
|
||||
def test_update_with_failure
|
||||
put :update, :id => 10, :group => {:name => ''}
|
||||
put :update, :params => {
|
||||
:id => 10,
|
||||
:group => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /Name cannot be blank/i
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'Group.count', -1 do
|
||||
post :destroy, :id => 10
|
||||
post :destroy, :params => {
|
||||
:id => 10
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/groups'
|
||||
end
|
||||
|
||||
def test_new_users
|
||||
get :new_users, :id => 10
|
||||
get :new_users, :params => {
|
||||
:id => 10
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'user_search'
|
||||
end
|
||||
|
||||
def test_xhr_new_users
|
||||
xhr :get, :new_users, :id => 10
|
||||
get :new_users, :params => {
|
||||
:id => 10
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
def test_add_users
|
||||
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
|
||||
|
||||
def test_xhr_add_users
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -148,20 +193,32 @@ class GroupsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_remove_user
|
||||
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
|
||||
|
||||
def test_xhr_remove_user
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
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_include 'John Smith', response.body
|
||||
end
|
||||
|
||||
@@ -49,7 +49,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_should_save_the_file
|
||||
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
|
||||
end
|
||||
assert_equal 2, import.user_id
|
||||
@@ -59,7 +61,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_settings_should_display_settings_form
|
||||
import = generate_import
|
||||
get :settings, :id => import.to_param
|
||||
get :settings, :params => {
|
||||
:id => import.to_param
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'import_settings[separator]'
|
||||
assert_select 'select[name=?]', 'import_settings[wrapper]'
|
||||
@@ -70,8 +74,15 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_post_settings_should_update_settings
|
||||
import = generate_import
|
||||
|
||||
post :settings, :id => import.to_param,
|
||||
:import_settings => {:separator => ":", :wrapper => "|", :encoding => "UTF-8", :date_format => '%m/%d/%Y'}
|
||||
post :settings, :params => {
|
||||
:id => import.to_param,
|
||||
:import_settings => {
|
||||
:separator => ":",
|
||||
:wrapper => "|",
|
||||
:encoding => "UTF-8",
|
||||
:date_format => '%m/%d/%Y'
|
||||
}
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}/mapping"
|
||||
|
||||
import.reload
|
||||
@@ -84,8 +95,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_post_settings_should_update_total_items_count
|
||||
import = generate_import('import_iso8859-1.csv')
|
||||
|
||||
post :settings, :id => import.to_param,
|
||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "ISO-8859-1"}
|
||||
post :settings, :params => {
|
||||
:id => import.to_param,
|
||||
:import_settings => {
|
||||
:separator => ";",
|
||||
:wrapper => '"',
|
||||
:encoding => "ISO-8859-1"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
import.reload
|
||||
assert_equal 2, import.total_items
|
||||
@@ -94,8 +111,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_post_settings_with_wrong_encoding_should_display_error
|
||||
import = generate_import('import_iso8859-1.csv')
|
||||
|
||||
post :settings, :id => import.to_param,
|
||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "UTF-8"}
|
||||
post :settings, :params => {
|
||||
:id => import.to_param,
|
||||
:import_settings => {
|
||||
:separator => ";",
|
||||
:wrapper => '"',
|
||||
:encoding => "UTF-8"
|
||||
}
|
||||
}
|
||||
assert_response 200
|
||||
import.reload
|
||||
assert_nil import.total_items
|
||||
@@ -105,8 +128,14 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_post_settings_with_invalid_encoding_should_display_error
|
||||
import = generate_import('invalid-Shift_JIS.csv')
|
||||
|
||||
post :settings, :id => import.to_param,
|
||||
:import_settings => {:separator => ";", :wrapper => '"', :encoding => "Shift_JIS"}
|
||||
post :settings, :params => {
|
||||
:id => import.to_param,
|
||||
:import_settings => {
|
||||
:separator => ";",
|
||||
:wrapper => '"',
|
||||
:encoding => "Shift_JIS"
|
||||
}
|
||||
}
|
||||
assert_response 200
|
||||
import.reload
|
||||
assert_nil import.total_items
|
||||
@@ -118,7 +147,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
import.settings = {'separator' => ";", 'wrapper' => '"', 'encoding' => "ISO-8859-1"}
|
||||
import.save!
|
||||
|
||||
get :mapping, :id => import.to_param
|
||||
get :mapping, :params => {
|
||||
:id => import.to_param
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
|
||||
@@ -135,8 +166,15 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_post_mapping_should_update_mapping
|
||||
import = generate_import('import_iso8859-1.csv')
|
||||
|
||||
post :mapping, :id => import.to_param,
|
||||
:import_settings => {:mapping => {:project_id => '1', :tracker_id => '2', :subject => '0'}}
|
||||
post :mapping, :params => {
|
||||
:id => import.to_param,
|
||||
:import_settings => {
|
||||
:mapping => {
|
||||
:project_id => '1',
|
||||
:tracker_id => '2',
|
||||
:subject => '0'}
|
||||
}
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}/run"
|
||||
import.reload
|
||||
mapping = import.settings['mapping']
|
||||
@@ -149,7 +187,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
def test_get_run
|
||||
import = generate_import_with_mapping
|
||||
|
||||
get :run, :id => import
|
||||
get :run, :params => {
|
||||
:id => import
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#import-progress'
|
||||
end
|
||||
@@ -158,7 +198,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
import = generate_import_with_mapping
|
||||
|
||||
assert_difference 'Issue.count', 3 do
|
||||
post :run, :id => import
|
||||
post :run, :params => {
|
||||
:id => import
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}"
|
||||
end
|
||||
|
||||
@@ -175,12 +217,16 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
import = generate_import_with_mapping
|
||||
|
||||
assert_difference 'Issue.count', 2 do
|
||||
post :run, :id => import
|
||||
post :run, :params => {
|
||||
:id => import
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}/run"
|
||||
end
|
||||
|
||||
assert_difference 'Issue.count', 1 do
|
||||
post :run, :id => import
|
||||
post :run, :params => {
|
||||
:id => import
|
||||
}
|
||||
assert_redirected_to "/imports/#{import.to_param}"
|
||||
end
|
||||
|
||||
@@ -193,7 +239,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
import.run
|
||||
assert_equal 0, import.unsaved_items.count
|
||||
|
||||
get :show, :id => import.to_param
|
||||
get :show, :params => {
|
||||
:id => import.to_param
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'ul#saved-items'
|
||||
@@ -207,7 +255,9 @@ class ImportsControllerTest < Redmine::ControllerTest
|
||||
import.run
|
||||
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_select 'table#unsaved-items'
|
||||
|
||||
@@ -28,14 +28,19 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :new, :project_id => '1'
|
||||
get :new, :params => {
|
||||
:project_id => '1'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'issue_category[name]'
|
||||
end
|
||||
|
||||
def test_new_from_issue_form
|
||||
@request.session[:user_id] = 2 # manager
|
||||
xhr :get, :new, :project_id => '1'
|
||||
get :new, :params => {
|
||||
:project_id => '1'
|
||||
},
|
||||
:xhr => true
|
||||
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
@@ -44,7 +49,12 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
def test_create
|
||||
@request.session[:user_id] = 2 # manager
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||
category = IssueCategory.find_by_name('New category')
|
||||
@@ -54,7 +64,12 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_failure
|
||||
@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_select_error /Name cannot be blank/i
|
||||
end
|
||||
@@ -62,7 +77,13 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_from_issue_form
|
||||
@request.session[:user_id] = 2 # manager
|
||||
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
|
||||
category = IssueCategory.order('id DESC').first
|
||||
assert_equal 'New category', category.name
|
||||
@@ -74,7 +95,13 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_from_issue_form_with_failure
|
||||
@request.session[:user_id] = 2 # manager
|
||||
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
|
||||
|
||||
assert_response :success
|
||||
@@ -84,38 +111,59 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 2
|
||||
get :edit, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes'
|
||||
end
|
||||
|
||||
def test_update
|
||||
assert_no_difference 'IssueCategory.count' do
|
||||
put :update, :id => 2, :issue_category => { :name => 'Testing' }
|
||||
put :update, :params => {
|
||||
:id => 2,
|
||||
:issue_category => {
|
||||
:name => 'Testing'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||
assert_equal 'Testing', IssueCategory.find(2).name
|
||||
end
|
||||
|
||||
def test_update_failure
|
||||
put :update, :id => 2, :issue_category => { :name => '' }
|
||||
put :update, :params => {
|
||||
:id => 2,
|
||||
:issue_category => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /Name cannot be blank/i
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_destroy_category_not_in_use
|
||||
delete :destroy, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||
assert_nil IssueCategory.find_by_id(2)
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_not_nil IssueCategory.find_by_id(1)
|
||||
assert_select 'select[name=?]', 'reassign_to_id'
|
||||
@@ -123,7 +171,11 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_category_in_use_with_reassignment
|
||||
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_nil IssueCategory.find_by_id(1)
|
||||
# check that the issue was reassign
|
||||
@@ -132,7 +184,10 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_category_in_use_without_reassignment
|
||||
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_nil IssueCategory.find_by_id(1)
|
||||
# check that the issue category was nullified
|
||||
|
||||
@@ -38,8 +38,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create
|
||||
assert_difference 'IssueRelation.count' do
|
||||
post :create, :issue_id => 1,
|
||||
:relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => '2',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
relation = IssueRelation.order('id DESC').first
|
||||
assert_equal 1, relation.issue_from_id
|
||||
@@ -49,15 +55,29 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_on_invalid_issue
|
||||
assert_no_difference 'IssueRelation.count' do
|
||||
post :create, :issue_id => 999,
|
||||
:relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 999,
|
||||
:relation => {
|
||||
:issue_to_id => '2',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_xhr
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -70,8 +90,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_should_accept_id_with_hash
|
||||
assert_difference 'IssueRelation.count' do
|
||||
post :create, :issue_id => 1,
|
||||
:relation => {:issue_to_id => '#2', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => '#2',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
relation = IssueRelation.order('id DESC').first
|
||||
assert_equal 2, relation.issue_to_id
|
||||
@@ -79,8 +105,14 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_should_strip_id
|
||||
assert_difference 'IssueRelation.count' do
|
||||
post :create, :issue_id => 1,
|
||||
:relation => {:issue_to_id => ' 2 ', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => ' 2 ',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
relation = IssueRelation.order('id DESC').first
|
||||
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
|
||||
assert_no_difference 'IssueRelation.count' do
|
||||
assert_nothing_raised do
|
||||
post :create, :issue_id => 1,
|
||||
:relation => {:issue_to_id => 'foo', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => 'foo',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -100,8 +138,15 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
issue2 = Issue.generate!
|
||||
|
||||
assert_difference 'IssueRelation.count' do
|
||||
xhr :post, :create, :issue_id => issue2.id,
|
||||
:relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => issue2.id,
|
||||
:relation => {
|
||||
:issue_to_id => issue1.id,
|
||||
:relation_type => 'follows',
|
||||
:delay => ''
|
||||
}
|
||||
},
|
||||
:xhr => true
|
||||
end
|
||||
assert_include 'Followed issue', response.body
|
||||
end
|
||||
@@ -111,14 +156,28 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
assert_nil Issue.visible(User.find(3)).find_by_id(4)
|
||||
|
||||
assert_no_difference 'IssueRelation.count' do
|
||||
post :create, :issue_id => 1,
|
||||
:relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''}
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => '4',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_xhr_with_failure
|
||||
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_equal 'text/javascript', response.content_type
|
||||
@@ -128,13 +187,17 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'IssueRelation.count', -1 do
|
||||
delete :destroy, :id => '2'
|
||||
delete :destroy, :params => {
|
||||
:id => '2'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_invalid_relation
|
||||
assert_no_difference 'IssueRelation.count' do
|
||||
delete :destroy, :id => '999'
|
||||
delete :destroy, :params => {
|
||||
:id => '999'
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
@@ -146,7 +209,10 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
assert_difference 'IssueRelation.count', -1 do
|
||||
xhr :delete, :destroy, :id => '2'
|
||||
delete :destroy, :params => {
|
||||
:id => '2'
|
||||
},
|
||||
:xhr => true
|
||||
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
|
||||
@@ -51,7 +51,11 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create
|
||||
assert_difference 'IssueStatus.count' do
|
||||
post :create, :issue_status => {:name => 'New status'}
|
||||
post :create, :params => {
|
||||
:issue_status => {
|
||||
:name => 'New status'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to :action => 'index'
|
||||
status = IssueStatus.order('id DESC').first
|
||||
@@ -59,26 +63,42 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
post :create, :issue_status => {:name => ''}
|
||||
post :create, :params => {
|
||||
:issue_status => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => '3'
|
||||
get :edit, :params => {
|
||||
:id => '3'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved'
|
||||
end
|
||||
|
||||
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'
|
||||
status = IssueStatus.find(3)
|
||||
assert_equal 'Renamed status', status.name
|
||||
end
|
||||
|
||||
def test_update_with_failure
|
||||
put :update, :id => '3', :issue_status => {:name => ''}
|
||||
put :update, :params => {
|
||||
:id => '3',
|
||||
:issue_status => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
@@ -88,7 +108,9 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
||||
Tracker.where(:default_status_id => 1).delete_all
|
||||
|
||||
assert_difference 'IssueStatus.count', -1 do
|
||||
delete :destroy, :id => '1'
|
||||
delete :destroy, :params => {
|
||||
:id => '1'
|
||||
}
|
||||
end
|
||||
assert_redirected_to :action => 'index'
|
||||
assert_nil IssueStatus.find_by_id(1)
|
||||
@@ -99,7 +121,9 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
|
||||
Tracker.where(:default_status_id => 1).delete_all
|
||||
|
||||
assert_no_difference 'IssueStatus.count' do
|
||||
delete :destroy, :id => '1'
|
||||
delete :destroy, :params => {
|
||||
:id => '1'
|
||||
}
|
||||
end
|
||||
assert_redirected_to :action => 'index'
|
||||
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_no_difference 'IssueStatus.count' do
|
||||
delete :destroy, :id => '1'
|
||||
delete :destroy, :params => {
|
||||
:id => '1'
|
||||
}
|
||||
end
|
||||
assert_redirected_to :action => 'index'
|
||||
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 'TimeEntry.count' do
|
||||
put :update,
|
||||
:id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
},
|
||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
|
||||
put :update, :params => {
|
||||
:id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => '',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,15 +92,24 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Journal.count' do
|
||||
assert_no_difference 'TimeEntry.count' do
|
||||
assert_difference 'Attachment.count' do
|
||||
put :update,
|
||||
:id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
},
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}},
|
||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
|
||||
put :update, :params => {
|
||||
:id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'My notes',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => '',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -110,12 +125,15 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
issue = Issue.find(2)
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
put :update, :id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
}
|
||||
put :update, :params => {
|
||||
:id => issue.id,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => (issue.lock_version - 1)
|
||||
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div.conflict'
|
||||
@@ -127,13 +145,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
def test_update_stale_issue_should_show_conflicting_journals
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
},
|
||||
:last_journal_id => 1
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:last_journal_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
},
|
||||
:last_journal_id => ''
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => '',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:last_journal_id => ''
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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)
|
||||
|
||||
@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_select '.conflict-journal', :text => /Privates 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_select '.conflict-journal', :text => /Privates notes/, :count => 0
|
||||
end
|
||||
@@ -175,13 +213,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Journal.count' do
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'overwrite_conflict_resolution',
|
||||
:lock_version => 2
|
||||
},
|
||||
:conflict_resolution => 'overwrite'
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'overwrite_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:conflict_resolution => 'overwrite'
|
||||
}
|
||||
end
|
||||
|
||||
assert_response 302
|
||||
@@ -196,13 +237,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Journal.count' do
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
}
|
||||
end
|
||||
|
||||
assert_response 302
|
||||
@@ -218,14 +262,17 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
journal = new_record(Journal) do
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_privates_notes_conflict_resolution',
|
||||
:private_notes => '1',
|
||||
:lock_version => 2
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_privates_notes_conflict_resolution',
|
||||
:private_notes => '1',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:conflict_resolution => 'add_notes'
|
||||
}
|
||||
end
|
||||
|
||||
assert_response 302
|
||||
@@ -238,13 +285,16 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Journal.count' do
|
||||
put :update, :id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
},
|
||||
:conflict_resolution => 'cancel'
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:fixed_version_id => 4,
|
||||
:notes => 'add_notes_conflict_resolution',
|
||||
:lock_version => 2
|
||||
|
||||
},
|
||||
:conflict_resolution => 'cancel'
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to '/issues/1'
|
||||
@@ -256,10 +306,17 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference('TimeEntry.count') do
|
||||
put :update,
|
||||
:id => 1,
|
||||
:issue => { :subject => '' },
|
||||
:time_entry => { :hours => '2.5', :comments => 'should not be added', :activity_id => TimeEntryActivity.first.id }
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:subject => ''
|
||||
},
|
||||
:time_entry => {
|
||||
:hours => '2.5',
|
||||
:comments => 'should not be added',
|
||||
:activity_id => TimeEntryActivity.first.id
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
@@ -65,7 +65,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_show_should_show_visible_custom_fields_only
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :show, :id => @issue.id
|
||||
get :show, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
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
|
||||
@users_to_test.each do |user, fields|
|
||||
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
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -98,7 +105,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :show, :id => @issue.id
|
||||
get :show, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
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"
|
||||
@@ -116,7 +125,12 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
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
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -133,7 +147,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :edit, :id => @issue.id
|
||||
get :edit, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
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|
|
||||
@request.session[:user_id] = user.id
|
||||
put :update, :id => @issue.id,
|
||||
:issue => {:custom_field_values => {
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field3.id.to_s => "User#{user.id}Value2",
|
||||
}}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field3.id.to_s => "User#{user.id}Value2",
|
||||
}
|
||||
}
|
||||
}
|
||||
@issue.reload
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -169,7 +189,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_index_should_show_visible_custom_fields_only
|
||||
@users_to_test.each do |user, fields|
|
||||
@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|
|
||||
if fields.include?(field)
|
||||
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
|
||||
@users_to_test.each do |user, fields|
|
||||
@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|
|
||||
if fields.include?(field)
|
||||
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'})
|
||||
|
||||
@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 => 'ValueB', :count => 0
|
||||
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
|
||||
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)}
|
||||
|
||||
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)}
|
||||
end
|
||||
|
||||
@@ -231,15 +265,19 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
assert_difference 'Issue.count' do
|
||||
post :create,
|
||||
:project_id => 1,
|
||||
:issue => {
|
||||
:tracker_id => 1,
|
||||
:status_id => 1,
|
||||
:subject => 'New issue',
|
||||
:priority_id => 5,
|
||||
: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)
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:issue => {
|
||||
:tracker_id => 1,
|
||||
:status_id => 1,
|
||||
:subject => 'New issue',
|
||||
:priority_id => 5,
|
||||
: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)
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
@@ -270,10 +308,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
put :update,
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
@@ -303,10 +345,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
put :update,
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
@@ -26,13 +26,18 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
end
|
||||
|
||||
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
|
||||
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)
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}"
|
||||
|
||||
Role.find(1).remove_permission! :view_private_notes
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}", :count => 0
|
||||
end
|
||||
|
||||
def test_index_should_show_visible_custom_fields_only
|
||||
Issue.destroy_all
|
||||
Journal.delete_all
|
||||
field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
|
||||
@fields = []
|
||||
@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'}
|
||||
)
|
||||
@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.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|
|
||||
get :index, :format => 'atom', :key => user.rss_key
|
||||
get :index, :params => {
|
||||
:format => 'atom',
|
||||
:key => user.rss_key
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
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"
|
||||
@@ -91,7 +104,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_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,
|
||||
: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_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,
|
||||
: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
|
||||
end
|
||||
|
||||
def test_diff_should_default_to_description_diff
|
||||
get :diff, :id => 3
|
||||
get :diff, :params => {
|
||||
:id => 3
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'span.diff_out', :text => /removed/
|
||||
@@ -131,7 +155,10 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_reply_to_issue
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :new, :id => 6
|
||||
get :new, :params => {
|
||||
:id => 6
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
@@ -140,13 +167,20 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_reply_to_issue_without_permission
|
||||
@request.session[:user_id] = 7
|
||||
xhr :get, :new, :id => 6
|
||||
get :new, :params => {
|
||||
:id => 6
|
||||
},
|
||||
:xhr => true
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_reply_to_note
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
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)
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
assert_include '> Privates notes', response.body
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_edit_xhr
|
||||
@request.session[:user_id] = 1
|
||||
xhr :get, :edit, :id => 2
|
||||
get :edit, :params => {
|
||||
:id => 2
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
assert_include 'textarea', response.body
|
||||
@@ -179,19 +224,31 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_equal 'text/javascript', response.content_type
|
||||
assert_include 'textarea', response.body
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_update_xhr
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
assert_equal 'Updated notes', Journal.find(2).notes
|
||||
@@ -200,7 +257,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_xhr_with_private_notes_checked
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
assert_equal true, Journal.find(2).private_notes
|
||||
@@ -211,7 +274,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
def test_update_xhr_with_private_notes_unchecked
|
||||
Journal.find(2).update_attributes(:private_notes => true)
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
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).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_equal false, Journal.find(2).private_notes
|
||||
end
|
||||
@@ -233,7 +308,13 @@ class JournalsControllerTest < Redmine::ControllerTest
|
||||
def test_update_xhr_with_empty_notes_should_delete_the_journal
|
||||
@request.session[:user_id] = 1
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
@@ -33,7 +33,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
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
|
||||
assert_response 201
|
||||
end
|
||||
@@ -44,9 +47,13 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_difference 'Issue.count' do
|
||||
post :index, :key => 'secret',
|
||||
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
|
||||
:issue => {:is_private => '1'}
|
||||
post :index, :params => {
|
||||
:key => 'secret',
|
||||
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
|
||||
:issue => {
|
||||
:is_private => '1'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response 201
|
||||
issue = Issue.order(:id => :desc).first
|
||||
@@ -60,7 +67,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
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
|
||||
assert_response 422
|
||||
end
|
||||
@@ -71,7 +81,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
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
|
||||
assert_response 403
|
||||
assert_include 'Access denied', response.body
|
||||
@@ -82,7 +95,10 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
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
|
||||
assert_response 403
|
||||
assert_include 'Access denied', response.body
|
||||
@@ -92,7 +108,9 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
get :new, :key => 'secret'
|
||||
get :new, :params => {
|
||||
:key => 'secret'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -35,7 +37,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
role.update! :all_roles_managed => false
|
||||
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_select 'div.roles-selection' do
|
||||
assert_select 'label', :text => 'Manager', :count => 0
|
||||
@@ -45,14 +49,23 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_xhr_new
|
||||
xhr :get, :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
def test_create
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||
assert User.find(7).member_of?(Project.find(1))
|
||||
@@ -60,7 +73,13 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_multiple
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||
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
|
||||
|
||||
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
|
||||
member = Member.order(:id => :desc).first
|
||||
assert_equal [2], member.role_ids
|
||||
@@ -83,7 +108,13 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
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
|
||||
member = Member.order(:id => :desc).first
|
||||
assert_equal [1, 2], member.role_ids
|
||||
@@ -91,7 +122,14 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_create
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -103,7 +141,14 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_create_with_failure
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -111,19 +156,30 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_edit
|
||||
get :edit, :id => 2
|
||||
get :edit, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '2'
|
||||
end
|
||||
|
||||
def test_xhr_edit
|
||||
xhr :get, :edit, :id => 2
|
||||
get :edit, :params => {
|
||||
:id => 2
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_update
|
||||
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
|
||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||
end
|
||||
@@ -131,7 +187,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
def test_update_locked_member_should_be_allowed
|
||||
User.find(3).lock!
|
||||
|
||||
put :update, :id => 2, :membership => {:role_ids => [1]}
|
||||
put :update, :params => {
|
||||
:id => 2,
|
||||
:membership => {
|
||||
:role_ids => [1]
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
member = Member.find(2)
|
||||
assert member.user.locked?
|
||||
@@ -144,7 +205,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||
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
|
||||
end
|
||||
|
||||
@@ -154,13 +220,25 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
role.managed_roles = Role.where(:id => [2, 3]).to_a
|
||||
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
|
||||
end
|
||||
|
||||
def test_xhr_update
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -172,7 +250,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'Member.count', -1 do
|
||||
delete :destroy, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:id => 2
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/settings/members'
|
||||
assert !User.find(3).member_of?(Project.find(1))
|
||||
@@ -182,7 +262,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
assert User.find(3).lock!
|
||||
|
||||
assert_difference 'Member.count', -1 do
|
||||
delete :destroy, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:id => 2
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -193,7 +275,9 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
member = Member.create!(:user => User.find(9), :role_ids => [1, 3], :project_id => 1)
|
||||
|
||||
assert_no_difference 'Member.count' do
|
||||
delete :destroy, :id => member.id
|
||||
delete :destroy, :params => {
|
||||
:id => member.id
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -204,13 +288,18 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
member = Member.create!(:user => User.find(9), :role_ids => [3], :project_id => 1)
|
||||
|
||||
assert_difference 'Member.count', -1 do
|
||||
delete :destroy, :id => member.id
|
||||
delete :destroy, :params => {
|
||||
:id => member.id
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def test_xhr_destroy
|
||||
assert_difference 'Member.count', -1 do
|
||||
xhr :delete, :destroy, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:id => 2
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -219,7 +308,12 @@ class MembersControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_include 'User Misc', response.body
|
||||
end
|
||||
|
||||
@@ -25,7 +25,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :board_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h2', :text => 'First post'
|
||||
@@ -33,7 +36,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_show_should_contain_reply_field_tags_for_quoting
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :board_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# tags required by MessagesController#quote
|
||||
@@ -54,7 +60,11 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
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_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
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :board_id => 1, :id => 1
|
||||
get :show, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'div#reply textarea#message_content'
|
||||
end
|
||||
|
||||
def test_show_message_not_found
|
||||
get :show, :board_id => 1, :id => 99999
|
||||
get :show, :params => {
|
||||
:board_id => 1,
|
||||
:id => 99999
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :board_id => 1
|
||||
get :new, :params => {
|
||||
:board_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?]', 'message[subject]'
|
||||
@@ -89,7 +110,9 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_new_with_invalid_board
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :board_id => 99
|
||||
get :new, :params => {
|
||||
:board_id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
@@ -98,9 +121,13 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(message_posted) do
|
||||
post :new, :board_id => 1,
|
||||
:message => { :subject => 'Test created message',
|
||||
:content => 'Message body'}
|
||||
post :new, :params => {
|
||||
:board_id => 1,
|
||||
:message => {
|
||||
:subject => 'Test created message',
|
||||
:content => 'Message body'
|
||||
}
|
||||
}
|
||||
end
|
||||
message = Message.find_by_subject('Test created message')
|
||||
assert_not_nil message
|
||||
@@ -121,7 +148,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :board_id => 1, :id => 1
|
||||
get :edit, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'message[subject]', 'First post'
|
||||
@@ -129,9 +159,14 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :board_id => 1, :id => 1,
|
||||
:message => { :subject => 'New subject',
|
||||
:content => 'New body'}
|
||||
post :edit, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1,
|
||||
:message => {
|
||||
:subject => 'New subject',
|
||||
:content => 'New body'
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/boards/1/topics/1'
|
||||
message = Message.find(1)
|
||||
assert_equal 'New subject', message.subject
|
||||
@@ -140,11 +175,16 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_edit_sticky_and_locked
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :board_id => 1, :id => 1,
|
||||
:message => { :subject => 'New subject',
|
||||
:content => 'New body',
|
||||
:locked => '1',
|
||||
:sticky => '1'}
|
||||
post :edit, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1,
|
||||
:message => {
|
||||
:subject => 'New subject',
|
||||
:content => 'New body',
|
||||
:locked => '1',
|
||||
:sticky => '1'
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/boards/1/topics/1'
|
||||
message = Message.find(1)
|
||||
assert_equal true, message.sticky?
|
||||
@@ -153,10 +193,15 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_edit_should_allow_to_change_board
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :board_id => 1, :id => 1,
|
||||
:message => { :subject => 'New subject',
|
||||
:content => 'New body',
|
||||
:board_id => 2}
|
||||
post :edit, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1,
|
||||
:message => {
|
||||
:subject => 'New subject',
|
||||
:content => 'New body',
|
||||
:board_id => 2
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/boards/2/topics/1'
|
||||
message = Message.find(1)
|
||||
assert_equal Board.find(2), message.board
|
||||
@@ -164,7 +209,14 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_reply
|
||||
@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
|
||||
assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
|
||||
assert Message.find_by_subject('Test reply')
|
||||
@@ -173,7 +225,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
def test_destroy_topic
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Message.count', -3 do
|
||||
post :destroy, :board_id => 1, :id => 1
|
||||
post :destroy, :params => {
|
||||
:board_id => 1,
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/boards/1'
|
||||
assert_nil Message.find_by_id(1)
|
||||
@@ -182,7 +237,10 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
def test_destroy_reply
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Message.count', -1 do
|
||||
post :destroy, :board_id => 1, :id => 2
|
||||
post :destroy, :params => {
|
||||
:board_id => 1,
|
||||
:id => 2
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/boards/1/topics/1?r=2'
|
||||
assert_nil Message.find_by_id(2)
|
||||
@@ -190,7 +248,11 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_quote
|
||||
@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_equal 'text/javascript', response.content_type
|
||||
|
||||
@@ -200,19 +262,27 @@ class MessagesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview_new
|
||||
@request.session[:user_id] = 2
|
||||
post :preview,
|
||||
:board_id => 1,
|
||||
:message => {:subject => "", :content => "Previewed text"}
|
||||
post :preview, :params => {
|
||||
:board_id => 1,
|
||||
:message => {
|
||||
:subject => "",
|
||||
:content => "Previewed text"
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_include 'Previewed text', response.body
|
||||
end
|
||||
|
||||
def test_preview_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :preview,
|
||||
:id => 4,
|
||||
:board_id => 1,
|
||||
:message => {:subject => "", :content => "Previewed text"}
|
||||
post :preview, :params => {
|
||||
:id => 4,
|
||||
:board_id => 1,
|
||||
:message => {
|
||||
:subject => "",
|
||||
:content => "Previewed text"
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_include 'Previewed text', response.body
|
||||
end
|
||||
|
||||
@@ -238,13 +238,17 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_update_account
|
||||
post :account,
|
||||
:user => {
|
||||
:firstname => "Joe",
|
||||
:login => "root",
|
||||
:admin => 1,
|
||||
:group_ids => ['10'],
|
||||
:custom_field_values => {"4" => "0100562500"}
|
||||
post :account, :params => {
|
||||
:user => {
|
||||
:firstname => "Joe",
|
||||
:login => "root",
|
||||
:admin => 1,
|
||||
:group_ids => ['10'],
|
||||
:custom_field_values => {
|
||||
"4" => "0100562500"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
assert_redirected_to '/my/account'
|
||||
@@ -259,9 +263,11 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_account_should_send_security_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
post :account,
|
||||
:user => {
|
||||
:mail => 'foobar@example.com'
|
||||
post :account, :params => {
|
||||
:user => {
|
||||
:mail => 'foobar@example.com'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
assert_difference 'User.count', -1 do
|
||||
post :destroy, :confirm => '1'
|
||||
post :destroy, :params => {
|
||||
:confirm => '1'
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/'
|
||||
assert_match /deleted/i, flash[:notice]
|
||||
@@ -307,7 +315,9 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
User.any_instance.stubs(:own_account_deletable?).returns(false)
|
||||
|
||||
assert_no_difference 'User.count' do
|
||||
post :destroy, :confirm => '1'
|
||||
post :destroy, :params => {
|
||||
:confirm => '1'
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/my/account'
|
||||
end
|
||||
@@ -321,17 +331,21 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_update_password
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
post :password, :params => {
|
||||
:password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
}
|
||||
assert_redirected_to '/my/account'
|
||||
assert User.try_to_login('jsmith', 'secret123')
|
||||
end
|
||||
|
||||
def test_update_password_with_non_matching_confirmation
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret1234'
|
||||
post :password, :params => {
|
||||
:password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret1234'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /Password doesn.*t match confirmation/
|
||||
assert User.try_to_login('jsmith', 'jsmith')
|
||||
@@ -339,9 +353,11 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_password_with_wrong_password
|
||||
# wrong password
|
||||
post :password, :password => 'wrongpassword',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
post :password, :params => {
|
||||
:password => 'wrongpassword',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'Wrong password', flash[:error]
|
||||
assert User.try_to_login('jsmith', 'jsmith')
|
||||
@@ -357,9 +373,11 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_password_should_send_security_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
post :password, :params => {
|
||||
:password => 'jsmith',
|
||||
:new_password => 'secret123',
|
||||
:new_password_confirmation => 'secret123'
|
||||
}
|
||||
|
||||
assert_not_nil (mail = ActionMailer::Base.deliveries.last)
|
||||
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')
|
||||
@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_include '$("#block-issuesassignedtome").replaceWith(', response.body
|
||||
assert_include 'Due date', response.body
|
||||
@@ -381,30 +405,42 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_add_block
|
||||
post :add_block, :block => 'issueswatched'
|
||||
post :add_block, :params => {
|
||||
:block => 'issueswatched'
|
||||
}
|
||||
assert_redirected_to '/my/page'
|
||||
assert User.find(2).pref[:my_page_layout]['top'].include?('issueswatched')
|
||||
end
|
||||
|
||||
def test_add_block_xhr
|
||||
xhr :post, :add_block, :block => 'issueswatched'
|
||||
post :add_block, :params => {
|
||||
:block => 'issueswatched'
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_include 'issueswatched', User.find(2).pref[:my_page_layout]['top']
|
||||
end
|
||||
|
||||
def test_add_invalid_block_should_error
|
||||
post :add_block, :block => 'invalid'
|
||||
post :add_block, :params => {
|
||||
:block => 'invalid'
|
||||
}
|
||||
assert_response 422
|
||||
end
|
||||
|
||||
def test_remove_block
|
||||
post :remove_block, :block => 'issuesassignedtome'
|
||||
post :remove_block, :params => {
|
||||
:block => 'issuesassignedtome'
|
||||
}
|
||||
assert_redirected_to '/my/page'
|
||||
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
||||
end
|
||||
|
||||
def test_remove_block_xhr
|
||||
xhr :post, :remove_block, :block => 'issuesassignedtome'
|
||||
post :remove_block, :params => {
|
||||
:block => 'issuesassignedtome'
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_include '$("#block-issuesassignedtome").remove();', response.body
|
||||
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.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_equal ['documents', 'calendar', 'news'], User.find(2).pref.my_page_layout['left']
|
||||
end
|
||||
@@ -425,7 +465,11 @@ class MyControllerTest < Redmine::ControllerTest
|
||||
pref.my_page_layout = {'left' => ['news','documents'], 'right' => ['calendar']}
|
||||
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_equal({'left' => ['news', 'calendar', 'documents'], 'right' => []}, User.find(2).pref.my_page_layout)
|
||||
end
|
||||
|
||||
@@ -33,18 +33,24 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index_with_project
|
||||
get :index, :project_id => 1
|
||||
get :index, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h3 a', :text => 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_index_with_invalid_project_should_respond_with_404
|
||||
get :index, :project_id => 999
|
||||
get :index, :params => {
|
||||
:project_id => 999
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => 'eCookbook first release !'
|
||||
end
|
||||
@@ -54,7 +60,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
attachment.container = News.find(1)
|
||||
attachment.save!
|
||||
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'a', :text => attachment.filename
|
||||
end
|
||||
@@ -65,7 +73,9 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
user.pref.save!
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
|
||||
@@ -73,13 +83,17 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_show_not_found
|
||||
get :show, :id => 999
|
||||
get :show, :params => {
|
||||
:id => 999
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?]', 'news[title]'
|
||||
end
|
||||
@@ -89,9 +103,14 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :notified_events => %w(news_added) do
|
||||
post :create, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => 'NewsControllerTest',
|
||||
:description => 'This is the description',
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/news'
|
||||
|
||||
@@ -108,9 +127,17 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'News.count' do
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1,
|
||||
:news => { :title => 'Test', :description => 'This is the description' },
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => 'Test',
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
attachment = Attachment.order('id DESC').first
|
||||
@@ -120,23 +147,35 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_create_with_validation_failure
|
||||
@request.session[:user_id] = 2
|
||||
post :create, :project_id => 1, :news => { :title => '',
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => '',
|
||||
:description => 'This is the description',
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /title cannot be blank/i
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !'
|
||||
end
|
||||
|
||||
def test_put_update
|
||||
@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'
|
||||
news = News.find(1)
|
||||
assert_equal 'Description changed by test_post_edit', news.description
|
||||
@@ -147,9 +186,16 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference 'News.count' do
|
||||
assert_difference 'Attachment.count' do
|
||||
put :update, :id => 1,
|
||||
:news => { :description => 'This is the description' },
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:news => {
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
attachment = Attachment.order('id DESC').first
|
||||
@@ -158,14 +204,21 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
put :update, :id => 1, :news => { :description => '' }
|
||||
put :update, :params => {
|
||||
:id => 1,
|
||||
:news => {
|
||||
:description => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /description cannot be blank/i
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/news'
|
||||
assert_nil News.find_by_id(1)
|
||||
end
|
||||
|
||||
@@ -30,7 +30,12 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview_new_issue
|
||||
@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_select 'fieldset' do
|
||||
assert_select 'legend', :text => 'Description'
|
||||
@@ -40,8 +45,14 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview_issue_notes_with_no_change_to_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1,
|
||||
:issue => {:description => Issue.find(1).description, :notes => 'Foo'}
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:description => Issue.find(1).description,
|
||||
:notes => 'Foo'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Description', :count => 0
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
@@ -49,8 +60,14 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview_issue_notes_with_change_to_description
|
||||
@request.session[:user_id] = 2
|
||||
post :issue, :project_id => '1', :id => 1,
|
||||
:issue => {:description => 'Changed description', :notes => 'Foo'}
|
||||
post :issue, :params => {
|
||||
:project_id => '1',
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:description => 'Changed description',
|
||||
:notes => 'Foo'
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'legend', :text => 'Description'
|
||||
assert_select 'legend', :text => 'Notes'
|
||||
@@ -58,7 +75,13 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview_journal_notes_for_update
|
||||
@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_select 'legend', :text => 'Notes'
|
||||
assert_select 'p', :text => 'Foo'
|
||||
@@ -67,32 +90,54 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
def test_preview_issue_notes_should_support_links_to_existing_attachments
|
||||
Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar')
|
||||
@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_select 'a.attachment', :text => 'foo.bar'
|
||||
end
|
||||
|
||||
def test_preview_issue_with_project_changed
|
||||
@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_select 'legend', :text => 'Notes'
|
||||
end
|
||||
|
||||
def test_preview_new_news
|
||||
get :news, :project_id => 1,
|
||||
:news => {:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''}
|
||||
get :news, :params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
end
|
||||
|
||||
def test_preview_existing_news
|
||||
get :news, :project_id => 1, :id => 2,
|
||||
:news => {:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''}
|
||||
get :news, :params => {
|
||||
:project_id => 1,
|
||||
:id => 2,
|
||||
:news => {
|
||||
:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset.preview', :text => /News description/
|
||||
end
|
||||
|
||||
@@ -25,7 +25,9 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_new_user_membership
|
||||
get :new, :user_id => 7
|
||||
get :new, :params => {
|
||||
:user_id => 7
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'label', :text => 'eCookbook' do
|
||||
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
|
||||
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_select 'label', :text => 'eCookbook' do
|
||||
assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]'
|
||||
@@ -43,14 +47,23 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_xhr_new_user_membership
|
||||
xhr :get, :new, :user_id => 7
|
||||
get :new, :params => {
|
||||
:user_id => 7
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
def test_create_user_membership
|
||||
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
|
||||
assert_redirected_to '/users/7/edit?tab=memberships'
|
||||
member = Member.order('id DESC').first
|
||||
@@ -61,7 +74,13 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_user_membership_with_multiple_roles
|
||||
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
|
||||
member = Member.order('id DESC').first
|
||||
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
|
||||
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
|
||||
members = Member.order('id DESC').limit(2).sort_by(&:project_id)
|
||||
assert_equal 1, members[0].project_id
|
||||
@@ -84,7 +109,15 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_create_user_membership
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -97,7 +130,14 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_create_user_membership_with_failure
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -106,19 +146,32 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_edit_user_membership
|
||||
get :edit, :user_id => 2, :id => 1
|
||||
get :edit, :params => {
|
||||
:user_id => 2,
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?][checked=checked]', 'membership[role_ids][]', '1'
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_update_user_membership
|
||||
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'
|
||||
end
|
||||
assert_equal [2], Member.find(1).role_ids
|
||||
@@ -126,7 +179,15 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_update_user_membership
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -136,7 +197,10 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_user_membership
|
||||
assert_difference 'Member.count', -1 do
|
||||
delete :destroy, :user_id => 2, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:user_id => 2,
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/users/2/edit?tab=memberships'
|
||||
assert_nil Member.find_by_id(1)
|
||||
@@ -144,7 +208,11 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_destroy_user_membership_js_format
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -153,20 +221,36 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_xhr_new_group_membership
|
||||
xhr :get, :new, :group_id => 10
|
||||
get :new, :params => {
|
||||
:group_id => 10
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
def test_create_group_membership
|
||||
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
|
||||
|
||||
def test_xhr_create_group_membership
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -175,7 +259,14 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_xhr_create_group_membership_with_failure
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -184,13 +275,26 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_group_membership
|
||||
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
|
||||
|
||||
def test_xhr_update_group_membership
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -198,13 +302,20 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_destroy_group_membership
|
||||
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
|
||||
|
||||
def test_xhr_destroy_group_membership
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
@@ -40,12 +40,15 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager
|
||||
billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
|
||||
|
||||
put :update, :project_id => 1, :enumerations => {
|
||||
"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
|
||||
"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
|
||||
}
|
||||
put :update, :params => {
|
||||
:project_id => 1,
|
||||
:enumerations => {
|
||||
"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
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :redirect
|
||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||
@@ -105,10 +108,13 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
assert project_activity_two.save
|
||||
|
||||
|
||||
put :update, :project_id => 1, :enumerations => {
|
||||
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
|
||||
}
|
||||
put :update, :params => {
|
||||
:project_id => 1,
|
||||
:enumerations => {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
assert_response :redirect
|
||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||
@@ -132,9 +138,15 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
assert_equal 3, TimeEntry.where(:activity_id => 9, :project_id => 1).count
|
||||
|
||||
@request.session[:user_id] = 2 # manager
|
||||
put :update, :project_id => 1, :enumerations => {
|
||||
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate
|
||||
}
|
||||
put :update, :params => {
|
||||
:project_id => 1,
|
||||
:enumerations => {
|
||||
"9"=> {
|
||||
"parent_id"=>"9", "custom_field_values"=> {
|
||||
"7" => "1"}, "active"=>"0"} # Design, De-activate
|
||||
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
||||
# No more TimeEntries using the system activity
|
||||
@@ -160,12 +172,15 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
assert_equal 1, TimeEntry.where(:activity_id => 10, :project_id => 1).count
|
||||
|
||||
@request.session[:user_id] = 2 # manager
|
||||
put :update, :project_id => 1, :enumerations => {
|
||||
# Design
|
||||
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"},
|
||||
# Development, Change custom value
|
||||
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}
|
||||
}
|
||||
put :update, :params => {
|
||||
:project_id => 1,
|
||||
:enumerations => {
|
||||
# Design
|
||||
"9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"},
|
||||
# Development, Change custom value
|
||||
"10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}
|
||||
}
|
||||
}
|
||||
assert_response :redirect
|
||||
|
||||
# TimeEntries shouldn't have been reassigned on the failed record
|
||||
@@ -195,7 +210,9 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
})
|
||||
assert project_activity_two.save
|
||||
|
||||
delete :destroy, :project_id => 1
|
||||
delete :destroy, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :redirect
|
||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||
|
||||
@@ -216,7 +233,9 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
||||
update_all("activity_id = '#{project_activity.id}'")
|
||||
assert_equal 3, TimeEntry.where(:activity_id => project_activity.id,
|
||||
:project_id => 1).count
|
||||
delete :destroy, :project_id => 1
|
||||
delete :destroy, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :redirect
|
||||
assert_redirected_to '/projects/ecookbook/settings/activities'
|
||||
|
||||
|
||||
@@ -46,14 +46,20 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_index_atom
|
||||
get :index, :format => 'atom'
|
||||
get :index, :params => {
|
||||
:format => 'atom'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||
end
|
||||
|
||||
def test_autocomplete_js
|
||||
xhr :get, :autocomplete, :format => 'js', :q => 'coo'
|
||||
get :autocomplete, :params => {
|
||||
:format => 'js',
|
||||
:q => 'coo'
|
||||
},
|
||||
:xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -106,7 +112,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Role.find(1).add_permission! :add_subprojects
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :parent_id => 'ecookbook'
|
||||
get :new, :params => {
|
||||
:parent_id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'project[parent_id]' do
|
||||
@@ -145,18 +153,21 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
test "#create by admin user should create a new project" do
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
post :create,
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:homepage => 'http://weblog',
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:tracker_ids => ['1', '3'],
|
||||
# an issue custom field that is not for all project
|
||||
:issue_custom_field_ids => ['9'],
|
||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:homepage => 'http://weblog',
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:tracker_ids => ['1', '3'],
|
||||
# an issue custom field that is not for all project
|
||||
:issue_custom_field_ids => ['9'],
|
||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
||||
@@ -177,13 +188,19 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
assert_difference 'Project.count' do
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:parent_id => 1
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
end
|
||||
|
||||
@@ -196,7 +213,13 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
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
|
||||
assert_redirected_to '/projects/new'
|
||||
end
|
||||
@@ -205,14 +228,20 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Role.non_member.add_permission! :add_project
|
||||
@request.session[:user_id] = 9
|
||||
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:tracker_ids => ['1', '3'],
|
||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:tracker_ids => ['1', '3'],
|
||||
:enabled_module_names => ['issue_tracking', 'news', 'repository']
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
||||
@@ -234,13 +263,19 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 9
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:parent_id => 1
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /Subproject of is invalid/
|
||||
@@ -251,13 +286,19 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Role.find(1).add_permission! :add_subprojects
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:parent_id => 1
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 1
|
||||
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
project = Project.find_by_name('blog')
|
||||
assert_equal 1, project.parent_id
|
||||
@@ -269,12 +310,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' }
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /Subproject of is invalid/
|
||||
@@ -287,13 +334,19 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
assert !User.find(2).member_of?(Project.find(6))
|
||||
assert_no_difference 'Project.count' do
|
||||
post :create, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:parent_id => 6
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => {
|
||||
'3' => 'Beta'
|
||||
},
|
||||
:parent_id => 6
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /Subproject of is invalid/
|
||||
@@ -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
|
||||
project = new_record(Project) do
|
||||
post :create, :project => {
|
||||
:name => "blog1",
|
||||
:identifier => "blog1",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog1",
|
||||
:identifier => "blog1",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_equal %w(files news), project.enabled_module_names.sort
|
||||
|
||||
default_role.add_permission!(:select_project_modules)
|
||||
project = new_record(Project) do
|
||||
post :create, :project => {
|
||||
:name => "blog2",
|
||||
:identifier => "blog2",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog2",
|
||||
:identifier => "blog2",
|
||||
:enabled_module_names => ["issue_tracking", "repository"]
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_equal %w(issue_tracking repository), project.enabled_module_names.sort
|
||||
@@ -333,9 +392,15 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Project.count' do
|
||||
post :create, :project => {
|
||||
:name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1'
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => 'inherited',
|
||||
:identifier => 'inherited',
|
||||
:parent_id => parent.id,
|
||||
:inherit_members => '1'
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
@@ -350,11 +415,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
|
||||
@request.session[:user_id] = 1
|
||||
assert_no_difference 'Project.count' do
|
||||
post :create, :project => {
|
||||
:name => "blog",
|
||||
:identifier => "",
|
||||
:enabled_module_names => %w(issue_tracking news)
|
||||
}
|
||||
post :create, :params => {
|
||||
:project => {
|
||||
:name => "blog",
|
||||
:identifier => "",
|
||||
:enabled_module_names => %w(issue_tracking news)
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
%w(issue_tracking news).each do |mod|
|
||||
@@ -365,13 +433,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
|
||||
def test_show_by_identifier
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
@@ -381,14 +453,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
p.enabled_module_names = []
|
||||
p.save!
|
||||
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '#main.nosidebar'
|
||||
end
|
||||
|
||||
def test_show_should_display_visible_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
@@ -396,7 +472,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_show_should_not_display_hidden_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
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_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
|
||||
f1 = ProjectCustomField.generate! :field_format => 'text'
|
||||
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
project = Project.find_by_identifier('ecookbook')
|
||||
project.custom_values.first.update_attribute(:value, nil)
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -434,28 +518,36 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
project = Project.find_by_identifier('ecookbook')
|
||||
project.archive!
|
||||
|
||||
get :show, :id => 'ecookbook'
|
||||
get :show, :params => {
|
||||
:id => 'ecookbook'
|
||||
}
|
||||
assert_response 403
|
||||
assert_select 'p', :text => /archived/
|
||||
assert_not_include project.name, response.body
|
||||
end
|
||||
|
||||
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_select 'a', :text => /Private child/, :count => 0
|
||||
end
|
||||
|
||||
def test_show_should_show_private_subprojects_that_are_visible
|
||||
@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_select 'a', :text => /Private child/
|
||||
end
|
||||
|
||||
def test_settings
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :id => 1
|
||||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
@@ -463,7 +555,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_settings_of_subproject
|
||||
@request.session[:user_id] = 2
|
||||
get :settings, :id => 'private-child'
|
||||
get :settings, :params => {
|
||||
:id => 'private-child'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
|
||||
@@ -473,14 +567,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Project.find(1).close
|
||||
@request.session[:user_id] = 2 # manager
|
||||
|
||||
get :settings, :id => 1
|
||||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_settings_should_be_denied_for_anonymous_on_closed_project
|
||||
Project.find(1).close
|
||||
|
||||
get :settings, :id => 1
|
||||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
@@ -489,7 +587,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Role.find(1).add_permission! :manage_wiki
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :settings, :id => 1
|
||||
get :settings, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
||||
@@ -500,7 +600,11 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_settings_should_accept_version_status_filter
|
||||
@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_select 'select[name=version_status]' do
|
||||
@@ -516,7 +620,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_settings_should_accept_version_name_filter
|
||||
@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_select 'input[name=version_name][value=?]', '.1'
|
||||
@@ -534,15 +643,23 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert user.reload.locked?
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :settings, :id => 'ecookbook', :tab => 'members'
|
||||
get :settings, :params => {
|
||||
:id => 'ecookbook',
|
||||
:tab => 'members'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select "tr#member-#{member.id}"
|
||||
end
|
||||
|
||||
def test_update
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :id => 1, :project => {:name => 'Test changed name',
|
||||
:issue_custom_field_ids => ['']}
|
||||
post :update, :params => {
|
||||
:id => 1,
|
||||
:project => {
|
||||
:name => 'Test changed name',
|
||||
:issue_custom_field_ids => ['']
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/settings'
|
||||
project = Project.find(1)
|
||||
assert_equal 'Test changed name', project.name
|
||||
@@ -550,7 +667,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_with_failure
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :id => 1, :project => {:name => ''}
|
||||
post :update, :params => {
|
||||
:id => 1,
|
||||
:project => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
@@ -559,7 +681,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
Project.find(1).close
|
||||
@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_equal 'eCookbook', Project.find(1).name
|
||||
end
|
||||
@@ -567,7 +694,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_update_should_be_denied_for_anonymous_on_closed_project
|
||||
Project.find(1).close
|
||||
|
||||
post :update, :id => 1, :project => {:name => 'Closed'}
|
||||
post :update, :params => {
|
||||
:id => 1,
|
||||
:project => {
|
||||
:name => 'Closed'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
assert_equal 'eCookbook', Project.find(1).name
|
||||
end
|
||||
@@ -578,7 +710,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project]))
|
||||
@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_match /Successful update/, flash[:notice]
|
||||
end
|
||||
@@ -587,7 +724,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
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_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
|
||||
end
|
||||
@@ -596,7 +736,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 2
|
||||
delete :destroy, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
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
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
assert_select 'strong',
|
||||
@@ -619,7 +763,10 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
assert_difference 'Project.count', -5 do
|
||||
delete :destroy, :id => 1, :confirm => 1
|
||||
delete :destroy, :params => {
|
||||
:id => 1,
|
||||
:confirm => 1
|
||||
}
|
||||
assert_redirected_to '/admin/projects'
|
||||
end
|
||||
assert_nil Project.find_by_id(1)
|
||||
@@ -627,7 +774,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_archive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
post :archive, :id => 1
|
||||
post :archive, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/admin/projects'
|
||||
assert !Project.find(1).active?
|
||||
end
|
||||
@@ -635,7 +784,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_archive_with_failure
|
||||
@request.session[:user_id] = 1
|
||||
Project.any_instance.stubs(:archive).returns(false)
|
||||
post :archive, :id => 1
|
||||
post :archive, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/admin/projects'
|
||||
assert_match /project cannot be archived/i, flash[:error]
|
||||
end
|
||||
@@ -643,14 +794,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_unarchive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
Project.find(1).archive
|
||||
post :unarchive, :id => 1
|
||||
post :unarchive, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/admin/projects'
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_close
|
||||
@request.session[:user_id] = 2
|
||||
post :close, :id => 1
|
||||
post :close, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook'
|
||||
assert_equal Project::STATUS_CLOSED, Project.find(1).status
|
||||
end
|
||||
@@ -658,7 +813,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_reopen
|
||||
Project.find(1).close
|
||||
@request.session[:user_id] = 2
|
||||
post :reopen, :id => 1
|
||||
post :reopen, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook'
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
@@ -668,7 +825,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
parent = nil
|
||||
6.times do |i|
|
||||
p = Project.generate_with_parent!(parent)
|
||||
get :show, :id => p
|
||||
get :show, :params => {
|
||||
:id => p
|
||||
}
|
||||
assert_select '#header h1' do
|
||||
assert_select 'a', :count => [i, 3].min
|
||||
end
|
||||
@@ -681,7 +840,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1 # admin
|
||||
orig = Project.find(1)
|
||||
|
||||
get :copy, :id => orig.id
|
||||
get :copy, :params => {
|
||||
:id => orig.id
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 1
|
||||
get :copy, :id => 99
|
||||
get :copy, :params => {
|
||||
:id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
@@ -700,7 +863,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
source = Project.generate!(:issue_custom_fields => [field1])
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
get :copy, :id => source.id
|
||||
get :copy, :params => {
|
||||
:id => source.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'fieldset#project_issue_custom_fields' do
|
||||
assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s
|
||||
@@ -713,14 +878,17 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
CustomField.delete_all
|
||||
|
||||
assert_difference 'Project.count' do
|
||||
post :copy, :id => 1,
|
||||
:project => {
|
||||
:name => 'Copy',
|
||||
:identifier => 'unique-copy',
|
||||
:tracker_ids => ['1', '2', '3', ''],
|
||||
:enabled_module_names => %w(issue_tracking time_tracking)
|
||||
},
|
||||
:only => %w(issues versions)
|
||||
post :copy, :params => {
|
||||
:id => 1,
|
||||
:project => {
|
||||
:name => 'Copy',
|
||||
:identifier => 'unique-copy',
|
||||
:tracker_ids => ['1', '2', '3', ''],
|
||||
:enabled_module_names => %w(issue_tracking time_tracking)
|
||||
|
||||
},
|
||||
:only => %w(issues versions)
|
||||
}
|
||||
end
|
||||
project = Project.find('unique-copy')
|
||||
source = Project.find(1)
|
||||
@@ -733,45 +901,72 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_copy_should_redirect_to_settings_when_successful
|
||||
@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_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
|
||||
end
|
||||
|
||||
def test_post_copy_with_failure
|
||||
@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_select_error /Identifier cannot be blank/
|
||||
end
|
||||
|
||||
def test_jump_without_project_id_should_redirect_to_active_tab
|
||||
get :index, :jump => 'issues'
|
||||
get :index, :params => {
|
||||
:jump => 'issues'
|
||||
}
|
||||
assert_redirected_to '/issues'
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_unknown_tab
|
||||
get :index, :jump => 'foobar'
|
||||
get :index, :params => {
|
||||
:jump => 'foobar'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
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'
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def test_body_should_have_project_css_class
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_select 'body.project-ecookbook'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new_project_query
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
get :new, :params => {
|
||||
:project_id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
|
||||
@@ -59,26 +61,38 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new_on_invalid_project
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 'invalid'
|
||||
get :new, :params => {
|
||||
:project_id => 'invalid'
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_new_time_entry_query
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1, :type => 'TimeEntryQuery'
|
||||
get :new, :params => {
|
||||
:project_id => 1,
|
||||
:type => 'TimeEntryQuery'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=type][value=?]', 'TimeEntryQuery'
|
||||
end
|
||||
|
||||
def test_create_project_public_query
|
||||
@request.session[:user_id] = 2
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:f => ["status_id", "assigned_to_id"],
|
||||
:op => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_project_public_query", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:f => ["status_id", "assigned_to_id"],
|
||||
:op => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
: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')
|
||||
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
|
||||
@request.session[:user_id] = 3
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_project_private_query", "visibility" => "0"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
: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')
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
: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')
|
||||
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
|
||||
@request.session[:user_id] = 3
|
||||
post :create,
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_global_private_query", "visibility" => "0"},
|
||||
:c => ["", "tracker", "subject", "priority", "category"]
|
||||
post :create, :params => {
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["me"], "status_id" => ["1"]
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_global_private_query", "visibility" => "0"
|
||||
},
|
||||
:c => ["", "tracker", "subject", "priority", "category"]
|
||||
}
|
||||
|
||||
q = Query.find_by_name('test_new_global_private_query')
|
||||
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
|
||||
@request.session[:user_id] = 3
|
||||
post :create,
|
||||
:fields => ["assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "="},
|
||||
:values => { "assigned_to_id" => ["me"]},
|
||||
:query => {"name" => "test_new_global_query"}
|
||||
post :create, :params => {
|
||||
:fields => ["assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "="
|
||||
},
|
||||
:values => {
|
||||
"assigned_to_id" => ["me"]
|
||||
},
|
||||
:query => {
|
||||
"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
|
||||
@@ -155,13 +197,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_create_with_sort
|
||||
@request.session[:user_id] = 1
|
||||
post :create,
|
||||
:default_columns => '1',
|
||||
:operators => {"status_id" => "o"},
|
||||
:values => {"status_id" => ["1"]},
|
||||
:query => {:name => "test_new_with_sort",
|
||||
:visibility => "2",
|
||||
:sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}}
|
||||
post :create, :params => {
|
||||
:default_columns => '1',
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
:query => {
|
||||
:name => "test_new_with_sort",
|
||||
:visibility => "2",
|
||||
:sort_criteria => {
|
||||
"0" => ["due_date", "desc"], "1" => ["tracker", ""]}
|
||||
}
|
||||
}
|
||||
|
||||
query = Query.find_by_name("test_new_with_sort")
|
||||
assert_not_nil query
|
||||
@@ -171,7 +221,12 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference '::Query.count' do
|
||||
post :create, :project_id => 'ecookbook', :query => {:name => ''}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
@@ -181,13 +236,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_global_query_from_gantt
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'IssueQuery.count' do
|
||||
post :create,
|
||||
:gantt => 1,
|
||||
:operators => {"status_id" => "o"},
|
||||
:values => {"status_id" => ["1"]},
|
||||
:query => {:name => "test_create_from_gantt",
|
||||
:draw_relations => '1',
|
||||
:draw_progress_line => '1'}
|
||||
post :create, :params => {
|
||||
:gantt => 1,
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
:query => {
|
||||
:name => "test_create_from_gantt",
|
||||
:draw_relations => '1',
|
||||
:draw_progress_line => '1'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
query = IssueQuery.order('id DESC').first
|
||||
@@ -199,14 +261,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_project_query_from_gantt
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'IssueQuery.count' do
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:gantt => 1,
|
||||
:operators => {"status_id" => "o"},
|
||||
:values => {"status_id" => ["1"]},
|
||||
:query => {:name => "test_create_from_gantt",
|
||||
:draw_relations => '0',
|
||||
:draw_progress_line => '0'}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:gantt => 1,
|
||||
:operators => {
|
||||
"status_id" => "o"
|
||||
},
|
||||
:values => {
|
||||
"status_id" => ["1"]
|
||||
},
|
||||
:query => {
|
||||
:name => "test_create_from_gantt",
|
||||
:draw_relations => '0',
|
||||
:draw_progress_line => '0'
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
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
|
||||
@request.session[:user_id] = 3
|
||||
query = new_record(Query) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:query => {"name" => "name", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query => {
|
||||
"name" => "name", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
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
|
||||
@request.session[:user_id] = 3
|
||||
query = new_record(Query) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
||||
:query => {"name" => "name", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query_is_for_all => '1',
|
||||
:query => {
|
||||
"name" => "name", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
assert_nil query.project
|
||||
@@ -242,9 +318,12 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_project_public_query_with_manage_public_queries_permission
|
||||
@request.session[:user_id] = 2
|
||||
query = new_record(Query) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:query => {"name" => "name", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query => {
|
||||
"name" => "name", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
query = new_record(Query) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
||||
:query => {"name" => "name", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query_is_for_all => '1',
|
||||
:query => {
|
||||
"name" => "name", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
assert_nil query.project
|
||||
@@ -266,9 +349,13 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_global_public_query_by_admin
|
||||
@request.session[:user_id] = 1
|
||||
query = new_record(Query) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook', :query_is_for_all => '1',
|
||||
:query => {"name" => "name", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:query_is_for_all => '1',
|
||||
:query => {
|
||||
"name" => "name", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
assert_nil query.project
|
||||
@@ -279,14 +366,21 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
q = new_record(TimeEntryQuery) do
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:type => 'TimeEntryQuery',
|
||||
:default_columns => '1',
|
||||
:f => ["spent_on"],
|
||||
:op => {"spent_on" => "="},
|
||||
:v => { "spent_on" => ["2016-07-14"]},
|
||||
:query => {"name" => "test_new_project_public_query", "visibility" => "2"}
|
||||
post :create, :params => {
|
||||
:project_id => 'ecookbook',
|
||||
:type => 'TimeEntryQuery',
|
||||
:default_columns => '1',
|
||||
:f => ["spent_on"],
|
||||
:op => {
|
||||
"spent_on" => "="
|
||||
},
|
||||
:v => {
|
||||
"spent_on" => ["2016-07-14"]
|
||||
},
|
||||
:query => {
|
||||
"name" => "test_new_project_public_query", "visibility" => "2"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 4
|
||||
get :edit, :params => {
|
||||
:id => 4
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||
@@ -306,7 +402,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_global_private_query
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 3
|
||||
get :edit, :params => {
|
||||
:id => 3
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||
@@ -315,7 +413,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_project_private_query
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 2
|
||||
get :edit, :params => {
|
||||
:id => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?]', 'query[visibility]', 0
|
||||
@@ -324,7 +424,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_project_public_query
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
get :edit, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
|
||||
@@ -333,7 +435,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_sort_criteria
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 5
|
||||
get :edit, :params => {
|
||||
:id => 5
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
|
||||
@@ -344,19 +448,28 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit_invalid_query
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 99
|
||||
get :edit, :params => {
|
||||
:id => 99
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_udpate_global_private_query
|
||||
@request.session[:user_id] = 3
|
||||
put :update,
|
||||
:id => 3,
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_edit_global_private_query", "visibility" => "2"}
|
||||
put :update, :params => {
|
||||
:id => 3,
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
: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
|
||||
q = Query.find_by_name('test_edit_global_private_query')
|
||||
@@ -367,13 +480,20 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_global_public_query
|
||||
@request.session[:user_id] = 1
|
||||
put :update,
|
||||
:id => 4,
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_edit_global_public_query", "visibility" => "2"}
|
||||
put :update, :params => {
|
||||
:id => 4,
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {
|
||||
"assigned_to_id" => "=", "status_id" => "o"
|
||||
},
|
||||
: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
|
||||
q = Query.find_by_name('test_edit_global_public_query')
|
||||
@@ -384,28 +504,40 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_update_with_failure
|
||||
@request.session[:user_id] = 1
|
||||
put :update, :id => 4, :query => {:name => ''}
|
||||
put :update, :params => {
|
||||
:id => 4,
|
||||
:query => {
|
||||
:name => ''
|
||||
}
|
||||
}
|
||||
assert_response :success
|
||||
assert_select_error /Name cannot be blank/
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@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_nil Query.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_backslash_should_be_escaped_in_filters
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :subject => 'foo/bar'
|
||||
get :new, :params => {
|
||||
:subject => 'foo/bar'
|
||||
}
|
||||
assert_response :success
|
||||
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
|
||||
end
|
||||
|
||||
def test_filter_with_project_id_should_return_filter_values
|
||||
@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_equal 'application/json', response.content_type
|
||||
@@ -415,7 +547,9 @@ class QueriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_filter_without_project_id_should_return_filter_values
|
||||
@request.session[:user_id] = 2
|
||||
get :filter, :name => 'fixed_version_id'
|
||||
get :filter, :params => {
|
||||
:name => 'fixed_version_id'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
|
||||
@@ -28,13 +28,18 @@ class ReportsControllerTest < Redmine::ControllerTest
|
||||
:versions
|
||||
|
||||
def test_get_issue_report
|
||||
get :issue_report, :id => 1
|
||||
get :issue_report, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_issue_report_details
|
||||
%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
|
||||
end
|
||||
end
|
||||
@@ -46,7 +51,10 @@ class ReportsControllerTest < Redmine::ControllerTest
|
||||
Issue.generate!(:tracker_id => 1, :status_id => 5)
|
||||
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 'td', :text => 'Bug'
|
||||
assert_select ':nth-child(2)', :text => '2' # status:1
|
||||
@@ -58,7 +66,10 @@ class ReportsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,7 +42,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Bazaar'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Bazaar'
|
||||
@@ -50,7 +53,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 2
|
||||
@@ -60,7 +65,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'table.entries tbody' do
|
||||
assert_select 'tr', 3
|
||||
@@ -71,8 +79,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 4
|
||||
@@ -84,32 +95,40 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => PRJ_ID,
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /doc-mkdir.txt/
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
# Line 19
|
||||
assert_select 'tr#L29 td.line-code', :text => /Show help message/
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('Show help message')
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['directory'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody'
|
||||
end
|
||||
@@ -117,7 +136,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
def test_diff
|
||||
# Full diff of changeset 3
|
||||
['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
|
||||
# Line 11 removed
|
||||
assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/
|
||||
@@ -125,8 +148,10 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => PRJ_ID,
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select "th.line-num", :text => '2' do
|
||||
@@ -147,8 +172,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
:identifier => 'author_escaping',
|
||||
:log_encoding => 'UTF-8')
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
@@ -175,8 +203,11 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
:identifier => 'author_non_ascii',
|
||||
:log_encoding => log_encoding)
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
@@ -198,7 +229,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
assert @repository.changesets.count > 0
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -217,7 +250,9 @@ class RepositoriesBazaarControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -28,7 +28,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 1
|
||||
get :new, :project_id => 'subproject1'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
||||
@@ -39,7 +41,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_new_should_propose_enabled_scm_only
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :enabled_scm => ['Mercurial', 'Git'] do
|
||||
get :new, :project_id => 'subproject1'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1'
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
@@ -52,7 +56,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_new_with_type
|
||||
@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_select 'select[name=?]', 'repository_scm' do
|
||||
@@ -63,9 +70,15 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_create
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Repository.count' do
|
||||
post :create, :project_id => 'subproject1',
|
||||
:repository_scm => 'Subversion',
|
||||
:repository => {:url => 'file:///test', :is_default => '1', :identifier => ''}
|
||||
post :create, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Subversion',
|
||||
:repository => {
|
||||
:url => 'file:///test',
|
||||
:is_default => '1',
|
||||
:identifier => ''
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
repository = Repository.order('id DESC').first
|
||||
@@ -76,9 +89,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_failure
|
||||
@request.session[:user_id] = 1
|
||||
assert_no_difference 'Repository.count' do
|
||||
post :create, :project_id => 'subproject1',
|
||||
:repository_scm => 'Subversion',
|
||||
:repository => {:url => 'invalid'}
|
||||
post :create, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Subversion',
|
||||
:repository => {
|
||||
:url => 'invalid'
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_select_error /URL is invalid/
|
||||
@@ -89,21 +106,33 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_edit
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 11
|
||||
get :edit, :params => {
|
||||
:id => 11
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test'
|
||||
end
|
||||
|
||||
def test_update
|
||||
@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_equal 'test_update', Repository.find(11).password
|
||||
end
|
||||
|
||||
def test_update_with_failure
|
||||
@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_select_error /Password is too long/
|
||||
end
|
||||
@@ -111,7 +140,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => 11
|
||||
delete :destroy, :params => {
|
||||
:id => 11
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
assert_nil Repository.find_by_id(11)
|
||||
@@ -121,7 +152,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
Repository::Subversion.any_instance.expects(:fetch_changesets).once
|
||||
|
||||
with_settings :autofetch_changesets => '1' do
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,7 +162,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
Repository::Subversion.any_instance.expects(:fetch_changesets).never
|
||||
|
||||
with_settings :autofetch_changesets => '0' do
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -138,12 +173,16 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
Project.find(1).close
|
||||
|
||||
with_settings :autofetch_changesets => '1' do
|
||||
get :show, :id => 1
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def test_revisions
|
||||
get :revisions, :id => 1
|
||||
get :revisions, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.changesets'
|
||||
end
|
||||
@@ -151,18 +190,27 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_revisions_for_other_repository
|
||||
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_select 'table.changesets'
|
||||
end
|
||||
|
||||
def test_revisions_for_invalid_repository
|
||||
get :revisions, :id => 1, :repository_id => 'foo'
|
||||
get :revisions, :params => {
|
||||
:id => 1,
|
||||
:repository_id => 'foo'
|
||||
}
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_revision
|
||||
get :revision, :id => 1, :rev => 1
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => 'Revision 1'
|
||||
end
|
||||
@@ -171,7 +219,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
Changeset.where(:id => 100).update_all(:comments => 'Simple *text*')
|
||||
|
||||
with_settings :commit_logs_formatting => '0' do
|
||||
get :revision, :id => 1, :rev => 1
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select '.changeset-comments', :text => 'Simple *text*'
|
||||
end
|
||||
@@ -181,7 +232,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
Role.find(1).add_permission! :manage_related_issues
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :revision, :id => 1, :rev => 1
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:rev => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/repository/revisions/1/issues' do
|
||||
@@ -190,14 +244,20 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository'
|
||||
end
|
||||
|
||||
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_select 'div.contextual' do
|
||||
@@ -209,7 +269,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_add_related_issue
|
||||
@request.session[:user_id] = 2
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -221,7 +287,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_add_related_issue_should_accept_issue_id_with_sharp
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_equal [2], Changeset.find(103).issue_ids
|
||||
end
|
||||
@@ -229,7 +301,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
def test_add_related_issue_with_invalid_issue_id
|
||||
@request.session[:user_id] = 2
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -242,7 +320,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -256,13 +340,19 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
assert_not_nil latest
|
||||
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_equal 'image/svg+xml', @response.content_type
|
||||
end
|
||||
|
||||
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_equal 'image/svg+xml', @response.content_type
|
||||
end
|
||||
@@ -278,7 +368,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
:comments => 'Committed by foo.'
|
||||
)
|
||||
|
||||
get :committers, :id => 10
|
||||
get :committers, :params => {
|
||||
:id => 10
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
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
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :committers, :id => 10
|
||||
get :committers, :params => {
|
||||
:id => 10
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -304,7 +398,12 @@ class RepositoriesControllerTest < Redmine::ControllerTest
|
||||
:comments => 'Committed by foo.'
|
||||
)
|
||||
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_equal User.find(2), c.reload.user
|
||||
end
|
||||
|
||||
@@ -46,7 +46,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Cvs'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Cvs'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
@@ -59,7 +62,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -78,7 +83,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
@@ -94,8 +102,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -110,8 +121,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'td.line-code', :text => /before_filter/, :count => 0
|
||||
@@ -123,9 +136,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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],
|
||||
:rev => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# this line was removed in r3
|
||||
@@ -137,8 +152,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||
end
|
||||
|
||||
@@ -147,9 +164,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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],
|
||||
:format => 'raw'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -158,8 +177,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody'
|
||||
end
|
||||
@@ -170,7 +191,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['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_select 'td.line-code.diff_out', :text => /before_filter :require_login/
|
||||
@@ -184,7 +209,11 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['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_select 'td.line-code.diff_in', :text => /watched.remove_watcher/
|
||||
@@ -200,8 +229,10 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# 1.1 line
|
||||
@@ -226,7 +257,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -247,7 +280,9 @@ class RepositoriesCvsControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -42,7 +42,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Darcs'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Darcs'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Darcs'
|
||||
@@ -54,7 +57,9 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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 'tr', 3
|
||||
assert_select 'tr.dir td.filename a', :text => 'images'
|
||||
@@ -68,7 +73,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
assert_select 'tr', 2
|
||||
@@ -82,8 +90,11 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'table.entries tbody' do
|
||||
assert_select 'tr', 1
|
||||
@@ -96,8 +107,10 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /edit.png/
|
||||
end
|
||||
@@ -109,7 +122,11 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
# Full diff of changeset 5
|
||||
['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
|
||||
# Line 22 removed
|
||||
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_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -144,7 +163,9 @@ class RepositoriesDarcsControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -43,7 +43,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Filesystem'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Filesystem'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Filesystem'
|
||||
@@ -53,7 +56,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
def test_browse_root
|
||||
@repository.fetch_changesets
|
||||
@repository.reload
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -71,21 +76,29 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'tr#L1 td.line-code', :text => /TEST CAT/
|
||||
end
|
||||
|
||||
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_equal 'application/octet-stream', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_non_ascii_contents
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
||||
if @ruby19_non_utf8_pass
|
||||
@@ -102,8 +115,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
def test_show_utf16
|
||||
enc = 'UTF-16'
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L2 td.line-code', :text => /japanese/
|
||||
end
|
||||
@@ -111,8 +126,10 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_show_text_file_should_show_other_if_too_big
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'p.nodata'
|
||||
@@ -123,7 +140,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1 # admin
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -140,7 +159,9 @@ class RepositoriesFilesystemControllerTest < Redmine::ControllerTest
|
||||
)
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -54,14 +54,17 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
def test_create_and_update
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Repository.count' do
|
||||
post :create, :project_id => 'subproject1',
|
||||
:repository_scm => 'Git',
|
||||
:repository => {
|
||||
:url => '/test',
|
||||
:is_default => '0',
|
||||
:identifier => 'test-create',
|
||||
:report_last_commit => '1',
|
||||
}
|
||||
post :create, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Git',
|
||||
:repository => {
|
||||
:url => '/test',
|
||||
:is_default => '0',
|
||||
:identifier => 'test-create',
|
||||
:report_last_commit => '1',
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
repository = Repository.order('id DESC').first
|
||||
@@ -69,10 +72,13 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert_equal '/test', repository.url
|
||||
assert_equal true, repository.report_last_commit
|
||||
|
||||
put :update, :id => repository.id,
|
||||
:repository => {
|
||||
:report_last_commit => '0'
|
||||
}
|
||||
put :update, :params => {
|
||||
:id => repository.id,
|
||||
:repository => {
|
||||
:report_last_commit => '0'
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
repo2 = Repository.find(repository.id)
|
||||
assert_equal false, repo2.report_last_commit
|
||||
@@ -92,7 +98,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Git'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Git'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Git'
|
||||
@@ -105,7 +114,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -131,7 +142,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
@@ -156,7 +170,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
"tag00.lightweight",
|
||||
"tag01.annotated",
|
||||
].each do |t1|
|
||||
get :show, :id => PRJ_ID, :rev => t1
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => t1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody tr'
|
||||
@@ -169,7 +186,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
@@ -184,8 +204,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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'
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -195,15 +218,19 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => PRJ_ID,
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /edit.png/
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
# Line 11
|
||||
assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
||||
@@ -219,9 +246,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
else
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
get :entry, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:rev => r1
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
|
||||
end
|
||||
@@ -230,17 +259,21 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2 a', :text => 'sources'
|
||||
assert_select 'table.entries tbody'
|
||||
@@ -255,10 +288,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
# Full diff of changeset 2f9c0091
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
# Line 22 removed
|
||||
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
|
||||
# Full diff of changeset 2f9c0091
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
# Line 22 removed
|
||||
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
|
||||
with_cache do
|
||||
with_settings :default_language => 'en' do
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
assert_response :success
|
||||
assert @response.body.include?("... This diff was truncated")
|
||||
end
|
||||
with_settings :default_language => 'fr' do
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
assert_response :success
|
||||
assert ! @response.body.include?("... This diff was truncated")
|
||||
assert @response.body.include?("... Ce diff")
|
||||
@@ -319,11 +360,12 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
|
||||
:rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /2f9c0091:61b685fb/
|
||||
assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff'
|
||||
@@ -341,12 +383,13 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert repo
|
||||
assert_equal false, repo.is_default
|
||||
assert_equal 'test-diff-path', repo.identifier
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:repository_id => 'test-diff-path',
|
||||
:rev => '61b685fbe55ab05b',
|
||||
:rev_to => '2f9c0091c754a91a',
|
||||
:type => 'inline'
|
||||
}
|
||||
assert_response :success
|
||||
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'
|
||||
@@ -359,7 +402,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
['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_select 'table' do
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
|
||||
@@ -372,7 +419,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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
|
||||
# modified file
|
||||
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
||||
@@ -388,24 +439,28 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert_nil user.pref[:diff_type]
|
||||
|
||||
@request.session[:user_id] = 1 # admin
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
}
|
||||
assert_response :success
|
||||
user.reload
|
||||
assert_equal "inline", user.pref[:diff_type]
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
|
||||
:type => 'sbs'
|
||||
}
|
||||
assert_response :success
|
||||
user.reload
|
||||
assert_equal "sbs", user.pref[:diff_type]
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => PRJ_ID,
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Line 23, changeset 2f9c0091
|
||||
@@ -422,16 +477,21 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /@ deff712f/
|
||||
end
|
||||
|
||||
def test_annotate_binary_file
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'p#errorExplanation', :text => /cannot be annotated/
|
||||
end
|
||||
@@ -439,15 +499,19 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_annotate_error_when_too_big
|
||||
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],
|
||||
:rev => 'deff712f'
|
||||
}
|
||||
assert_response :success
|
||||
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],
|
||||
:rev => '7234cb2'
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
@@ -462,9 +526,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
else
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
|
||||
get :annotate, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:rev => r1
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
assert_select "+ td.revision" do
|
||||
assert_select "a", :text => '57ca437c'
|
||||
@@ -481,9 +547,11 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_annotate_latin_1_author
|
||||
['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],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
assert_select "+ td.revision" do
|
||||
assert_select "a", :text => '83ca5fd5'
|
||||
@@ -501,7 +569,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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'
|
||||
end
|
||||
|
||||
@@ -511,7 +581,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
|
||||
get :revision, :id => PRJ_ID, :rev => r
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => r
|
||||
}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
@@ -522,7 +595,10 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['', ' ', nil].each do |r|
|
||||
get :revision, :id => PRJ_ID, :rev => r
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
assert_select_error /was not found/
|
||||
end
|
||||
@@ -536,7 +612,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -556,7 +634,9 @@ class RepositoriesGitControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -56,7 +56,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Mercurial'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Mercurial'
|
||||
@@ -68,7 +71,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -89,7 +94,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
@@ -109,8 +117,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[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
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -130,9 +141,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[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],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -156,9 +169,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[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],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -182,7 +197,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
def show_should_show_branch_selection_form
|
||||
@repository.fetch_changesets
|
||||
@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 'select[name=branch]' do
|
||||
assert_select 'option[value=?]', 'test-branch-01'
|
||||
@@ -203,7 +220,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
'test_branch.latin-1',
|
||||
'test-branch-00',
|
||||
].each do |bra|
|
||||
get :show, :id => PRJ_ID, :rev => bra
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => bra
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody tr'
|
||||
@@ -221,7 +241,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
'tag_test.00',
|
||||
'tag-init-revision'
|
||||
].each do |tag|
|
||||
get :show, :id => PRJ_ID, :rev => tag
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => tag
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody tr'
|
||||
@@ -230,15 +253,19 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => PRJ_ID,
|
||||
get :changes, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /edit.png/
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
# Line 10
|
||||
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
|
||||
[21, '21', 'adf805632193'].each do |r1|
|
||||
get :entry, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:rev => r1
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/
|
||||
end
|
||||
@@ -257,9 +286,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
def test_entry_show_latin_1_contents
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
[27, '27', '7bbf4c738e71'].each do |r1|
|
||||
get :entry, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:rev => r1
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||
end
|
||||
@@ -267,9 +298,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
||||
:format => 'raw'
|
||||
}
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||
@@ -280,8 +313,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => PRJ_ID,
|
||||
get :entry, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2 a', :text => 'sources'
|
||||
assert_select 'table.entries tbody'
|
||||
@@ -295,7 +330,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
[4, '4', 'def6d2f1254a'].each do |r1|
|
||||
# Full diff of changeset 4
|
||||
['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
|
||||
if @diff_c_support
|
||||
# Line 22 removed
|
||||
@@ -314,11 +353,12 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
[2, '400bb8672109', '400', 400].each do |r1|
|
||||
[4, 'def6d2f1254a'].each do |r2|
|
||||
['inline', 'sbs'].each do |dt|
|
||||
get :diff,
|
||||
get :diff, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => r1,
|
||||
:rev_to => r2,
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/
|
||||
end
|
||||
@@ -330,7 +370,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
[21, 'adf805632193'].each do |r1|
|
||||
['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_select 'table' do
|
||||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
|
||||
@@ -342,20 +386,30 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
||||
end
|
||||
|
||||
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_select 'th.filename', :text => 'sources/welcome_controller.rb'
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => PRJ_ID,
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
# Line 22, revision 4:def6d2f1254a
|
||||
@@ -372,8 +426,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response 404
|
||||
assert_select_error /was not found/
|
||||
end
|
||||
@@ -384,8 +440,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
[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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /@ 2:400bb8672109/
|
||||
end
|
||||
@@ -393,9 +452,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_annotate_latin_1_path
|
||||
[21, '21', 'adf805632193'].each do |r1|
|
||||
get :annotate, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:rev => r1
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_response :success
|
||||
assert_select "th.line-num", :text => '1' do
|
||||
assert_select "+ td.revision" do
|
||||
@@ -412,9 +473,11 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
def test_annotate_latin_1_contents
|
||||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||||
[27, '7bbf4c738e71'].each do |r1|
|
||||
get :annotate, :id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:rev => r1
|
||||
get :annotate, :params => {
|
||||
:id => PRJ_ID,
|
||||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||||
:rev => r1
|
||||
}
|
||||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||||
end
|
||||
end
|
||||
@@ -427,7 +490,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['1', '9d5b5b', '9d5b5b004199'].each do |r|
|
||||
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_select 'title',
|
||||
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
||||
@@ -441,7 +507,10 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['', ' ', nil].each do |r|
|
||||
get :revision, :id => PRJ_ID, :rev => r
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
assert_select_error /was not found/
|
||||
end
|
||||
@@ -454,7 +523,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -473,7 +544,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
|
||||
@@ -41,7 +41,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
def test_new
|
||||
@request.session[:user_id] = 1
|
||||
@project.repository.destroy
|
||||
get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
|
||||
get :new, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:repository_scm => 'Subversion'
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'select[name=?]', 'repository_scm' do
|
||||
assert_select 'option[value=?][selected=selected]', 'Subversion'
|
||||
@@ -53,7 +56,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
get :show, :id => PRJ_ID
|
||||
get :show, :params => {
|
||||
:id => PRJ_ID
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -78,7 +83,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
:url => self.class.subversion_repository_url,
|
||||
: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_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]'
|
||||
@@ -91,7 +99,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select 'table.entries tbody' do
|
||||
@@ -111,8 +122,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.entries tbody' do
|
||||
@@ -130,8 +144,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
@@ -155,8 +171,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'table.changesets tbody' do
|
||||
@@ -175,8 +193,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2 a', :text => 'subversion_test'
|
||||
assert_select 'h2 a', :text => 'helloworld.c'
|
||||
@@ -189,8 +209,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
# no files in the test repo is larger than 1KB...
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.content_type
|
||||
assert_select 'p.nodata'
|
||||
@@ -198,8 +220,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
|
||||
end
|
||||
@@ -209,9 +233,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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],
|
||||
:rev => 2
|
||||
}
|
||||
assert_response :success
|
||||
# this line was removed in r3 and file was moved in r6
|
||||
assert_select 'td.line-code', :text => /Here's the code/
|
||||
@@ -222,8 +248,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
||||
end
|
||||
|
||||
@@ -232,8 +260,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
|
||||
end
|
||||
@@ -243,8 +273,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2 a', :text => 'subversion_test'
|
||||
assert_select 'h2 a', :text => 'folder'
|
||||
@@ -252,7 +284,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
|
||||
# TODO: this test needs fixtures.
|
||||
def test_revision
|
||||
get :revision, :id => 1, :rev => 2
|
||||
get :revision, :params => {
|
||||
:id => 1,
|
||||
:rev => 2
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'ul' do
|
||||
@@ -270,13 +305,20 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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_select_error /was not found/
|
||||
end
|
||||
|
||||
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_select_error /was not found/
|
||||
end
|
||||
@@ -287,7 +329,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['', ' ', nil].each do |r|
|
||||
get :revision, :id => PRJ_ID, :rev => r
|
||||
get :revision, :params => {
|
||||
:id => PRJ_ID,
|
||||
:rev => r
|
||||
}
|
||||
assert_response 404
|
||||
assert_select_error /was not found/
|
||||
end
|
||||
@@ -299,7 +344,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
# Changes repository url to a subdirectory
|
||||
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_select 'ul' do
|
||||
@@ -318,7 +366,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['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_select 'h2', :text => /Revision 3/
|
||||
assert_select 'th.filename', :text => 'subversion_test/textfile.txt'
|
||||
@@ -331,7 +383,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
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_equal 'text/x-patch', @response.content_type
|
||||
assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first
|
||||
@@ -343,9 +399,13 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
['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],
|
||||
:type => dt
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'h2', :text => /2:6/
|
||||
@@ -361,8 +421,10 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'tr' do
|
||||
@@ -384,8 +446,11 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
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]
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'h2', :text => /@ 8/
|
||||
end
|
||||
@@ -397,7 +462,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@project.reload
|
||||
@@ -414,7 +481,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
||||
assert_equal 0, @repository.changesets.count
|
||||
|
||||
assert_difference 'Repository.count', -1 do
|
||||
delete :destroy, :id => @repository.id
|
||||
delete :destroy, :params => {
|
||||
:id => @repository.id
|
||||
}
|
||||
end
|
||||
assert_response 302
|
||||
@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)
|
||||
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
|
||||
token.reload
|
||||
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)
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
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'
|
||||
end
|
||||
|
||||
@@ -63,7 +71,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||
|
||||
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'
|
||||
end
|
||||
end
|
||||
@@ -73,7 +84,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -83,7 +97,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||
|
||||
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'
|
||||
end
|
||||
end
|
||||
@@ -93,7 +110,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
||||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created)
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -106,7 +126,10 @@ class SessionsControllerTest < Redmine::ControllerTest
|
||||
autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago)
|
||||
@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_response :success
|
||||
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)
|
||||
|
||||
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_include "Veuillez vous reconnecter", flash[:error]
|
||||
assert_equal :fr, current_language
|
||||
|
||||
@@ -136,7 +136,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new_from_issue_form
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :new, :params => {:project_id => '1'}
|
||||
get :new, :params => {:project_id => '1'}, :xhr => true
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -155,7 +155,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
||||
def test_create_from_issue_form
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
version = Version.find_by_name('test_add_version_from_issue_form')
|
||||
assert_not_nil version
|
||||
@@ -169,7 +169,7 @@ class VersionsControllerTest < Redmine::ControllerTest
|
||||
def test_create_from_issue_form_with_failure
|
||||
@request.session[:user_id] = 2
|
||||
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
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
@@ -247,12 +247,12 @@ class VersionsControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
|
||||
def test_issue_status_by
|
||||
xhr :get, :status_by, :params => {:id => 2}
|
||||
get :status_by, :params => {:id => 2}, :xhr => true
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
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_include 'Assigned', response.body
|
||||
assert_include 'Closed', response.body
|
||||
|
||||
@@ -38,7 +38,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_watch_a_single_object
|
||||
@request.session[:user_id] = 3
|
||||
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_include '$(".issue-1-watcher")', response.body
|
||||
end
|
||||
@@ -48,7 +48,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_watch_a_collection_with_a_single_object
|
||||
@request.session[:user_id] = 3
|
||||
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_include '$(".issue-1-watcher")', response.body
|
||||
end
|
||||
@@ -58,7 +58,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_watch_a_collection_with_multiple_objects
|
||||
@request.session[:user_id] = 3
|
||||
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_include '$(".issue-bulk-watcher")', response.body
|
||||
end
|
||||
@@ -71,7 +71,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
assert_not_nil m = Project.find(1).enabled_module('news')
|
||||
|
||||
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
|
||||
end
|
||||
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_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
|
||||
end
|
||||
end
|
||||
@@ -91,7 +91,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
Role.find(2).remove_permission! :view_issues
|
||||
@request.session[:user_id] = 3
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -99,7 +99,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_watch_invalid_class_should_respond_with_404
|
||||
@request.session[:user_id] = 3
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -107,7 +107,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_watch_invalid_object_should_respond_with_404
|
||||
@request.session[:user_id] = 3
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -125,7 +125,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_unwatch
|
||||
@request.session[:user_id] = 3
|
||||
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_include '$(".issue-2-watcher")', response.body
|
||||
end
|
||||
@@ -138,7 +138,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
Watcher.create!(:user_id => 3, :watchable => Issue.find(3))
|
||||
|
||||
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_include '$(".issue-bulk-watcher")', response.body
|
||||
end
|
||||
@@ -148,28 +148,28 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_new
|
||||
@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_match /ajax-modal/, response.body
|
||||
end
|
||||
|
||||
def test_new_with_multiple_objects
|
||||
@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_match /ajax-modal/, response.body
|
||||
end
|
||||
|
||||
def test_new_for_new_record_with_project_id
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :new, :params => {:project_id => 1}
|
||||
get :new, :params => {:project_id => 1}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /ajax-modal/, response.body
|
||||
end
|
||||
|
||||
def test_new_for_new_record_with_project_identifier
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :new, :params => {:project_id => 'ecookbook'}
|
||||
get :new, :params => {:project_id => 'ecookbook'}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /ajax-modal/, response.body
|
||||
end
|
||||
@@ -190,10 +190,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_create
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count') do
|
||||
xhr :post, :create, :params => {
|
||||
post :create, :params => {
|
||||
:object_type => 'issue', :object_id => '2',
|
||||
:watcher => {:user_id => '4'}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
assert_match /ajax-modal/, response.body
|
||||
@@ -204,10 +204,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_mutiple_users
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count', 2) do
|
||||
xhr :post, :create, :params => {
|
||||
post :create, :params => {
|
||||
:object_type => 'issue', :object_id => '2',
|
||||
:watcher => {:user_ids => ['4', '7']}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
assert_match /ajax-modal/, response.body
|
||||
@@ -219,10 +219,10 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_create_with_mutiple_objects
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count', 4) do
|
||||
xhr :post, :create, :params => {
|
||||
post :create, :params => {
|
||||
:object_type => 'issue', :object_id => ['1', '2'],
|
||||
:watcher => {:user_ids => ['4', '7']}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
assert_match /ajax-modal/, response.body
|
||||
@@ -235,7 +235,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_autocomplete_on_watchable_creation
|
||||
@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_select 'input', :count => 4
|
||||
assert_select 'input[name=?][value="1"]', 'watcher[user_ids][]'
|
||||
@@ -250,17 +250,17 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
user = User.generate!(:firstname => 'issue15622')
|
||||
membership = user.membership(project)
|
||||
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_select 'input', :count => 1
|
||||
end
|
||||
|
||||
def test_autocomplete_on_watchable_update
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :autocomplete_for_user, :params => {
|
||||
get :autocomplete_for_user, :params => {
|
||||
:object_type => 'issue', :object_id => '2',
|
||||
:project_id => 'ecookbook', :q => 'mi'
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_select 'input', :count => 3
|
||||
assert_select 'input[name=?][value="2"]', 'watcher[user_ids][]'
|
||||
@@ -275,18 +275,18 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
membership = user.membership(project)
|
||||
assert_nil membership
|
||||
|
||||
xhr :get, :autocomplete_for_user, :params => {
|
||||
get :autocomplete_for_user, :params => {
|
||||
:object_type => 'issue', :object_id => '2',
|
||||
:project_id => 'ecookbook', :q => 'issue15622'
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_select 'input', :count => 1
|
||||
|
||||
assert_difference('Watcher.count', 1) do
|
||||
xhr :post, :create, :params => {
|
||||
post :create, :params => {
|
||||
:object_type => 'issue', :object_id => '2',
|
||||
:watcher => {:user_ids => ["#{user.id}"]}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
assert_match /ajax-modal/, response.body
|
||||
@@ -302,7 +302,7 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
User.add_to_project(visible, Project.find(1))
|
||||
|
||||
@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_include visible.name, response.body
|
||||
@@ -312,9 +312,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_append
|
||||
@request.session[:user_id] = 2
|
||||
assert_no_difference 'Watcher.count' do
|
||||
xhr :post, :append, :params => {
|
||||
post :append, :params => {
|
||||
:watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook'
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_include 'watchers_inputs', 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
|
||||
@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.body.blank?
|
||||
end
|
||||
@@ -343,9 +343,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count', -1) do
|
||||
xhr :delete, :destroy, :params => {
|
||||
delete :destroy, :params => {
|
||||
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
end
|
||||
@@ -359,9 +359,9 @@ class WatchersControllerTest < Redmine::ControllerTest
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count', -1) do
|
||||
xhr :delete, :destroy, :params => {
|
||||
delete :destroy, :params => {
|
||||
:object_type => 'issue', :object_id => '2', :user_id => '3'
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_match /watchers/, response.body
|
||||
end
|
||||
|
||||
@@ -188,7 +188,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
def test_get_new_xhr
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
xhr :get, :new, :params => {:project_id => 'ecookbook'}
|
||||
get :new, :params => {:project_id => 'ecookbook'}, :xhr => true
|
||||
assert_response :success
|
||||
assert_include 'Unallowed characters', response.body
|
||||
end
|
||||
@@ -203,7 +203,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
def test_post_new_xhr_with_valid_title_should_redirect_to_edit
|
||||
@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_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body
|
||||
end
|
||||
@@ -228,7 +228,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
def test_post_new_xhr_with_invalid_title_should_display_errors
|
||||
@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_include 'Title has already been taken', response.body
|
||||
end
|
||||
@@ -581,7 +581,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_preview
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :preview, :params => {
|
||||
post :preview, :params => {
|
||||
:project_id => 1,
|
||||
:id => 'CookBook_documentation',
|
||||
:content => {
|
||||
@@ -589,14 +589,14 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
:text => 'this is a *previewed text*',
|
||||
:version => 3
|
||||
}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_select 'strong', :text => /previewed text/
|
||||
end
|
||||
|
||||
def test_preview_new_page
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :preview, :params => {
|
||||
post :preview, :params => {
|
||||
:project_id => 1,
|
||||
:id => 'New page',
|
||||
:content => {
|
||||
@@ -604,7 +604,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
||||
:comments => '',
|
||||
:version => 0
|
||||
}
|
||||
}
|
||||
}, :xhr => true
|
||||
assert_response :success
|
||||
assert_select 'h1', :text => /New page/
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
||||
assert_nil Project.find(3).wiki
|
||||
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
@@ -56,7 +56,7 @@ class WikisControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
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_equal 'text/javascript', response.content_type
|
||||
end
|
||||
|
||||
@@ -320,10 +320,12 @@ module Redmine
|
||||
assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match"
|
||||
end
|
||||
|
||||
def process(method, path, parameters={}, session={}, flash={})
|
||||
if parameters.key?(:params) || parameters.key?(:session)
|
||||
raise ArgumentError if session.present?
|
||||
super method, path, parameters[:params], parameters[:session], parameters.except(:params, :session)
|
||||
def process(action, http_method = 'GET', *args)
|
||||
parameters, session, flash = *args
|
||||
if args.size == 1 && parameters[:xhr] == true
|
||||
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
|
||||
super
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user