##// END OF EJS Templates
Don't use auth_sources fixtures when not needed....
Don't use auth_sources fixtures when not needed. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8915 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8795:a9161a3fdeff
r8795:a9161a3fdeff
Show More
context_menus_controller_test.rb
251 lines | 10.8 KiB | text/x-ruby | RubyLexer
/ test / functional / context_menus_controller_test.rb
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892
class ContextMenusControllerTest < ActionController::TestCase
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/functional/context_menus_controller_test.rb...
r7369 fixtures :projects,
:trackers,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:workflows,
:journals, :journal_details,
:versions,
:issues, :issue_statuses, :issue_categories,
:users,
Jean-Philippe Lang
Add missing fixtures....
r7898 :enumerations,
:time_entries
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892
def test_context_menu_one_issue
@request.session[:user_id] = 2
get :issues, :ids => [1]
assert_response :success
assert_template 'context_menu'
assert_tag :tag => 'a', :content => 'Edit',
:attributes => { :href => '/issues/1/edit',
:class => 'icon-edit' }
assert_tag :tag => 'a', :content => 'Closed',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bstatus_id%5D=5',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'Immediate',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bpriority_id%5D=8',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
Jean-Baptiste Barth
Do not show inactive issue priorities where not necessary (#8573)....
r5950 assert_no_tag :tag => 'a', :content => 'Inactive Priority'
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 # Versions
assert_tag :tag => 'a', :content => '2.0',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bfixed_version_id%5D=3',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bfixed_version_id%5D=4',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'Dave Lopper',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bassigned_to_id%5D=3',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'Copy',
Jean-Philippe Lang
Use the regular issue form to copy a single issue....
r8432 :attributes => { :href => '/projects/ecookbook/issues/1/copy',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => 'icon-copy' }
Jean-Philippe Lang
Removed the "Move" button for single issue since it can be moved from the reguler update form....
r8413 assert_no_tag :tag => 'a', :content => 'Move'
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_tag :tag => 'a', :content => 'Delete',
Jean-Philippe Lang
Issue destroy is now DELETE only....
r8035 :attributes => { :href => '/issues?ids%5B%5D=1',
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => 'icon-del' }
end
def test_context_menu_one_issue_by_anonymous
get :issues, :ids => [1]
assert_response :success
assert_template 'context_menu'
assert_tag :tag => 'a', :content => 'Delete',
:attributes => { :href => '#',
:class => 'icon-del disabled' }
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/context_menus_controller_test.rb....
r6700
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 def test_context_menu_multiple_issues_of_same_project
@request.session[:user_id] = 2
get :issues, :ids => [1, 2]
assert_response :success
assert_template 'context_menu'
Jean-Philippe Lang
Trying to fix random failures with postgresql due to different ids order in urls....
r4553 assert_not_nil assigns(:issues)
assert_equal [1, 2], assigns(:issues).map(&:id).sort
Toshi MARUYAMA
remove trailing white-spaces from test/functional/context_menus_controller_test.rb....
r6700
Jean-Philippe Lang
Trying to fix random failures with postgresql due to different ids order in urls....
r4553 ids = assigns(:issues).map(&:id).map {|i| "ids%5B%5D=#{i}"}.join('&amp;')
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_tag :tag => 'a', :content => 'Edit',
Jean-Philippe Lang
Trying to fix random failures with postgresql due to different ids order in urls....
r4553 :attributes => { :href => "/issues/bulk_edit?#{ids}",
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => 'icon-edit' }
Jean-Baptiste Barth
Allow mass status update through context menu. #3411...
r3941 assert_tag :tag => 'a', :content => 'Closed',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bstatus_id%5D=5",
Jean-Baptiste Barth
Allow mass status update through context menu. #3411...
r3941 :class => '' }
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_tag :tag => 'a', :content => 'Immediate',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bpriority_id%5D=8",
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'Dave Lopper',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bassigned_to_id%5D=3",
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => '' }
assert_tag :tag => 'a', :content => 'Copy',
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 :attributes => { :href => "/issues/bulk_edit?copy=1&amp;#{ids}",
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => 'icon-copy' }
Jean-Philippe Lang
Removed the "Move" button for issues since they can be moved from the bulk edit form....
r8417 assert_no_tag :tag => 'a', :content => 'Move'
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_tag :tag => 'a', :content => 'Delete',
Jean-Philippe Lang
Issue destroy is now DELETE only....
r8035 :attributes => { :href => "/issues?#{ids}",
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 :class => 'icon-del' }
end
Jean-Baptiste Barth
Added ability to delete issues from different projects through contextual menu (#5332)...
r4122 def test_context_menu_multiple_issues_of_different_projects
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 @request.session[:user_id] = 2
Jean-Baptiste Barth
Added ability to delete issues from different projects through contextual menu (#5332)...
r4122 get :issues, :ids => [1, 2, 6]
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_response :success
assert_template 'context_menu'
Jean-Philippe Lang
Trying to fix random failures with postgresql due to different ids order in urls....
r4553 assert_not_nil assigns(:issues)
assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort
Toshi MARUYAMA
remove trailing white-spaces from test/functional/context_menus_controller_test.rb....
r6700
Jean-Philippe Lang
Trying to fix random failures with postgresql due to different ids order in urls....
r4553 ids = assigns(:issues).map(&:id).map {|i| "ids%5B%5D=#{i}"}.join('&amp;')
Jean-Baptiste Barth
Added ability to edit issues from different project through contextual menu (#5332)...
r4128 assert_tag :tag => 'a', :content => 'Edit',
:attributes => { :href => "/issues/bulk_edit?#{ids}",
:class => 'icon-edit' }
assert_tag :tag => 'a', :content => 'Closed',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bstatus_id%5D=5",
Jean-Baptiste Barth
Added ability to edit issues from different project through contextual menu (#5332)...
r4128 :class => '' }
assert_tag :tag => 'a', :content => 'Immediate',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bpriority_id%5D=8",
Jean-Baptiste Barth
Added ability to edit issues from different project through contextual menu (#5332)...
r4128 :class => '' }
assert_tag :tag => 'a', :content => 'John Smith',
Etienne Massip
Fixed broken issues context tests (#9794)....
r8091 :attributes => { :href => "/issues/bulk_update?#{ids}&amp;issue%5Bassigned_to_id%5D=2",
Jean-Baptiste Barth
Added ability to edit issues from different project through contextual menu (#5332)...
r4128 :class => '' }
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 assert_tag :tag => 'a', :content => 'Delete',
Jean-Philippe Lang
Issue destroy is now DELETE only....
r8035 :attributes => { :href => "/issues?#{ids}",
Jean-Baptiste Barth
Added ability to delete issues from different projects through contextual menu (#5332)...
r4122 :class => 'icon-del' }
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/context_menus_controller_test.rb....
r6700
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 def test_context_menu_should_include_list_custom_fields
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
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 get :issues, :ids => [1]
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704
assert_tag 'a',
:content => 'List',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => 3}}
assert_tag 'a',
:content => 'Foo',
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 :attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo"}
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 assert_tag 'a',
:content => 'none',
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 :attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bcustom_field_values%5D%5B#{field.id}%5D="}
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 end
def test_context_menu_should_not_include_null_value_for_required_custom_fields
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]
assert_tag 'a',
:content => 'List',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => 2}}
end
def test_context_menu_on_single_issue_should_select_current_custom_field_value
field = IssueCustomField.create!(:name => 'List', :field_format => 'list',
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
issue = Issue.find(1)
issue.custom_field_values = {field.id => 'Bar'}
issue.save!
@request.session[:user_id] = 2
get :issues, :ids => [1]
assert_tag 'a',
:content => 'List',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => 3}}
assert_tag 'a',
:content => 'Bar',
:attributes => {:class => /icon-checked/}
end
def test_context_menu_should_include_bool_custom_fields
field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool',
:is_for_all => true, :tracker_ids => [1, 2, 3])
@request.session[:user_id] = 2
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 get :issues, :ids => [1]
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704
assert_tag 'a',
:content => 'Bool',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => 3}}
assert_tag 'a',
:content => 'Yes',
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 :attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1"}
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 end
def test_context_menu_should_include_user_custom_fields
field = IssueCustomField.create!(:name => 'User', :field_format => 'user',
:is_for_all => true, :tracker_ids => [1, 2, 3])
@request.session[:user_id] = 2
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 get :issues, :ids => [1]
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704
assert_tag 'a',
:content => 'User',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => Project.find(1).members.count + 1}}
assert_tag 'a',
:content => 'John Smith',
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 :attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2"}
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 end
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
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 get :issues, :ids => [1]
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704
assert_tag 'a',
:content => 'Version',
:attributes => {:href => '#'},
:sibling => {:tag => 'ul', :children => {:count => Project.find(1).shared_versions.count + 1}}
assert_tag 'a',
:content => '2.0',
Jean-Philippe Lang
Prevent random failures due to params order....
r8729 :attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3"}
Jean-Philippe Lang
Bulk-edit custom fields through context menu (#6296)....
r8704 end
Jean-Philippe Lang
Adds a <<me>> option for assignee in the context menu (#1102)....
r8569 def test_context_menu_by_assignable_user_should_include_assigned_to_me_link
@request.session[:user_id] = 2
get :issues, :ids => [1]
assert_response :success
assert_template 'context_menu'
assert_tag :tag => 'a', :content => / me /,
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bassigned_to_id%5D=2',
:class => '' }
end
Jean-Philippe Lang
Find visible issues only in ContextMenusController#issues....
r4466 def test_context_menu_issue_visibility
get :issues, :ids => [1, 4]
assert_response :success
assert_template 'context_menu'
assert_equal [1], assigns(:issues).collect(&:id)
end
Jean-Philippe Lang
Fixed time entries context menu display according permissions (#9405)....
r7802
def test_time_entries_context_menu
@request.session[:user_id] = 2
get :time_entries, :ids => [1, 2]
assert_response :success
assert_template 'time_entries'
assert_tag 'a', :content => 'Edit'
assert_no_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
end
def test_time_entries_context_menu_without_edit_permission
@request.session[:user_id] = 2
Role.find_by_name('Manager').remove_permission! :edit_time_entries
get :time_entries, :ids => [1, 2]
assert_response :success
assert_template 'time_entries'
assert_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
end
Eric Davis
Refactor: move IssuesController#context_menu to a new controller....
r3892 end