##// END OF EJS Templates
Refactor: Start to extract IssuesController#edit into #update (REST)....
Eric Davis -
r3366:d581510af605
parent child
Show More
@@ -19,7 +19,7 class IssuesController < ApplicationController
19 19 menu_item :new_issue, :only => :new
20 20 default_search_scope :issues
21 21
22 before_filter :find_issue, :only => [:show, :edit, :reply]
22 before_filter :find_issue, :only => [:show, :edit, :update, :reply]
23 23 before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
24 24 before_filter :find_project, :only => [:new, :update_form, :preview]
25 25 before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu]
@@ -226,7 +226,7 class IssuesController < ApplicationController
226 226 end
227 227 # failure
228 228 respond_to do |format|
229 format.html { }
229 format.html { render :action => 'edit' }
230 230 format.xml { render :xml => @issue.errors, :status => :unprocessable_entity }
231 231 end
232 232 end
@@ -237,6 +237,13 class IssuesController < ApplicationController
237 237 attachments.each(&:destroy)
238 238 end
239 239
240 #--
241 # Start converting to the Rails REST controllers
242 #++
243 def update
244 edit
245 end
246
240 247 def reply
241 248 journal = Journal.find(params[:journal_id]) if params[:journal_id]
242 249 if journal
@@ -1,7 +1,8
1 1 <% labelled_tabular_form_for :issue, @issue,
2 :url => {:action => 'edit', :id => @issue},
2 :url => {:action => 'update', :id => @issue},
3 3 :html => {:id => 'issue-form',
4 4 :class => nil,
5 :method => :put,
5 6 :multipart => true} do |f| %>
6 7 <%= error_messages_for 'issue' %>
7 8 <%= error_messages_for 'time_entry' %>
@@ -52,9 +52,9 Redmine::AccessControl.map do |map|
52 52 :queries => :index,
53 53 :reports => [:issue_report, :issue_report_details]}
54 54 map.permission :add_issues, {:issues => [:new, :update_form]}
55 map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit, :update_form]}
55 map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]}
56 56 map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
57 map.permission :add_issue_notes, {:issues => [:edit, :reply]}
57 map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]}
58 58 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
59 59 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
60 60 map.permission :move_issues, {:issues => :move}, :require => :loggedin
@@ -657,7 +657,7 class IssuesControllerTest < ActionController::TestCase
657 657 assert_select_rjs :show, "update"
658 658 end
659 659
660 def test_post_edit_without_custom_fields_param
660 def test_put_update_without_custom_fields_param
661 661 @request.session[:user_id] = 2
662 662 ActionMailer::Base.deliveries.clear
663 663
@@ -668,7 +668,7 class IssuesControllerTest < ActionController::TestCase
668 668
669 669 assert_difference('Journal.count') do
670 670 assert_difference('JournalDetail.count', 2) do
671 post :edit, :id => 1, :issue => {:subject => new_subject,
671 put :update, :id => 1, :issue => {:subject => new_subject,
672 672 :priority_id => '6',
673 673 :category_id => '1' # no change
674 674 }
@@ -686,14 +686,14 class IssuesControllerTest < ActionController::TestCase
686 686 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
687 687 end
688 688
689 def test_post_edit_with_custom_field_change
689 def test_put_update_with_custom_field_change
690 690 @request.session[:user_id] = 2
691 691 issue = Issue.find(1)
692 692 assert_equal '125', issue.custom_value_for(2).value
693 693
694 694 assert_difference('Journal.count') do
695 695 assert_difference('JournalDetail.count', 3) do
696 post :edit, :id => 1, :issue => {:subject => 'Custom field change',
696 put :update, :id => 1, :issue => {:subject => 'Custom field change',
697 697 :priority_id => '6',
698 698 :category_id => '1', # no change
699 699 :custom_field_values => { '2' => 'New custom value' }
@@ -709,12 +709,12 class IssuesControllerTest < ActionController::TestCase
709 709 assert mail.body.include?("Searchable field changed from 125 to New custom value")
710 710 end
711 711
712 def test_post_edit_with_status_and_assignee_change
712 def test_put_update_with_status_and_assignee_change
713 713 issue = Issue.find(1)
714 714 assert_equal 1, issue.status_id
715 715 @request.session[:user_id] = 2
716 716 assert_difference('TimeEntry.count', 0) do
717 post :edit,
717 put :update,
718 718 :id => 1,
719 719 :issue => { :status_id => 2, :assigned_to_id => 3 },
720 720 :notes => 'Assigned to dlopper',
@@ -733,10 +733,10 class IssuesControllerTest < ActionController::TestCase
733 733 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
734 734 end
735 735
736 def test_post_edit_with_note_only
736 def test_put_update_with_note_only
737 737 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
738 738 # anonymous user
739 post :edit,
739 put :update,
740 740 :id => 1,
741 741 :notes => notes
742 742 assert_redirected_to :action => 'show', :id => '1'
@@ -749,11 +749,11 class IssuesControllerTest < ActionController::TestCase
749 749 assert mail.body.include?(notes)
750 750 end
751 751
752 def test_post_edit_with_note_and_spent_time
752 def test_put_update_with_note_and_spent_time
753 753 @request.session[:user_id] = 2
754 754 spent_hours_before = Issue.find(1).spent_hours
755 755 assert_difference('TimeEntry.count') do
756 post :edit,
756 put :update,
757 757 :id => 1,
758 758 :notes => '2.5 hours added',
759 759 :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first }
@@ -772,7 +772,7 class IssuesControllerTest < ActionController::TestCase
772 772 assert_equal spent_hours_before + 2.5, issue.spent_hours
773 773 end
774 774
775 def test_post_edit_with_attachment_only
775 def test_put_update_with_attachment_only
776 776 set_tmp_attachments_directory
777 777
778 778 # Delete all fixtured journals, a race condition can occur causing the wrong
@@ -780,7 +780,7 class IssuesControllerTest < ActionController::TestCase
780 780 Journal.delete_all
781 781
782 782 # anonymous user
783 post :edit,
783 put :update,
784 784 :id => 1,
785 785 :notes => '',
786 786 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
@@ -795,12 +795,12 class IssuesControllerTest < ActionController::TestCase
795 795 assert mail.body.include?('testfile.txt')
796 796 end
797 797
798 def test_post_edit_with_no_change
798 def test_put_update_with_no_change
799 799 issue = Issue.find(1)
800 800 issue.journals.clear
801 801 ActionMailer::Base.deliveries.clear
802 802
803 post :edit,
803 put :update,
804 804 :id => 1,
805 805 :notes => ''
806 806 assert_redirected_to :action => 'show', :id => '1'
@@ -811,26 +811,26 class IssuesControllerTest < ActionController::TestCase
811 811 assert ActionMailer::Base.deliveries.empty?
812 812 end
813 813
814 def test_post_edit_should_send_a_notification
814 def test_put_update_should_send_a_notification
815 815 @request.session[:user_id] = 2
816 816 ActionMailer::Base.deliveries.clear
817 817 issue = Issue.find(1)
818 818 old_subject = issue.subject
819 819 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
820 820
821 post :edit, :id => 1, :issue => {:subject => new_subject,
821 put :update, :id => 1, :issue => {:subject => new_subject,
822 822 :priority_id => '6',
823 823 :category_id => '1' # no change
824 824 }
825 825 assert_equal 1, ActionMailer::Base.deliveries.size
826 826 end
827 827
828 def test_post_edit_with_invalid_spent_time
828 def test_put_update_with_invalid_spent_time
829 829 @request.session[:user_id] = 2
830 830 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
831 831
832 832 assert_no_difference('Journal.count') do
833 post :edit,
833 put :update,
834 834 :id => 1,
835 835 :notes => notes,
836 836 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
@@ -843,11 +843,11 class IssuesControllerTest < ActionController::TestCase
843 843 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
844 844 end
845 845
846 def test_post_edit_should_allow_fixed_version_to_be_set_to_a_subproject
846 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
847 847 issue = Issue.find(2)
848 848 @request.session[:user_id] = 2
849 849
850 post :edit,
850 put :update,
851 851 :id => issue.id,
852 852 :issue => {
853 853 :fixed_version_id => 4
@@ -859,11 +859,11 class IssuesControllerTest < ActionController::TestCase
859 859 assert_not_equal issue.project_id, issue.fixed_version.project_id
860 860 end
861 861
862 def test_post_edit_should_redirect_back_using_the_back_url_parameter
862 def test_put_update_should_redirect_back_using_the_back_url_parameter
863 863 issue = Issue.find(2)
864 864 @request.session[:user_id] = 2
865 865
866 post :edit,
866 put :update,
867 867 :id => issue.id,
868 868 :issue => {
869 869 :fixed_version_id => 4
@@ -874,11 +874,11 class IssuesControllerTest < ActionController::TestCase
874 874 assert_redirected_to '/issues'
875 875 end
876 876
877 def test_post_edit_should_not_redirect_back_using_the_back_url_parameter_off_the_host
877 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
878 878 issue = Issue.find(2)
879 879 @request.session[:user_id] = 2
880 880
881 post :edit,
881 put :update,
882 882 :id => issue.id,
883 883 :issue => {
884 884 :fixed_version_id => 4
General Comments 0
You need to be logged in to leave comments. Login now