kawasima / redmine_impasse

The redmine plugin for test management.
http://kawasima.github.com/redmine_impasse/
91 stars 99 forks source link

Bugfix: impasse creating/editing unsorted test cases #221

Open vegetadevelop opened 11 years ago

vegetadevelop commented 11 years ago

During test case creation/editing from 6th step the order of these ones will lost (in editing and view mode, after saved also). This is my solution implemented in: vendor/plugins/redmine_impasse/app/controllers/impasse_test_case_controller.rb

in new/edit funtion:


      if @node.is_test_case? and params.include? :test_steps
        #---------------------------------------------------------------------      
        # BUGFIX: <sorting test steps> sort test steps list correctly
        #   params[:test_steps] --> tmp_params (hash with key corresponding to the step number) --> tmp (sorted array)
        #---------------------------------------------------------------------      
        tmp_params = Hash.new
        params[:test_steps].each do |k,v|
            k = "#{v['step_number']}"
            tmp_params[("#{k}").to_i] = v
        end
        tmp = tmp_params.sort
        tmp_params.clear
        @test_steps = tmp.collect{|i, ts| Impasse::TestStep.new(ts) }
        @test_steps.each{|ts| raise ActiveRecord::RecordInvalid.new(ts) unless ts.valid? }
        @test_case.test_steps.replace(@test_steps)
        tmp.clear
        #</sorting test steps>
        #---------------------------------------------------------------------
      end

Platform: redmine 1.4.7, ruby 1.8.7, rails 2.3.5, impasse 1.2.2