From 7325b1e39aa7d218e08355b3cd1ea73647a7358e Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Mon, 29 Jun 2015 15:28:56 +0000 Subject: [PATCH] Do not try test_project node into the #test-case-view div. Fixes ActiveRecord::RecordNotFound Couldn't find Impasse::TestSuite error. refs #9 --- app/controllers/impasse_test_case_controller.rb | 5 ++++- assets/javascripts/test_case_tree.js | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/impasse_test_case_controller.rb b/app/controllers/impasse_test_case_controller.rb index d8093d0..0fedaef 100644 --- a/app/controllers/impasse_test_case_controller.rb +++ b/app/controllers/impasse_test_case_controller.rb @@ -319,8 +319,11 @@ def get_node(node_params) if node.is_test_case? test_case = Impasse::TestCase.find(node_params[:id]) - else + elsif node.is_test_suite? test_case = Impasse::TestSuite.find(node_params[:id]) + else + # test_project does not have a dedicated model + test_case = nil end [node, test_case] diff --git a/assets/javascripts/test_case_tree.js b/assets/javascripts/test_case_tree.js index 93f9686..a7798f0 100644 --- a/assets/javascripts/test_case_tree.js +++ b/assets/javascripts/test_case_tree.js @@ -421,9 +421,17 @@ jQuery(document).ready(function ($) { }) .bind("select_node.jstree", function(e, data) { $("#test-case-view").block(impasse_loading_options()); - var node_id = data.rslt.obj.attr("id").replace("node_", ""); - location.replace("#testcase-" + node_id); - show_test_case(node_id); + var node = data.rslt.obj; + var node_id = node.attr("id").replace("node_", ""); + // test_project has nothing to show in the test case view + if (node.attr('rel') == 'test_project') { + location.replace("#"); + $("#test-case-view").html(""); + } + else { + location.replace("#testcase-" + node_id); + show_test_case(node_id); + } }); $("#testcase-dialog .add-test-step").live("click", function() {