##// END OF EJS Templates
Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188)....
Jean-Philippe Lang -
r11175:7799788b3de6
parent child
Show More
@@ -21,11 +21,11 class IssuesController < ApplicationController
21
21
22 before_filter :find_issue, :only => [:show, :edit, :update]
22 before_filter :find_issue, :only => [:show, :edit, :update]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
24 before_filter :find_project, :only => [:new, :create]
24 before_filter :find_project, :only => [:new, :create, :update_form]
25 before_filter :authorize, :except => [:index]
25 before_filter :authorize, :except => [:index]
26 before_filter :find_optional_project, :only => [:index]
26 before_filter :find_optional_project, :only => [:index]
27 before_filter :check_for_default_issue_status, :only => [:new, :create]
27 before_filter :check_for_default_issue_status, :only => [:new, :create]
28 before_filter :build_new_issue_from_params, :only => [:new, :create]
28 before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
29 accept_rss_auth :index, :show
29 accept_rss_auth :index, :show
30 accept_api_auth :index, :show, :create, :update, :destroy
30 accept_api_auth :index, :show, :create, :update, :destroy
31
31
@@ -132,7 +132,6 class IssuesController < ApplicationController
132 def new
132 def new
133 respond_to do |format|
133 respond_to do |format|
134 format.html { render :action => 'new', :layout => !request.xhr? }
134 format.html { render :action => 'new', :layout => !request.xhr? }
135 format.js { render :partial => 'update_form' }
136 end
135 end
137 end
136 end
138
137
@@ -202,6 +201,11 class IssuesController < ApplicationController
202 end
201 end
203 end
202 end
204
203
204 # Updates the issue form when changing the project, status or tracker
205 # on issue creation/update
206 def update_form
207 end
208
205 # Bulk edit/copy a set of issues
209 # Bulk edit/copy a set of issues
206 def bulk_edit
210 def bulk_edit
207 @issues.sort!
211 @issues.sort!
1 NO CONTENT: file renamed from app/views/issues/_update_form.js.erb to app/views/issues/update_form.js.erb
NO CONTENT: file renamed from app/views/issues/_update_form.js.erb to app/views/issues/update_form.js.erb
@@ -116,7 +116,7 RedmineApp::Application.routes.draw do
116 end
116 end
117 end
117 end
118 # issue form update
118 # issue form update
119 match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form'
119 match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form'
120
120
121 resources :files, :only => [:index, :new, :create]
121 resources :files, :only => [:index, :new, :create]
122
122
@@ -115,7 +115,7 Redmine::AccessControl.map do |map|
115 map.permission :manage_subtasks, {}
115 map.permission :manage_subtasks, {}
116 map.permission :set_issues_private, {}
116 map.permission :set_issues_private, {}
117 map.permission :set_own_issues_private, {}, :require => :loggedin
117 map.permission :set_own_issues_private, {}, :require => :loggedin
118 map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload}
118 map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
119 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
119 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
120 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
120 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
121 map.permission :view_private_notes, {}, :read => true, :require => :member
121 map.permission :view_private_notes, {}, :read => true, :require => :member
@@ -105,12 +105,15 users_006:
105 login: ''
105 login: ''
106 type: AnonymousUser
106 type: AnonymousUser
107 users_007:
107 users_007:
108 # A user who does not belong to any project
108 id: 7
109 id: 7
109 created_on: 2006-07-19 19:33:19 +02:00
110 created_on: 2006-07-19 19:33:19 +02:00
110 status: 1
111 status: 1
111 last_login_on:
112 last_login_on:
112 language: ''
113 language: 'en'
113 hashed_password: 1
114 # password = foo
115 salt: 7599f9963ec07b5a3b55b354407120c0
116 hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
114 updated_on: 2006-07-19 19:33:19 +02:00
117 updated_on: 2006-07-19 19:33:19 +02:00
115 admin: false
118 admin: false
116 mail: someone@foo.bar
119 mail: someone@foo.bar
@@ -1671,9 +1671,9 class IssuesControllerTest < ActionController::TestCase
1671 assert_error_tag :content => /No tracker/
1671 assert_error_tag :content => /No tracker/
1672 end
1672 end
1673
1673
1674 def test_update_new_form
1674 def test_update_form_for_new_issue
1675 @request.session[:user_id] = 2
1675 @request.session[:user_id] = 2
1676 xhr :post, :new, :project_id => 1,
1676 xhr :post, :update_form, :project_id => 1,
1677 :issue => {:tracker_id => 2,
1677 :issue => {:tracker_id => 2,
1678 :subject => 'This is the test_new issue',
1678 :subject => 'This is the test_new issue',
1679 :description => 'This is the description',
1679 :description => 'This is the description',
@@ -1690,14 +1690,14 class IssuesControllerTest < ActionController::TestCase
1690 assert_equal 'This is the test_new issue', issue.subject
1690 assert_equal 'This is the test_new issue', issue.subject
1691 end
1691 end
1692
1692
1693 def test_update_new_form_should_propose_transitions_based_on_initial_status
1693 def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status
1694 @request.session[:user_id] = 2
1694 @request.session[:user_id] = 2
1695 WorkflowTransition.delete_all
1695 WorkflowTransition.delete_all
1696 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
1696 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
1697 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
1697 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
1698 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1698 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1699
1699
1700 xhr :post, :new, :project_id => 1,
1700 xhr :post, :update_form, :project_id => 1,
1701 :issue => {:tracker_id => 1,
1701 :issue => {:tracker_id => 1,
1702 :status_id => 5,
1702 :status_id => 5,
1703 :subject => 'This is an issue'}
1703 :subject => 'This is an issue'}
@@ -2626,9 +2626,9 class IssuesControllerTest < ActionController::TestCase
2626 end
2626 end
2627 end
2627 end
2628
2628
2629 def test_update_edit_form
2629 def test_update_form_for_existing_issue
2630 @request.session[:user_id] = 2
2630 @request.session[:user_id] = 2
2631 xhr :put, :new, :project_id => 1,
2631 xhr :put, :update_form, :project_id => 1,
2632 :id => 1,
2632 :id => 1,
2633 :issue => {:tracker_id => 2,
2633 :issue => {:tracker_id => 2,
2634 :subject => 'This is the test_new issue',
2634 :subject => 'This is the test_new issue',
@@ -2647,9 +2647,9 class IssuesControllerTest < ActionController::TestCase
2647 assert_equal 'This is the test_new issue', issue.subject
2647 assert_equal 'This is the test_new issue', issue.subject
2648 end
2648 end
2649
2649
2650 def test_update_edit_form_should_keep_issue_author
2650 def test_update_form_for_existing_issue_should_keep_issue_author
2651 @request.session[:user_id] = 3
2651 @request.session[:user_id] = 3
2652 xhr :put, :new, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'}
2652 xhr :put, :update_form, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'}
2653 assert_response :success
2653 assert_response :success
2654 assert_equal 'text/javascript', response.content_type
2654 assert_equal 'text/javascript', response.content_type
2655
2655
@@ -2659,14 +2659,14 class IssuesControllerTest < ActionController::TestCase
2659 assert_not_equal User.current, issue.author
2659 assert_not_equal User.current, issue.author
2660 end
2660 end
2661
2661
2662 def test_update_edit_form_should_propose_transitions_based_on_initial_status
2662 def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status
2663 @request.session[:user_id] = 2
2663 @request.session[:user_id] = 2
2664 WorkflowTransition.delete_all
2664 WorkflowTransition.delete_all
2665 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
2665 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
2666 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
2666 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
2667 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
2667 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
2668
2668
2669 xhr :put, :new, :project_id => 1,
2669 xhr :put, :update_form, :project_id => 1,
2670 :id => 2,
2670 :id => 2,
2671 :issue => {:tracker_id => 2,
2671 :issue => {:tracker_id => 2,
2672 :status_id => 5,
2672 :status_id => 5,
@@ -2676,9 +2676,9 class IssuesControllerTest < ActionController::TestCase
2676 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
2676 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
2677 end
2677 end
2678
2678
2679 def test_update_edit_form_with_project_change
2679 def test_update_form_for_existing_issue_with_project_change
2680 @request.session[:user_id] = 2
2680 @request.session[:user_id] = 2
2681 xhr :put, :new, :project_id => 1,
2681 xhr :put, :update_form, :project_id => 1,
2682 :id => 1,
2682 :id => 1,
2683 :issue => {:project_id => 2,
2683 :issue => {:project_id => 2,
2684 :tracker_id => 2,
2684 :tracker_id => 2,
@@ -65,15 +65,6 class IssuesTest < ActionController::IntegrationTest
65 assert_equal 1, issue.status.id
65 assert_equal 1, issue.status.id
66 end
66 end
67
67
68 def test_update_issue_form
69 log_user('jsmith', 'jsmith')
70 post 'projects/ecookbook/issues/new', :issue => { :tracker_id => "2"}
71 assert_response :success
72 assert_tag 'select',
73 :attributes => {:name => 'issue[tracker_id]'},
74 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
75 end
76
77 # add then remove 2 attachments to an issue
68 # add then remove 2 attachments to an issue
78 def test_issue_attachments
69 def test_issue_attachments
79 log_user('jsmith', 'jsmith')
70 log_user('jsmith', 'jsmith')
@@ -107,8 +107,8 class RoutingIssuesTest < ActionController::IntegrationTest
107 def test_issues_form_update
107 def test_issues_form_update
108 ["post", "put"].each do |method|
108 ["post", "put"].each do |method|
109 assert_routing(
109 assert_routing(
110 { :method => method, :path => "/projects/23/issues/new" },
110 { :method => method, :path => "/projects/23/issues/update_form" },
111 { :controller => 'issues', :action => 'new', :project_id => '23' }
111 { :controller => 'issues', :action => 'update_form', :project_id => '23' }
112 )
112 )
113 end
113 end
114 end
114 end
@@ -56,6 +56,35 class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
56 assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
56 assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
57 end
57 end
58
58
59 def test_create_issue_with_form_update
60 field = IssueCustomField.create!(
61 :field_format => 'string',
62 :name => 'Form update CF',
63 :is_for_all => true,
64 :trackers => Tracker.find_all_by_name('Feature request')
65 )
66
67 Role.non_member.add_permission! :add_issues
68 Role.non_member.remove_permission! :edit_issues, :add_issue_notes
69
70 log_user('someone', 'foo')
71 visit '/projects/ecookbook/issues/new'
72 assert page.has_no_content?('Form update CF')
73
74 fill_in 'Subject', :with => 'new test issue'
75 # the custom field should show up when changing tracker
76 select 'Feature request', :from => 'Tracker'
77 assert page.has_content?('Form update CF')
78
79 fill_in 'Form update', :with => 'CF value'
80 assert_difference 'Issue.count' do
81 find('input[name=commit]').click
82 end
83
84 issue = Issue.order('id desc').first
85 assert_equal 'CF value', issue.custom_field_value(field)
86 end
87
59 def test_create_issue_with_watchers
88 def test_create_issue_with_watchers
60 User.generate!(:firstname => 'Some', :lastname => 'Watcher')
89 User.generate!(:firstname => 'Some', :lastname => 'Watcher')
61
90
@@ -98,6 +127,35 class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
98 assert_equal 'new issue description', issue.description
127 assert_equal 'new issue description', issue.description
99 end
128 end
100
129
130 def test_update_issue_with_form_update
131 field = IssueCustomField.create!(
132 :field_format => 'string',
133 :name => 'Form update CF',
134 :is_for_all => true,
135 :trackers => Tracker.find_all_by_name('Feature request')
136 )
137
138 Role.non_member.add_permission! :edit_issues
139 Role.non_member.remove_permission! :add_issues, :add_issue_notes
140
141 log_user('someone', 'foo')
142 visit '/issues/1'
143 assert page.has_no_content?('Form update CF')
144
145 page.first(:link, 'Update').click
146 # the custom field should show up when changing tracker
147 select 'Feature request', :from => 'Tracker'
148 assert page.has_content?('Form update CF')
149
150 fill_in 'Form update', :with => 'CF value'
151 assert_no_difference 'Issue.count' do
152 page.first(:button, 'Submit').click
153 end
154
155 issue = Issue.find(1)
156 assert_equal 'CF value', issue.custom_field_value(field)
157 end
158
101 def test_watch_issue_via_context_menu
159 def test_watch_issue_via_context_menu
102 log_user('jsmith', 'jsmith')
160 log_user('jsmith', 'jsmith')
103 visit '/issues'
161 visit '/issues'
General Comments 0
You need to be logged in to leave comments. Login now