##// END OF EJS Templates
Fixed that magic links to existing attachments are not converted when previewing issue notes....
Fixed that magic links to existing attachments are not converted when previewing issue notes. git-svn-id: http://svn.redmine.org/redmine/trunk@12476 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r11790:010bfc56e15f
r12201:58a63c49c49b
Show More
queries_controller_test.rb
317 lines | 12.2 KiB | text/x-ruby | RubyLexer
/ test / functional / queries_controller_test.rb
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805 # Redmine - project management software
Jean-Philippe Lang
Copyright for 2013 (#12788)....
r10939 # Copyright (C) 2006-2013 Jean-Philippe Lang
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805 #
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805 #
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class QueriesControllerTest < ActionController::TestCase
Jean-Baptiste Barth
Fixed some more test/functional/*_test.rb breaking when run alone (#12285)...
r10565 fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries, :enabled_modules
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 def setup
User.current = nil
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Code cleanup....
r10758 def test_index
get :index
# HTML response not implemented
assert_response 406
end
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_new_project_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
assert_template 'new'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?][value=0][checked=checked]', 'query[visibility]'
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
:disabled => nil }
Jean-Philippe Lang
Fixed that columns selection in not displayed on the custom query form (#10972)....
r9519 assert_select 'select[name=?]', 'c[]' do
assert_select 'option[value=tracker]'
assert_select 'option[value=subject]'
end
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_new_global_query
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 @request.session[:user_id] = 2
get :new
assert_response :success
assert_template 'new'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?]', 'query[visibility]', 0
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
:disabled => nil }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_new_on_invalid_project
@request.session[:user_id] = 2
get :new, :project_id => 'invalid'
assert_response 404
end
def test_create_project_public_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 2
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 post :create,
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805 :project_id => 'ecookbook',
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 :default_columns => '1',
Jean-Philippe Lang
Shortens filter param names....
r5159 :f => ["status_id", "assigned_to_id"],
:op => {"assigned_to_id" => "=", "status_id" => "o"},
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :query => {"name" => "test_new_project_public_query", "visibility" => "2"}
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 q = Query.find_by_name('test_new_project_public_query')
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert q.is_public?
assert q.has_default_columns?
assert q.valid?
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_create_project_private_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 3
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 post :create,
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805 :project_id => 'ecookbook',
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 :default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :query => {"name" => "test_new_project_private_query", "visibility" => "2"}
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 q = Query.find_by_name('test_new_project_private_query')
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert !q.is_public?
assert q.has_default_columns?
assert q.valid?
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_create_global_private_query_with_custom_columns
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 @request.session[:user_id] = 3
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 post :create,
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 :fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :query => {"name" => "test_new_global_private_query", "visibility" => "2"},
Jean-Philippe Lang
Shorten query[column_names] param name....
r5184 :c => ["", "tracker", "subject", "priority", "category"]
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 q = Query.find_by_name('test_new_global_private_query')
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 assert !q.is_public?
assert !q.has_default_columns?
Jean-Philippe Lang
Refactor: makes issue id a regular QueryColumn....
r11217 assert_equal [:id, :tracker, :subject, :priority, :category], q.columns.collect {|c| c.name}
Jean-Philippe Lang
Global queries can be saved from the global issue list (follows r1311 and closes #897)....
r1297 assert q.valid?
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_create_global_query_with_custom_filters
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 @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"}
q = Query.find_by_name('test_new_global_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
assert !q.has_filter?(:status_id)
assert_equal ['assigned_to_id'], q.filters.keys
assert q.valid?
end
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_create_with_sort
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 @request.session[:user_id] = 1
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 post :create,
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 :default_columns => '1',
:operators => {"status_id" => "o"},
:values => {"status_id" => ["1"]},
:query => {:name => "test_new_with_sort",
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :visibility => "2",
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 :sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}}
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 query = Query.find_by_name("test_new_with_sort")
assert_not_nil query
assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_create_with_failure
@request.session[:user_id] = 2
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_no_difference '::Query.count' do
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 post :create, :project_id => 'ecookbook', :query => {:name => ''}
end
assert_response :success
assert_template 'new'
Jean-Philippe Lang
Fixed that some input fields are escaped on validation failures (#11027)....
r9528 assert_select 'input[name=?]', 'query[name]'
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 end
Jean-Philippe Lang
Ability to save Gantt query filters (#7836)....
r11790 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'}
assert_response 302
end
query = IssueQuery.order('id DESC').first
assert_redirected_to "/issues/gantt?query_id=#{query.id}"
assert_equal true, query.draw_relations
assert_equal true, query.draw_progress_line
end
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'}
assert_response 302
end
query = IssueQuery.order('id DESC').first
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
assert_equal false, query.draw_relations
assert_equal false, query.draw_progress_line
end
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_global_public_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 1
get :edit, :id => 4
assert_response :success
assert_template 'edit'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?][value=2][checked=checked]', 'query[visibility]'
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
:disabled => 'disabled' }
end
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_global_private_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 3
get :edit, :id => 3
assert_response :success
assert_template 'edit'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?]', 'query[visibility]', 0
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
:disabled => 'disabled' }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_project_private_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 3
get :edit, :id => 2
assert_response :success
assert_template 'edit'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?]', 'query[visibility]', 0
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
:disabled => nil }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_project_public_query
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 @request.session[:user_id] = 2
get :edit, :id => 1
assert_response :success
assert_template 'edit'
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 assert_select 'input[name=?][value=2][checked=checked]', 'query[visibility]'
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
:disabled => 'disabled' }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_sort_criteria
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 @request.session[:user_id] = 1
get :edit, :id => 5
assert_response :success
assert_template 'edit'
assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
:child => { :tag => 'option', :attributes => { :value => 'priority',
:selected => 'selected' } }
assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
:child => { :tag => 'option', :attributes => { :value => 'desc',
:selected => 'selected' } }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/queries_controller_test.rb....
r6805
Jean-Philippe Lang
Additional tests for QueriesController....
r8145 def test_edit_invalid_query
@request.session[:user_id] = 2
get :edit, :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"]},
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :query => {"name" => "test_edit_global_private_query", "visibility" => "2"}
Jean-Philippe Lang
Additional tests for QueriesController....
r8145
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
q = Query.find_by_name('test_edit_global_private_query')
assert !q.is_public?
assert q.has_default_columns?
assert q.valid?
end
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"]},
Jean-Philippe Lang
Role based custom queries (#1019)....
r11764 :query => {"name" => "test_edit_global_public_query", "visibility" => "2"}
Jean-Philippe Lang
Additional tests for QueriesController....
r8145
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
q = Query.find_by_name('test_edit_global_public_query')
assert q.is_public?
assert q.has_default_columns?
assert q.valid?
end
def test_update_with_failure
@request.session[:user_id] = 1
put :update, :id => 4, :query => {:name => ''}
assert_response :success
assert_template 'edit'
end
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 def test_destroy
@request.session[:user_id] = 2
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 delete :destroy, :id => 1
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
assert_nil Query.find_by_id(1)
end
Jean-Philippe Lang
Fixed JSON escaping of filters (#11929)....
r10260
def test_backslash_should_be_escaped_in_filters
@request.session[:user_id] = 2
get :new, :subject => 'foo/bar'
assert_response :success
assert_template 'new'
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
end
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 end