Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions app/controllers/impasse_test_case_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,23 @@ def new
save_keywords(@node, params[:node_keywords])
@test_case.id = @node.id
if @node.is_test_case? and params.include? :test_steps
@test_steps = params[:test_steps].collect{|i, ts| Impasse::TestStep.new(ts) }
#---------------------------------------------------------------------
# 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
@test_case.save!
render :json => { :status => 'success', :message => l(:notice_successful_create), :ids => [@test_case.id] }
Expand Down Expand Up @@ -115,9 +129,23 @@ def edit
save_keywords(@node, params[:node_keywords])

if @node.is_test_case? and params.include? :test_steps
@test_steps = params[:test_steps].collect{|i, ts| Impasse::TestStep.new(ts) }
#---------------------------------------------------------------------
# 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

if params[:attachments]
Expand Down