Fixed that updating the issue form was broken by r4011 when user is not allowed to add issues (#13188).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11405 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1cf09a2d31
commit
7799788b3d
|
@ -21,11 +21,11 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
before_filter :find_issue, :only => [:show, :edit, :update]
|
before_filter :find_issue, :only => [:show, :edit, :update]
|
||||||
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
before_filter :find_project, :only => [:new, :create]
|
before_filter :find_project, :only => [:new, :create, :update_form]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
||||||
before_filter :build_new_issue_from_params, :only => [:new, :create]
|
before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
|
||||||
accept_rss_auth :index, :show
|
accept_rss_auth :index, :show
|
||||||
accept_api_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
|
@ -132,7 +132,6 @@ class IssuesController < ApplicationController
|
||||||
def new
|
def new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new', :layout => !request.xhr? }
|
format.html { render :action => 'new', :layout => !request.xhr? }
|
||||||
format.js { render :partial => 'update_form' }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -202,6 +201,11 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Updates the issue form when changing the project, status or tracker
|
||||||
|
# on issue creation/update
|
||||||
|
def update_form
|
||||||
|
end
|
||||||
|
|
||||||
# Bulk edit/copy a set of issues
|
# Bulk edit/copy a set of issues
|
||||||
def bulk_edit
|
def bulk_edit
|
||||||
@issues.sort!
|
@issues.sort!
|
||||||
|
|
|
@ -116,7 +116,7 @@ RedmineApp::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# issue form update
|
# issue form update
|
||||||
match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form'
|
match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form'
|
||||||
|
|
||||||
resources :files, :only => [:index, :new, :create]
|
resources :files, :only => [:index, :new, :create]
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ Redmine::AccessControl.map do |map|
|
||||||
map.permission :manage_subtasks, {}
|
map.permission :manage_subtasks, {}
|
||||||
map.permission :set_issues_private, {}
|
map.permission :set_issues_private, {}
|
||||||
map.permission :set_own_issues_private, {}, :require => :loggedin
|
map.permission :set_own_issues_private, {}, :require => :loggedin
|
||||||
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload}
|
map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
|
||||||
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
|
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
|
||||||
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
|
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
|
||||||
map.permission :view_private_notes, {}, :read => true, :require => :member
|
map.permission :view_private_notes, {}, :read => true, :require => :member
|
||||||
|
|
|
@ -105,12 +105,15 @@ users_006:
|
||||||
login: ''
|
login: ''
|
||||||
type: AnonymousUser
|
type: AnonymousUser
|
||||||
users_007:
|
users_007:
|
||||||
|
# A user who does not belong to any project
|
||||||
id: 7
|
id: 7
|
||||||
created_on: 2006-07-19 19:33:19 +02:00
|
created_on: 2006-07-19 19:33:19 +02:00
|
||||||
status: 1
|
status: 1
|
||||||
last_login_on:
|
last_login_on:
|
||||||
language: ''
|
language: 'en'
|
||||||
hashed_password: 1
|
# password = foo
|
||||||
|
salt: 7599f9963ec07b5a3b55b354407120c0
|
||||||
|
hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
|
||||||
updated_on: 2006-07-19 19:33:19 +02:00
|
updated_on: 2006-07-19 19:33:19 +02:00
|
||||||
admin: false
|
admin: false
|
||||||
mail: someone@foo.bar
|
mail: someone@foo.bar
|
||||||
|
|
|
@ -1671,9 +1671,9 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_error_tag :content => /No tracker/
|
assert_error_tag :content => /No tracker/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_new_form
|
def test_update_form_for_new_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :new, :project_id => 1,
|
xhr :post, :update_form, :project_id => 1,
|
||||||
:issue => {:tracker_id => 2,
|
:issue => {:tracker_id => 2,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
:description => 'This is the description',
|
:description => 'This is the description',
|
||||||
|
@ -1690,14 +1690,14 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_equal 'This is the test_new issue', issue.subject
|
assert_equal 'This is the test_new issue', issue.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_new_form_should_propose_transitions_based_on_initial_status
|
def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
WorkflowTransition.delete_all
|
WorkflowTransition.delete_all
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
|
||||||
|
|
||||||
xhr :post, :new, :project_id => 1,
|
xhr :post, :update_form, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:status_id => 5,
|
:status_id => 5,
|
||||||
:subject => 'This is an issue'}
|
:subject => 'This is an issue'}
|
||||||
|
@ -2626,9 +2626,9 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_edit_form
|
def test_update_form_for_existing_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :put, :new, :project_id => 1,
|
xhr :put, :update_form, :project_id => 1,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:issue => {:tracker_id => 2,
|
:issue => {:tracker_id => 2,
|
||||||
:subject => 'This is the test_new issue',
|
:subject => 'This is the test_new issue',
|
||||||
|
@ -2647,9 +2647,9 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_equal 'This is the test_new issue', issue.subject
|
assert_equal 'This is the test_new issue', issue.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_edit_form_should_keep_issue_author
|
def test_update_form_for_existing_issue_should_keep_issue_author
|
||||||
@request.session[:user_id] = 3
|
@request.session[:user_id] = 3
|
||||||
xhr :put, :new, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'}
|
xhr :put, :update_form, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
|
|
||||||
|
@ -2659,14 +2659,14 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_not_equal User.current, issue.author
|
assert_not_equal User.current, issue.author
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_edit_form_should_propose_transitions_based_on_initial_status
|
def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
WorkflowTransition.delete_all
|
WorkflowTransition.delete_all
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
|
||||||
|
|
||||||
xhr :put, :new, :project_id => 1,
|
xhr :put, :update_form, :project_id => 1,
|
||||||
:id => 2,
|
:id => 2,
|
||||||
:issue => {:tracker_id => 2,
|
:issue => {:tracker_id => 2,
|
||||||
:status_id => 5,
|
:status_id => 5,
|
||||||
|
@ -2676,9 +2676,9 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
|
assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_edit_form_with_project_change
|
def test_update_form_for_existing_issue_with_project_change
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :put, :new, :project_id => 1,
|
xhr :put, :update_form, :project_id => 1,
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:issue => {:project_id => 2,
|
:issue => {:project_id => 2,
|
||||||
:tracker_id => 2,
|
:tracker_id => 2,
|
||||||
|
|
|
@ -65,15 +65,6 @@ class IssuesTest < ActionController::IntegrationTest
|
||||||
assert_equal 1, issue.status.id
|
assert_equal 1, issue.status.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_issue_form
|
|
||||||
log_user('jsmith', 'jsmith')
|
|
||||||
post 'projects/ecookbook/issues/new', :issue => { :tracker_id => "2"}
|
|
||||||
assert_response :success
|
|
||||||
assert_tag 'select',
|
|
||||||
:attributes => {:name => 'issue[tracker_id]'},
|
|
||||||
:child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
|
|
||||||
end
|
|
||||||
|
|
||||||
# add then remove 2 attachments to an issue
|
# add then remove 2 attachments to an issue
|
||||||
def test_issue_attachments
|
def test_issue_attachments
|
||||||
log_user('jsmith', 'jsmith')
|
log_user('jsmith', 'jsmith')
|
||||||
|
|
|
@ -107,8 +107,8 @@ class RoutingIssuesTest < ActionController::IntegrationTest
|
||||||
def test_issues_form_update
|
def test_issues_form_update
|
||||||
["post", "put"].each do |method|
|
["post", "put"].each do |method|
|
||||||
assert_routing(
|
assert_routing(
|
||||||
{ :method => method, :path => "/projects/23/issues/new" },
|
{ :method => method, :path => "/projects/23/issues/update_form" },
|
||||||
{ :controller => 'issues', :action => 'new', :project_id => '23' }
|
{ :controller => 'issues', :action => 'update_form', :project_id => '23' }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,6 +56,35 @@ class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
|
||||||
assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
|
assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_issue_with_form_update
|
||||||
|
field = IssueCustomField.create!(
|
||||||
|
:field_format => 'string',
|
||||||
|
:name => 'Form update CF',
|
||||||
|
:is_for_all => true,
|
||||||
|
:trackers => Tracker.find_all_by_name('Feature request')
|
||||||
|
)
|
||||||
|
|
||||||
|
Role.non_member.add_permission! :add_issues
|
||||||
|
Role.non_member.remove_permission! :edit_issues, :add_issue_notes
|
||||||
|
|
||||||
|
log_user('someone', 'foo')
|
||||||
|
visit '/projects/ecookbook/issues/new'
|
||||||
|
assert page.has_no_content?('Form update CF')
|
||||||
|
|
||||||
|
fill_in 'Subject', :with => 'new test issue'
|
||||||
|
# the custom field should show up when changing tracker
|
||||||
|
select 'Feature request', :from => 'Tracker'
|
||||||
|
assert page.has_content?('Form update CF')
|
||||||
|
|
||||||
|
fill_in 'Form update', :with => 'CF value'
|
||||||
|
assert_difference 'Issue.count' do
|
||||||
|
find('input[name=commit]').click
|
||||||
|
end
|
||||||
|
|
||||||
|
issue = Issue.order('id desc').first
|
||||||
|
assert_equal 'CF value', issue.custom_field_value(field)
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_issue_with_watchers
|
def test_create_issue_with_watchers
|
||||||
User.generate!(:firstname => 'Some', :lastname => 'Watcher')
|
User.generate!(:firstname => 'Some', :lastname => 'Watcher')
|
||||||
|
|
||||||
|
@ -98,6 +127,35 @@ class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
|
||||||
assert_equal 'new issue description', issue.description
|
assert_equal 'new issue description', issue.description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_update_issue_with_form_update
|
||||||
|
field = IssueCustomField.create!(
|
||||||
|
:field_format => 'string',
|
||||||
|
:name => 'Form update CF',
|
||||||
|
:is_for_all => true,
|
||||||
|
:trackers => Tracker.find_all_by_name('Feature request')
|
||||||
|
)
|
||||||
|
|
||||||
|
Role.non_member.add_permission! :edit_issues
|
||||||
|
Role.non_member.remove_permission! :add_issues, :add_issue_notes
|
||||||
|
|
||||||
|
log_user('someone', 'foo')
|
||||||
|
visit '/issues/1'
|
||||||
|
assert page.has_no_content?('Form update CF')
|
||||||
|
|
||||||
|
page.first(:link, 'Update').click
|
||||||
|
# the custom field should show up when changing tracker
|
||||||
|
select 'Feature request', :from => 'Tracker'
|
||||||
|
assert page.has_content?('Form update CF')
|
||||||
|
|
||||||
|
fill_in 'Form update', :with => 'CF value'
|
||||||
|
assert_no_difference 'Issue.count' do
|
||||||
|
page.first(:button, 'Submit').click
|
||||||
|
end
|
||||||
|
|
||||||
|
issue = Issue.find(1)
|
||||||
|
assert_equal 'CF value', issue.custom_field_value(field)
|
||||||
|
end
|
||||||
|
|
||||||
def test_watch_issue_via_context_menu
|
def test_watch_issue_via_context_menu
|
||||||
log_user('jsmith', 'jsmith')
|
log_user('jsmith', 'jsmith')
|
||||||
visit '/issues'
|
visit '/issues'
|
||||||
|
|
Loading…
Reference in New Issue