@@ -21,11 +21,11 class IssuesController < ApplicationController | |||
|
21 | 21 | |
|
22 | 22 | before_filter :find_issue, :only => [:show, :edit, :update] |
|
23 | 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 | 25 | before_filter :authorize, :except => [:index] |
|
26 | 26 | before_filter :find_optional_project, :only => [:index] |
|
27 | 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 | 29 | accept_rss_auth :index, :show |
|
30 | 30 | accept_api_auth :index, :show, :create, :update, :destroy |
|
31 | 31 | |
@@ -132,7 +132,6 class IssuesController < ApplicationController | |||
|
132 | 132 | def new |
|
133 | 133 | respond_to do |format| |
|
134 | 134 | format.html { render :action => 'new', :layout => !request.xhr? } |
|
135 | format.js { render :partial => 'update_form' } | |
|
136 | 135 | end |
|
137 | 136 | end |
|
138 | 137 | |
@@ -202,6 +201,11 class IssuesController < ApplicationController | |||
|
202 | 201 | end |
|
203 | 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 | 209 | # Bulk edit/copy a set of issues |
|
206 | 210 | def bulk_edit |
|
207 | 211 | @issues.sort! |
|
1 | 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 | 116 | end |
|
117 | 117 | end |
|
118 | 118 | # issue form update |
|
119 |
match 'issues/ |
|
|
119 | match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' | |
|
120 | 120 | |
|
121 | 121 | resources :files, :only => [:index, :new, :create] |
|
122 | 122 |
@@ -115,7 +115,7 Redmine::AccessControl.map do |map| | |||
|
115 | 115 | map.permission :manage_subtasks, {} |
|
116 | 116 | map.permission :set_issues_private, {} |
|
117 | 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 | 119 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
120 | 120 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
121 | 121 | map.permission :view_private_notes, {}, :read => true, :require => :member |
@@ -105,12 +105,15 users_006: | |||
|
105 | 105 | login: '' |
|
106 | 106 | type: AnonymousUser |
|
107 | 107 | users_007: |
|
108 | # A user who does not belong to any project | |
|
108 | 109 | id: 7 |
|
109 | 110 | created_on: 2006-07-19 19:33:19 +02:00 |
|
110 | 111 | status: 1 |
|
111 | 112 | last_login_on: |
|
112 | language: '' | |
|
113 | hashed_password: 1 | |
|
113 | language: 'en' | |
|
114 | # password = foo | |
|
115 | salt: 7599f9963ec07b5a3b55b354407120c0 | |
|
116 | hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed | |
|
114 | 117 | updated_on: 2006-07-19 19:33:19 +02:00 |
|
115 | 118 | admin: false |
|
116 | 119 | mail: someone@foo.bar |
@@ -1671,9 +1671,9 class IssuesControllerTest < ActionController::TestCase | |||
|
1671 | 1671 | assert_error_tag :content => /No tracker/ |
|
1672 | 1672 | end |
|
1673 | 1673 | |
|
1674 |
def test_update_ |
|
|
1674 | def test_update_form_for_new_issue | |
|
1675 | 1675 | @request.session[:user_id] = 2 |
|
1676 |
xhr :post, : |
|
|
1676 | xhr :post, :update_form, :project_id => 1, | |
|
1677 | 1677 | :issue => {:tracker_id => 2, |
|
1678 | 1678 | :subject => 'This is the test_new issue', |
|
1679 | 1679 | :description => 'This is the description', |
@@ -1690,14 +1690,14 class IssuesControllerTest < ActionController::TestCase | |||
|
1690 | 1690 | assert_equal 'This is the test_new issue', issue.subject |
|
1691 | 1691 | end |
|
1692 | 1692 | |
|
1693 |
def test_update_ |
|
|
1693 | def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status | |
|
1694 | 1694 | @request.session[:user_id] = 2 |
|
1695 | 1695 | WorkflowTransition.delete_all |
|
1696 | 1696 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2) |
|
1697 | 1697 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5) |
|
1698 | 1698 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4) |
|
1699 | 1699 | |
|
1700 |
xhr :post, : |
|
|
1700 | xhr :post, :update_form, :project_id => 1, | |
|
1701 | 1701 | :issue => {:tracker_id => 1, |
|
1702 | 1702 | :status_id => 5, |
|
1703 | 1703 | :subject => 'This is an issue'} |
@@ -2626,9 +2626,9 class IssuesControllerTest < ActionController::TestCase | |||
|
2626 | 2626 | end |
|
2627 | 2627 | end |
|
2628 | 2628 | |
|
2629 |
def test_update_ |
|
|
2629 | def test_update_form_for_existing_issue | |
|
2630 | 2630 | @request.session[:user_id] = 2 |
|
2631 |
xhr :put, : |
|
|
2631 | xhr :put, :update_form, :project_id => 1, | |
|
2632 | 2632 | :id => 1, |
|
2633 | 2633 | :issue => {:tracker_id => 2, |
|
2634 | 2634 | :subject => 'This is the test_new issue', |
@@ -2647,9 +2647,9 class IssuesControllerTest < ActionController::TestCase | |||
|
2647 | 2647 | assert_equal 'This is the test_new issue', issue.subject |
|
2648 | 2648 | end |
|
2649 | 2649 | |
|
2650 |
def test_update_ |
|
|
2650 | def test_update_form_for_existing_issue_should_keep_issue_author | |
|
2651 | 2651 | @request.session[:user_id] = 3 |
|
2652 |
xhr :put, : |
|
|
2652 | xhr :put, :update_form, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'} | |
|
2653 | 2653 | assert_response :success |
|
2654 | 2654 | assert_equal 'text/javascript', response.content_type |
|
2655 | 2655 | |
@@ -2659,14 +2659,14 class IssuesControllerTest < ActionController::TestCase | |||
|
2659 | 2659 | assert_not_equal User.current, issue.author |
|
2660 | 2660 | end |
|
2661 | 2661 | |
|
2662 |
def test_update_ |
|
|
2662 | def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status | |
|
2663 | 2663 | @request.session[:user_id] = 2 |
|
2664 | 2664 | WorkflowTransition.delete_all |
|
2665 | 2665 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1) |
|
2666 | 2666 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5) |
|
2667 | 2667 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4) |
|
2668 | 2668 | |
|
2669 |
xhr :put, : |
|
|
2669 | xhr :put, :update_form, :project_id => 1, | |
|
2670 | 2670 | :id => 2, |
|
2671 | 2671 | :issue => {:tracker_id => 2, |
|
2672 | 2672 | :status_id => 5, |
@@ -2676,9 +2676,9 class IssuesControllerTest < ActionController::TestCase | |||
|
2676 | 2676 | assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort |
|
2677 | 2677 | end |
|
2678 | 2678 | |
|
2679 |
def test_update_ |
|
|
2679 | def test_update_form_for_existing_issue_with_project_change | |
|
2680 | 2680 | @request.session[:user_id] = 2 |
|
2681 |
xhr :put, : |
|
|
2681 | xhr :put, :update_form, :project_id => 1, | |
|
2682 | 2682 | :id => 1, |
|
2683 | 2683 | :issue => {:project_id => 2, |
|
2684 | 2684 | :tracker_id => 2, |
@@ -65,15 +65,6 class IssuesTest < ActionController::IntegrationTest | |||
|
65 | 65 | assert_equal 1, issue.status.id |
|
66 | 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 | 68 | # add then remove 2 attachments to an issue |
|
78 | 69 | def test_issue_attachments |
|
79 | 70 | log_user('jsmith', 'jsmith') |
@@ -107,8 +107,8 class RoutingIssuesTest < ActionController::IntegrationTest | |||
|
107 | 107 | def test_issues_form_update |
|
108 | 108 | ["post", "put"].each do |method| |
|
109 | 109 | assert_routing( |
|
110 |
{ :method => method, :path => "/projects/23/issues/ |
|
|
111 |
{ :controller => 'issues', :action => ' |
|
|
110 | { :method => method, :path => "/projects/23/issues/update_form" }, | |
|
111 | { :controller => 'issues', :action => 'update_form', :project_id => '23' } | |
|
112 | 112 | ) |
|
113 | 113 | end |
|
114 | 114 | end |
@@ -56,6 +56,35 class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base | |||
|
56 | 56 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) |
|
57 | 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 | 88 | def test_create_issue_with_watchers |
|
60 | 89 | User.generate!(:firstname => 'Some', :lastname => 'Watcher') |
|
61 | 90 | |
@@ -98,6 +127,35 class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base | |||
|
98 | 127 | assert_equal 'new issue description', issue.description |
|
99 | 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 | 159 | def test_watch_issue_via_context_menu |
|
102 | 160 | log_user('jsmith', 'jsmith') |
|
103 | 161 | visit '/issues' |
General Comments 0
You need to be logged in to leave comments.
Login now