Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Copy test cases to another project #226

Open
vegetadevelop opened this issue Jan 22, 2014 · 0 comments
Open

Bugfix: Copy test cases to another project #226

vegetadevelop opened this issue Jan 22, 2014 · 0 comments

Comments

@vegetadevelop
Copy link

"Copy" (to another project) button click have no effect.

My solution:
in app/views/impasse_test_case/index.html.erb file added this html form (id edit_copy_tests) called in assets/javascripts/test_case_tree.js on "button-copy-exec" click event handler:

<!-- C.V. BUGFIX <copy to another project a test case> button don't sent copy request and its data. Solution: added this html form called in assets/javascripts/test_case_tree.js -->
<form id="edit_copy_tests" class="tabular" action="<%=url_for :controller => :impasse_test_case, :action => :copy_to_another_project, :project_id => @project %>" method="post" enctype="multipart/form-data">
  <% if @allowed_projects.present? %>
<p><%=l(:notice_copy_cases_to_another_project)%></p>
<% if Rails::VERSION::MAJOR < 3 %>
      <% labelled_tabular_form_for :copy_tests, @project, { :action => :copy_to_another_project } do |f| %>
    <p>
      <label for="dest_project_id"><%= l(:field_project) %></label>
      <%= select_tag('dest_project_id', project_tree_options_for_select(@allowed_projects, :selected => @target_project)) %>
    </p>
  <% end %>
<% else %>
      <% output = labelled_tabular_form_for @project, :as => :copy_tests, :url => { :action => :copy_to_another_project } do |f| %>
    <p>
      <label for="dest_project_id"><%= l(:field_project) %></label>
      <%= select_tag('dest_project_id', project_tree_options_for_select(@allowed_projects, :selected => @target_project)) %>
    </p>
  <% end %>
      <%= output %>
    <% end %>
<p>
  <button id="button-copy-exec" type="button"><%= l(:button_copy)%></button>
  <button id="button-copy-cancel" type="button"><%= l(:button_cancel)%></button>
</p>
  <% else %>
<p class="nodata"><%=l(:notice_no_projects_to_copy_cases)%></p>
  <% end %>
</div>
<div class="floating" style="width : 100%;">
  <div id="requirements-view" style="width: 100%;"></div>
  <div id="test-case-view" style="width: 100%;"></div>
</div>
<!-- C.V. BUGFIX </copy to another project a test case>: form closed here -->
</form>

Note: I added only form tag


Next sub-issue:
only stepless test cases will copied. There is a problem with the copy of test case's steps.

My solution:
in app/controllers/impasse_test_case_controller.rb file, in "copy_to_another_project" function definition there is a misprint: "attr[:test_case_id] = new_test_case._id" the correct field is "id" not "_id". This is the code:

       case new_node.node_type_id
        when 2
          test_suite = Impasse::TestSuite.find(node.id)
          new_test_suite = test_suite.dup
          new_test_suite.id = new_node.id
          new_test_suite.save!
        when 3
          test_case = Impasse::TestCase.find(:first, :conditions => { :id => node.id }, :include => :test_steps)
          new_test_case = test_case.dup
          new_test_case.id = new_node.id
          new_test_case.save!
          test_case.test_steps.each do |ts|
            attr = ts.attributes
            #---------------------------------------------------------------------      
            # C.V. BUGFIX: <copy to another project a test case> copy correctly its steps
            #   attr[:test_case_id] = new_test_case._id --> attr[:test_case_id] = new_test_case.id
            #   correct field is "id" not "_id"
            #---------------------------------------------------------------------      
            attr[:test_case_id] = new_test_case.id
            #attr[:test_case_id] = new_test_case._id
            #</copy to another project a test case>
            #---------------------------------------------------------------------
            Impasse::TestStep.create!(attr)
          end

My SW versions:
Ruby 1.8.7
Rails 2.3.5 ( < 3 ) ---> WARNING: not tested with > 3
Redmine 1.4.7.stable.23 (MySQL)
Impasse 1.2.2


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant