diff --git a/README.rdoc b/README.rdoc index 8634ab7..8a2b42c 100755 --- a/README.rdoc +++ b/README.rdoc @@ -1,4 +1,4 @@ -= impasse - -Impasse is test management tool like Testlink. - += impasse + +Impasse is test management tool like Testlink + diff --git a/app/controllers/impasse_abstract_controller.rb b/app/controllers/impasse_abstract_controller.rb index e451205..b097b71 100644 --- a/app/controllers/impasse_abstract_controller.rb +++ b/app/controllers/impasse_abstract_controller.rb @@ -3,10 +3,11 @@ class ImpasseAbstractController < ApplicationController def require_login if !User.current.logged? # Extract only the basic url parameters on non-GET requests + local_params = params.permit!.to_h if request.get? - url = url_for(params) + url = url_for(local_params) else - url = url_for(:controller => "/params[:controller]", :action => params[:action], :id => params[:id], :project_id => params[:project_id]) + url = url_for(:controller => "/params[:controller]", :action => local_params[:action], :id => local_params[:id], :project_id => local_params[:project_id]) end respond_to do |format| diff --git a/app/controllers/impasse_custom_fields_controller.rb b/app/controllers/impasse_custom_fields_controller.rb index 9668fb8..eff9ccf 100644 --- a/app/controllers/impasse_custom_fields_controller.rb +++ b/app/controllers/impasse_custom_fields_controller.rb @@ -4,10 +4,10 @@ class ImpasseCustomFieldsController < ImpasseAbstractController helper CustomFieldsHelper helper ImpasseSettingsHelper - before_filter :require_admin + before_action :require_admin def index - @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } + @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name } @tab = params[:tab] || 'Impasse::TestCaseCustomField' end @@ -19,23 +19,23 @@ def new rescue end (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField) - if request.post? and @custom_field.save + if (request.post? or request.patch?) and @custom_field.save flash[:notice] = l(:notice_successful_create) call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field) redirect_to :action => 'index', :tab => @custom_field.class.name else - @trackers = Tracker.find(:all, :order => 'position') + @trackers = Tracker.all.order(:position) end end def edit @custom_field = CustomField.find(params[:id]) - if (request.post? || request.put?) and @custom_field.update_attributes(params[:custom_field]) + if (request.post? || request.put? or request.patch?) and @custom_field.update_attributes(params[:custom_field]) flash[:notice] = l(:notice_successful_update) call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field) redirect_to :action => 'index', :tab => @custom_field.class.name else - @trackers = Tracker.find(:all, :order => 'position') + @trackers = Tracker.all.order(:position) end end diff --git a/app/controllers/impasse_execution_bugs_controller.rb b/app/controllers/impasse_execution_bugs_controller.rb index 045e626..ca81d2d 100644 --- a/app/controllers/impasse_execution_bugs_controller.rb +++ b/app/controllers/impasse_execution_bugs_controller.rb @@ -2,9 +2,8 @@ class ImpasseExecutionBugsController < ImpasseAbstractController unloadable menu_item :impasse - before_filter :find_project_by_project_id, :only => [:new, :create] - before_filter :check_for_default_issue_status, :only => [:new, :create] - before_filter :build_new_issue_from_params, :only => [:new, :create] + before_action :find_project_by_project_id, :only => [:new, :create] + before_action :build_new_issue_from_params, :only => [:new, :create] helper :journals helper :projects @@ -23,10 +22,11 @@ class ImpasseExecutionBugsController < ImpasseAbstractController include RepositoriesHelper helper :sort include SortHelper + helper :issues include IssuesHelper def new - setting = Impasse::Setting.find_or_create_by_project_id(@project) + setting = Impasse::Setting.find_or_initialize_by(:project_id => @project) @issue.tracker_id = setting.bug_tracker_id unless setting.bug_tracker_id.nil? respond_to do |format| @@ -36,9 +36,10 @@ def new end def create - call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) + execution_params = params.permit!.to_h + call_hook(:controller_issues_new_before_save, { :params => execution_params, :issue => @issue }) if @issue.save - execution_bug = Impasse::ExecutionBug.new(:execution_id => params[:execution_bug][:execution_id], :bug_id => @issue.id) + execution_bug = Impasse::ExecutionBug.new(:execution_id => execution_params[:execution_bug][:execution_id], :bug_id => @issue.id) execution_bug.save! flash[:notice] = l(:notice_successful_create) @@ -53,8 +54,9 @@ def create end def upload_attachments - issue = Issue.find(params[:issue_id]) - attachments = Attachment.attach_files(issue, params[:attachments]) + execution_params = params.permit!.to_h + issue = Issue.find(execution_params[:issue_id]) + attachments = Attachment.attach_files(issue, execution_params[:attachments]) respond_to do |format| format.html { render :text => 'ok' } @@ -62,22 +64,28 @@ def upload_attachments end def build_new_issue_from_params - if params[:id].blank? + issue_params = params.permit!.to_h + + if issue_params[:id].blank? @issue = Issue.new - @issue.copy_from(params[:copy_from]) if params[:copy_from] + @issue.copy_from(issue_params[:copy_from]) if issue_params[:copy_from] @issue.project = @project else - @issue = @project.issues.visible.find(params[:id]) + @issue = @project.issues.visible.find(issue_params[:id]) end @issue.project = @project # Tracker must be set before custom field values - @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) + if (issue_params[:issue] && issue_params[:issue][:tracker_id]) || issue_params[:tracker_id] + @issue.tracker ||= @project.trackers.find((issue_params[:issue] && issue_params[:issue][:tracker_id]) || issue_params[:tracker_id]) + else + @issue.tracker ||= @project.trackers.first + end if @issue.tracker.nil? render_error l(:error_no_tracker_in_project) return false end - if params[:issue].is_a?(Hash) - @issue.safe_attributes = params[:issue] + if issue_params[:issue].is_a?(Hash) + @issue.safe_attributes = issue_params[:issue] end @issue.start_date ||= Date.today @issue.author = User.current @@ -86,10 +94,4 @@ def build_new_issue_from_params @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq end - def check_for_default_issue_status - if IssueStatus.default.nil? - render_error l(:error_no_default_issue_status) - return false - end - end end diff --git a/app/controllers/impasse_executions_controller.rb b/app/controllers/impasse_executions_controller.rb index ce695d4..07b0cee 100755 --- a/app/controllers/impasse_executions_controller.rb +++ b/app/controllers/impasse_executions_controller.rb @@ -9,7 +9,7 @@ class ImpasseExecutionsController < ImpasseAbstractController include CustomFieldsHelper menu_item :impasse - before_filter :find_project_by_project_id, :authorize + before_action :find_project_by_project_id, :authorize include ActionView::Helpers::AssetTagHelper @@ -19,23 +19,22 @@ def index end def put - @node = Impasse::Node.find(params[:test_plan_case][:test_case_id]) + execution_params = params.permit!.to_h + @node = Impasse::Node.find(execution_params[:test_plan_case][:test_case_id]) test_case_ids = (@node.is_test_case?) ? [ @node.id ] : @node.all_decendant_cases.collect{|tc| tc.id} - if params[:execution] and params[:execution][:expected_date] - params[:execution][:expected_date] = Time.at(params[:execution][:expected_date].to_i) + if execution_params[:execution] and execution_params[:execution][:expected_date] + execution_params[:execution][:expected_date] = Time.at(execution_params[:execution][:expected_date].to_i) end status = 'success' errors = [] for test_case_id in test_case_ids - test_plan_case = Impasse::TestPlanCase.find(:first, :conditions=>[ - "test_plan_id=? AND test_case_id=?", - params[:test_plan_case][:test_plan_id], - test_case_id]) - next if test_plan_case.nil? - execution = Impasse::Execution.find_or_initialize_by_test_plan_case_id(test_plan_case.id) - execution.attributes = params[:execution] - if params[:record] + test_plan_case = Impasse::TestPlanCase.where( + test_plan_id: execution_params[:test_plan_case][:test_plan_id], test_case_id: test_case_id).first + next unless test_plan_case + execution = Impasse::Execution.where(test_plan_case_id: test_plan_case.id).first_or_initialize + execution.update_attributes(execution_params[:execution]) + if execution_params[:record] execution.execution_ts = Time.now.to_datetime execution.executor_id = User.current.id end @@ -43,7 +42,7 @@ def put begin ActiveRecord::Base.transaction do execution.save! - if params[:record] + if execution_params[:record] @execution_history = Impasse::ExecutionHistory.new(execution.attributes) @execution_history.save! end @@ -66,10 +65,10 @@ def destroy status = true for test_case_id in test_case_ids - test_plan_case = Impasse::TestPlanCase.find(:first, :conditions=>[ - "test_plan_id=? AND test_case_id=?", params[:test_plan_case][:test_plan_id], test_case_id]) + test_plan_case = Impasse::TestPlanCase.where( + "test_plan_id=? AND test_case_id=?", params[:test_plan_case][:test_plan_id], test_case_id).first next if test_plan_case.nil? - execution = Impasse::Execution.find_by_test_plan_case_id(test_plan_case.id) + execution = Impasse::Execution.find_by(:test_plan_case_id => test_plan_case.id) next if execution.nil? execution.tester_id = execution.expected_date = nil satus &= execution.save @@ -98,16 +97,14 @@ def edit executions = Impasse::Execution.find_by_sql [sql, params[:test_plan_case][:test_plan_id], params[:test_plan_case][:test_case_id]] if executions.size == 0 @execution = Impasse::Execution.new - @execution.test_plan_case = Impasse::TestPlanCase.find_by_test_plan_id_and_test_case_id( - params[:test_plan_case][:test_plan_id], params[:test_plan_case][:test_case_id]) + @execution.test_plan_case = Impasse::TestPlanCase.find_by( + :test_plan_id => params[:test_plan_case][:test_plan_id], :test_case_id => params[:test_plan_case][:test_case_id]) else @execution = executions.first end - @execution.attributes = params[:execution] - @execution_histories = Impasse::ExecutionHistory.find(:all, :joins => [ :executor ], - :conditions => ["test_plan_case_id=?", @execution.test_plan_case_id], - :order => "execution_ts DESC") - if request.post? and @execution.save + @execution.update_attributes(params[:execution]) if params[:execution].present? + @execution_histories = Impasse::ExecutionHistory.where(:test_plan_case_id => @execution.test_plan_case_id).joins(:executor).order("execution_ts DESC") + if (request.post? or request.patch?) and @execution.save render :json => {'status'=>true} else render :partial=>'edit' diff --git a/app/controllers/impasse_requirement_issues_controller.rb b/app/controllers/impasse_requirement_issues_controller.rb index 9979157..afd0bd2 100644 --- a/app/controllers/impasse_requirement_issues_controller.rb +++ b/app/controllers/impasse_requirement_issues_controller.rb @@ -9,7 +9,7 @@ class ImpasseRequirementIssuesController < ImpasseAbstractController def index @project = Project.find(params[:project_id]) - setting = Impasse::Setting.find_by_project_id(@project.id) + setting = Impasse::Setting.find_by(:project_id => @project.id) params[:set_filter] = true params[:fields] ||= [] params[:fields] << 'tracker_id' @@ -32,7 +32,7 @@ def index :order => sort_clause, :offset => @offset, :limit => @limit) - @issue_count_by_group = @query.issue_count_by_group + @issue_count_by_group = @query.result_count_by_group render :index, :layout => !request.xhr? end @@ -42,7 +42,7 @@ def index def add_test_case ActiveRecord::Base.transaction do - requirement_issue = Impasse::RequirementIssue.find_by_issue_id(params[:issue_id]) || Impasse::RequirementIssue.create(:issue_id => params[:issue_id]) + requirement_issue = Impasse::RequirementIssue.find_by(:issue_id => params[:issue_id]) || Impasse::RequirementIssue.create(:issue_id => params[:issue_id]) node = Impasse::Node.find(params[:test_case_id]) if node.is_test_case? create_requirement_case(requirement_issue.id, node.id) @@ -59,7 +59,7 @@ def add_test_case def remove_test_case ActiveRecord::Base.transaction do requirement_issue = Impasse::RequirementIssue.find(params[:id]) - requirement_cases = requirement_issue.requirement_cases.find(:first, :conditions => { :test_case_id => params[:test_case_id] }) + requirement_cases = requirement_issue.requirement_cases.where(:test_case_id => params[:test_case_id]).first requirement_cases.destroy render :json => { :status => 'success', :message => l(:notice_successful_delete) } @@ -68,7 +68,7 @@ def remove_test_case private def create_requirement_case(requirement_id, test_case_id) - Impasse::RequirementCase.find_by_requirement_id_and_test_case_id(requirement_id, test_case_id) || Impasse::RequirementCase.create(:requirement_id => requirement_id, :test_case_id => test_case_id) + Impasse::RequirementCase.find_by(:requirement_id => requirement_id, :test_case_id => test_case_id) || Impasse::RequirementCase.create(:requirement_id => requirement_id, :test_case_id => test_case_id) end end diff --git a/app/controllers/impasse_settings_controller.rb b/app/controllers/impasse_settings_controller.rb index 0d4fe98..294bbec 100644 --- a/app/controllers/impasse_settings_controller.rb +++ b/app/controllers/impasse_settings_controller.rb @@ -1,18 +1,18 @@ class ImpasseSettingsController < ImpasseAbstractController unloadable - before_filter :find_project_by_project_id, :authorize + before_action :find_project_by_project_id, :authorize def index end def edit - @setting = Impasse::Setting.find_or_create_by_project_id(:project_id => @project.id) + @setting = Impasse::Setting.find_or_initialize_by(:project_id => @project.id) unless params[:setting][:requirement_tracker] params[:setting][:requirement_tracker] = [] end - @setting.attributes = params[:setting] - if request.put? or request.post? + @setting.update_attributes(params[:setting]) + if request.put? or request.post? or request.patch? ActiveRecord::Base.transaction do custom_fields_by_type = { 'Impasse::TestCaseCustomField' => [], @@ -30,7 +30,7 @@ def edit @project.execution_custom_fields = custom_fields_by_type['Impasse::ExecutionCustomField'] @setting.save! flash[:notice] = l(:notice_successful_update) - redirect_to :controller => '/projects', :action => 'settings', :id => @project, :tab => 'impasse' + redirect_to settings_project_path(@project, :tab => 'impasse') end end end diff --git a/app/controllers/impasse_test_case_controller.rb b/app/controllers/impasse_test_case_controller.rb index 8bf2432..691aac3 100644 --- a/app/controllers/impasse_test_case_controller.rb +++ b/app/controllers/impasse_test_case_controller.rb @@ -6,44 +6,52 @@ class ImpasseTestCaseController < ImpasseAbstractController helper :custom_fields include CustomFieldsHelper include ImpasseScreenshotsHelper + include ImpasseTestCaseHelper menu_item :impasse - before_filter :find_project, :authorize + before_action :find_project, :authorize def index if User.current.allowed_to?(:move_issues, @project) @allowed_projects = Issue.allowed_target_projects_on_move @allowed_projects.delete_if{|project| @project.id == project.id } end - @setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id) + @setting = Impasse::Setting.find_by(:project_id => @project) || Impasse::Setting.create(:project_id => @project.id) + respond_to do |format| + format.html { + } + format.csv {send_data(export_to_csv(), :type => 'text/csv; header=present', :filename => 'impasse_export.csv')} + end end def list - if params[:node_id].to_i == -1 - root = Impasse::Node.find_by_name_and_node_type_id(@project.identifier, 1) - @nodes = Impasse::Node.find_children(root.id, params[:test_plan_id], params[:filters]) - root.name = get_root_name(params[:test_plan_id]) + node_params = params.permit!.to_h + if node_params[:node_id].to_i == -1 + root = Impasse::Node.find_by(:name => @project.identifier, :node_type_id => 1) + @nodes = Impasse::Node.find_children(root.id, node_params[:test_plan_id], node_params[:filters]) + root.name = get_root_name(node_params[:test_plan_id]) @nodes.unshift(root) else - @nodes = Impasse::Node.find_children(params[:node_id], params[:test_plan_id], params[:filters]) + @nodes = Impasse::Node.find_children(node_params[:node_id], node_params[:test_plan_id], node_params[:filters]) end - jstree_nodes = convert(@nodes, params[:prefix]) + jstree_nodes = convert(@nodes, node_params[:prefix]) render :json => jstree_nodes end def show - @node, @test_case = get_node(params[:node]) - @setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id) + node_params = params.permit!.to_h + @node, @test_case = get_node(node_params[:node]) + @setting = Impasse::Setting.find_by(:project_id => @project) || Impasse::Setting.create(:project_id => @project.id) render :partial => 'show' end def new new_node - @setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id) + @setting = Impasse::Setting.find_by(:project_id => @project) || Impasse::Setting.create(:project_id => @project.id) - if request.post? or request.put? + if request.post? or request.put? or request.patch? begin ActiveRecord::Base.transaction do @node.save! @@ -54,6 +62,10 @@ def new @test_steps.each{|ts| raise ActiveRecord::RecordInvalid.new(ts) unless ts.valid? } @test_case.test_steps.replace(@test_steps) end + if params[:attachments] + attachments = Attachment.attach_files(@test_case, params[:attachments]) + create_thumbnail(attachments) if Object.const_defined?(:Magick) + end @test_case.save! render :json => { :status => 'success', :message => l(:notice_successful_create), :ids => [@test_case.id] } end @@ -75,8 +87,9 @@ def new end def copy + nodes_params = params.permit!.to_h nodes = [] - params[:nodes].each do |i,node_params| + nodes_params[:nodes].each do |i,node_params| ActiveRecord::Base.transaction do original_node = Impasse::Node.find(node_params[:original_id]) original_node[:node_order] = node_params[:node_order] @@ -90,10 +103,11 @@ def copy end def move + node_params = params.permit!.to_h nodes = [] - params[:nodes].each do |i,node_params| + node_params[:nodes].each do |i,nodes| ActiveRecord::Base.transaction do - node, test_case = get_node(node_params) + node, test_case = get_node(nodes) save_node(node) nodes << node end @@ -103,25 +117,26 @@ def move end def edit - @node, @test_case = get_node(params[:node]) - @test_case.attributes = params[:test_case] - @setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id) + node_params = params.permit!.to_h + @node, @test_case = get_node(node_params[:node]) + @test_case.update_attributes(node_params[:test_case]) if node_params.include? :test_case + @setting = Impasse::Setting.find_by(:project_id => @project) || Impasse::Setting.create(:project_id => @project.id) - if request.post? or request.put? + if request.post? or request.put? or request.patch? begin ActiveRecord::Base.transaction do save_node(@node) @test_case.save! - save_keywords(@node, params[:node_keywords]) + save_keywords(@node, 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) } + if @node.is_test_case? and node_params.include? :test_steps + @test_steps = node_params[:test_steps].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) end - if params[:attachments] - attachments = Attachment.attach_files(@test_case, params[:attachments]) + if node_params[:attachments] + attachments = Attachment.attach_files(@test_case, node_params[:attachments]) create_thumbnail(attachments) if Object.const_defined?(:Magick) end @@ -152,7 +167,7 @@ def destroy ActiveRecord::Base.transaction do node.all_decendant_cases_with_plan.each do |child| if child.planned? - Impasse::TestCase.update_all({:active => false}, ["id=?", child.id]) + Impasse::TestCase.where(:id => child.id).update_all(:active => false) inactive_cases << child else case child.node_type_id @@ -174,14 +189,15 @@ def destroy end def keywords - keywords = Impasse::Keyword.find_all_by_project_id(@project).map{|r| r.keyword} + keywords = Impasse::Keyword.where(:project_id => @project).map{|r| r.keyword} render :json => keywords end def copy_to_another_project + node_params = params.permit!.to_h copy_node_ids = [] - dest_project = Project.find(params[:dest_project_id]) - params[:node_ids].each do |id| + dest_project = Project.find(node_params[:dest_project_id]) + node_params[:node_ids].each do |id| nodes = Impasse::Node.find_with_children(id) for node in nodes copy_node_ids[node.level.to_i] ||= {} @@ -218,7 +234,7 @@ def copy_to_another_project ActiveRecord::Base.transaction do new_node = node.dup if new_node.node_type_id == 1 - root = Impasse::Node.find_by_name_and_node_type_id(dest_project.identifier, 1) + root = Impasse::Node.find_by(:name => dest_project.identifier, :node_type_id => 1) if root new_node = root # TODO get max node order @@ -238,7 +254,7 @@ def copy_to_another_project 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) + test_case = Impasse::TestCase.where(:id => node.id).includes(:test_steps).first new_test_case = test_case.dup new_test_case.id = new_node.id new_test_case.save! @@ -262,23 +278,24 @@ def copy_to_another_project private def new_node - @node = Impasse::Node.new(params[:node]) + node_params = params.permit!.to_h + @node = Impasse::Node.new(node_params[:node]) - case params[:node_type] + case node_params[:node_type] when 'test_case' - @test_case = Impasse::TestCase.new(params[:test_case]) + @test_case = Impasse::TestCase.new(node_params[:test_case]) @test_case.active = true @test_case.importance = 2 @node.node_type_id = 3 else - @test_case = Impasse::TestSuite.new(params[:test_case]) + @test_case = Impasse::TestSuite.new(node_params[:test_case]) @node.node_type_id = 2 end end def get_node(node_params) node = Impasse::Node.find(node_params[:id]) - node.attributes = node_params + node.update_attributes(node_params) if node.is_test_case? test_case = Impasse::TestCase.find(node_params[:id]) @@ -299,7 +316,7 @@ def save_node(node) end def save_keywords(node, keywords = "") - project_keywords = Impasse::Keyword.find_all_by_project_id(@project) + project_keywords = Impasse::Keyword.where(:project_id => @project) words = keywords.split(/\s*,\s*/) words.delete_if {|word| word =~ /^\s*$/}.uniq! @@ -338,7 +355,7 @@ def get_root_name(test_plan_id) def find_project begin @project = Project.find(params[:project_id]) - @project_node = Impasse::Node.find(:first, :conditions=>["name=? and node_type_id=?", @project.identifier, 1]) + @project_node = Impasse::Node.where(:name => @project.identifier, :node_type_id => 1).first if @project_node.nil? @project_node = Impasse::Node.new(:name=>@project.identifier, :node_type_id=>1, :node_order=>1) @project_node.save @@ -352,7 +369,7 @@ def copy_node(original_node, parent_id, level=0) node = original_node.dup if node.is_test_case? - original_case = Impasse::TestCase.find(original_node.id, :include => :test_steps) + original_case = Impasse::TestCase.where(:id => original_node.id).includes(:test_steps).first test_case = original_case.dup original_case.test_steps.each{|ts| test_case.test_steps << ts.dup } else diff --git a/app/controllers/impasse_test_plans_controller.rb b/app/controllers/impasse_test_plans_controller.rb index 8b5f96f..f147cb9 100644 --- a/app/controllers/impasse_test_plans_controller.rb +++ b/app/controllers/impasse_test_plans_controller.rb @@ -8,20 +8,23 @@ class ImpasseTestPlansController < ImpasseAbstractController include CustomFieldsHelper menu_item :impasse - before_filter :find_project_by_project_id, :authorize + before_action :find_project_by_project_id, :authorize def index - @test_plans_by_version, @versions = Impasse::TestPlan.find_all_by_version(@project, params[:completed]) + plan_params = params.permit!.to_h + @test_plans_by_version, @versions = Impasse::TestPlan.find_all_by_version(@project, plan_params[:completed]) end def show - @test_plan = Impasse::TestPlan.find(:first, :conditions => { :id => params[:id]}, :include => :version) - @setting = Impasse::Setting.find_by_project_id(@project) || Impasse::Setting.create(:project_id => @project.id) + plan_params = params.permit!.to_h + @test_plan = Impasse::TestPlan.where(:id => plan_params[:id]).includes(:version).first + @setting = Impasse::Setting.find_by(:project_id => @project) || Impasse::Setting.create(:project_id => @project.id) end def new - @test_plan = Impasse::TestPlan.new(params[:test_plan]) - if request.post? and @test_plan.save + plan_params = params.permit!.to_h + @test_plan = Impasse::TestPlan.new(plan_params[:test_plan]) + if (request.post? or request.patch?) and @test_plan.save flash[:notice] = l(:notice_successful_create) redirect_to :action => :tc_assign, :project_id => @project, :id => @test_plan end @@ -29,9 +32,10 @@ def new end def edit - @test_plan = Impasse::TestPlan.find(params[:id]) - @test_plan.attributes = params[:test_plan] - if (request.post? or request.put?) and @test_plan.save + plan_params = params.permit!.to_h + @test_plan = Impasse::TestPlan.find(plan_params[:id]) + @test_plan.update_attributes(plan_params[:test_plan]) if plan_params.include? :test_plan + if (request.post? or request.put? or request.patch?) and @test_plan.save flash[:notice] = l(:notice_successful_update) redirect_to :action => :show, :project_id => @project, :id => @test_plan end @@ -39,22 +43,24 @@ def edit end def destroy - @test_plan = Impasse::TestPlan.find(params[:id]) - if request.post? and @test_plan.destroy + plan_params = params.permit!.to_h + @test_plan = Impasse::TestPlan.find(plan_params[:id]) + if (request.post? or request.patch?) and @test_plan.destroy flash[:notice] = l(:notice_successful_delete) redirect_to :action => :index, :project_id => @project end end def copy - @test_plan = Impasse::TestPlan.find(params[:id]) - @test_plan.attributes = params[:test_plan] - if request.post? or request.put? + plan_params = params.permit!.to_h + @test_plan = Impasse::TestPlan.find(plan_params[:id]) + @test_plan.update_attributes(plan_params[:test_plan]) + if request.post? or request.put? or request.patch? ActiveRecord::Base.transaction do new_test_plan = @test_plan.dup new_test_plan.save! - test_plan_cases = Impasse::TestPlanCase.find_all_by_test_plan_id(params[:id]) + test_plan_cases = Impasse::TestPlanCase.find_all_by_test_plan_id(plan_params[:id]) for test_plan_case in test_plan_cases Impasse::TestPlanCase.create(:test_plan_id => new_test_plan.id, :test_case_id => test_plan_case.test_case_id) end @@ -100,7 +106,7 @@ def statistics def add_test_case if params.include? :test_case_ids new_cases = 0 - nodes = Impasse::Node.find(:all, :conditions => ["id in (?)", params[:test_case_ids]]) + nodes = Impasse::Node.where("id in (?)", params[:test_case_ids]) ActiveRecord::Base.transaction do for node in nodes test_case_ids = [] @@ -112,8 +118,7 @@ def add_test_case for test_case_id in test_case_ids test_plan_case = - Impasse::TestPlanCase.find_or_create_by_test_case_id_and_test_plan_id( - :test_case_id => test_case_id, + Impasse::TestPlanCase.find_or_create_by(:test_case_id => test_case_id, :test_plan_id => params[:test_plan_id], :node_order => 0) new_cases += 1 @@ -131,7 +136,7 @@ def remove_test_case end def autocomplete - @users = @project.users.like(params[:q]).all(:limit => 100) + @users = @project.users.like(params[:q]).limit(100) render :layout => false end end diff --git a/app/helpers/impasse_test_case_helper.rb b/app/helpers/impasse_test_case_helper.rb new file mode 100644 index 0000000..81f0181 --- /dev/null +++ b/app/helpers/impasse_test_case_helper.rb @@ -0,0 +1,190 @@ +require 'optparse' +module ImpasseTestCaseHelper + include ApplicationHelper + + #$FB : ruby class sheet to replace java FileSystemBookManager sheets + class Sheet + def initialize() + @header_indice = Hash.new + @header = Hash.new + @rows = Hash.new + @currRow = 0 + setRow(@currRow) + end + + def setHeaderAtIndice(indice, value) + i = 0 + while i < indice do + if !@header.has_key?(i) + @header[i] = "" + end + i+=1 + end + @header[indice] = value + @header_indice[value] = indice + end + + def headerIndice(value) + return @header_indice[value] + end + + def setRow(indice) + if indice.is_a? Integer + i = 0 + while i <= indice do + if !@rows.has_key?(i) + @rows[i] = Hash.new + end + i+=1 + end + @currRow = indice + end + end + + def nextRow + setRow(@currRow + 1) + end + + def setCellRowValue(indice, value) + if indice.is_a? Integer + i = 0 + while i < indice do + if !@rows[@currRow].has_key?(i) + @rows[@currRow][i] = "" + end + i+=1 + end + @rows[@currRow][indice] = value + end + end + + def save + csv_string = Redmine::Export::CSV.generate do |csv| + headerRow = Array.new + @header.sort.map do |rowkey, celvalue| + headerRow << celvalue + end + csv << headerRow + @rows.sort.map do |rowkey, rowvalue| + curRow = Array.new + rowvalue.sort.map do |celkey, celvalue| + curRow << celvalue + end + csv << curRow + end + end + # File.open(filename, "w+") do |f| + # f.write(csv_string) + # end + end + end + + + # Export Redmine Impasse test cases + def export_to_csv + project = @project + root = Impasse::Node.find_by_name_and_node_type_id(project[:identifier], 1) + #$FB test project existing + # raise "Project #{project} Not Found" unless root + puts "Browsing project #{project} tests..." + nodes = Impasse::Node.find_children(root.id) + nodes.unshift(root) + tree, depth = convert_node(nodes) + #$FB create simplier sheet + sheet = Sheet.new + #$FB my way to create colums header + sheet.setHeaderAtIndice(0, "Id") + sheet.setHeaderAtIndice(1, "Node_type_id") + sheet.setHeaderAtIndice(depth + 1, "Details") + sheet.setHeaderAtIndice(depth + 2, "Summary") + sheet.setHeaderAtIndice(depth + 3, "Preconditions") + sheet.setHeaderAtIndice(depth + 4, "Keywords") + sheet.setHeaderAtIndice(depth + 5, "Step") + sheet.setHeaderAtIndice(depth + 6, "Actions") + sheet.setHeaderAtIndice(depth + 7, "Expected results") + puts "Sheet header" + traverse(tree[0], 0, sheet) + puts "Traverse done" + #$FB my way to save a csv (and not an xlsx) + #manager.save(book) + + sheet.save + end + + def write_node(node, sheet) + if node[:node_type_id] == 2 + test_suite = Impasse::TestSuite.find(node[:id]) + #$FB my way to set a cell + #sheet.cell("Details").value = test_suite.details + sheet.setCellRowValue(sheet.headerIndice("Details"), test_suite.details) + elsif node[:node_type_id] == 3 + #test_case = Impasse::TestCase.find(:first, :conditions => ["id=?", node[:id]], :include => :test_steps) + test_case = Impasse::TestCase.where(:id => node[:id]).includes(:test_steps).first + #$FB my way to set a cell + #sheet.cell("Summary").value = test_case.summary + sheet.setCellRowValue(sheet.headerIndice("Summary"), test_case.summary) + #$FB my way to set a cell + #sheet.cell("Preconditions").value = test_case.preconditions + sheet.setCellRowValue(sheet.headerIndice("Preconditions"), test_case.preconditions) + test_case.test_steps.each_with_index do |step, i| + sheet.nextRow unless i == 0 + #sheet.cell("Step").value = step.actions + sheet.setCellRowValue(sheet.headerIndice("Step"), step.step_number) + #$FB my way to set a cell + #sheet.cell("Actions").value = step.actions + sheet.setCellRowValue(sheet.headerIndice("Actions"), step.actions) + #$FB my way to set a cell + #sheet.cell("Expected results").value = step.expected_results.to_s + sheet.setCellRowValue(sheet.headerIndice("Expected results"), step.expected_results.to_s) + end + end + sheet.nextRow + end + + def traverse(node, depth, sheet) + puts "Traversing level #{depth}" + #$FB my way to set a cell + #sheet.cell("Id").value = node[:id] + sheet.setCellRowValue(sheet.headerIndice("Id"), node[:id]) + #$FB my way to set a cell + #sheet.cell("Node type id").value = node[:node_type_id] + sheet.setCellRowValue(sheet.headerIndice("Node type id"), node[:node_type_id]) + #$FB my way to set a cell + #sheet.cell(2+depth).value = node[:name] + sheet.setCellRowValue(2+depth, node[:name]) + #$FB my way to set a cell + #sheet.cell("Keywords").value = node[:keywords] + sheet.setCellRowValue(sheet.headerIndice("Keywords"), node[:keywords]) + write_node(node, sheet) + (node[:children] || []).each do |child| + traverse(child, depth+1, sheet) + end + end + + def convert_node(nodes, prefix='node') + level = 1 + node_map = {} + jstree_nodes = [] + + for node in nodes + jstree_node = { + :id => node.id, + :node_type_id => node.node_type_id, + :name => node.name, + :keywords => node.keywords.map { |keyword| keyword.keyword }.join(","), + :children => [], + } + level = [node.level, level].max if node.respond_to? :level + node_map[node.id] = jstree_node + if node_map.include? node.parent_id + # non-root node + node_map[node.parent_id][:children] << jstree_node + else + #root node + jstree_nodes << jstree_node + end + end + [jstree_nodes, level] + end + +end diff --git a/app/models/impasse/execution.rb b/app/models/impasse/execution.rb index 9710c6c..4e02531 100644 --- a/app/models/impasse/execution.rb +++ b/app/models/impasse/execution.rb @@ -1,12 +1,15 @@ module Impasse class Execution < ActiveRecord::Base unloadable - set_table_name "impasse_executions" + self.table_name = "impasse_executions" self.include_root_in_json = false + + #attr_accessor :id, :status, :notes, :test_plan_case_id, :tester_id, :custom_field_values belongs_to :test_plan_case - has_many :issues, :through => :execution_bugs has_many :execution_bugs + has_many :issues, :through => :execution_bugs + #has_many :execution_bugs acts_as_customizable end diff --git a/app/models/impasse/execution_bug.rb b/app/models/impasse/execution_bug.rb index 9c93e0d..302c79f 100644 --- a/app/models/impasse/execution_bug.rb +++ b/app/models/impasse/execution_bug.rb @@ -1,9 +1,11 @@ module Impasse class ExecutionBug < ActiveRecord::Base unloadable - set_table_name "impasse_execution_bugs" + self.table_name = "impasse_execution_bugs" self.include_root_in_json = false + #attr_accessor :execution_id, :bug_id + belongs_to :issue, :foreign_key => :bug_id belongs_to :execution end diff --git a/app/models/impasse/execution_history.rb b/app/models/impasse/execution_history.rb index 9d5b60e..e70b18c 100644 --- a/app/models/impasse/execution_history.rb +++ b/app/models/impasse/execution_history.rb @@ -1,9 +1,11 @@ module Impasse class ExecutionHistory < ActiveRecord::Base unloadable - set_table_name "impasse_execution_histories" + self.table_name = "impasse_execution_histories" self.include_root_in_json = false + #attr_accessor :id, :test_plan_case_id, :tester_id, :build_id, :expected_date, :status, :execution_ts, :notes, :executor_id + belongs_to :test_plan_case belongs_to :executor, :class_name => "User" acts_as_customizable diff --git a/app/models/impasse/keyword.rb b/app/models/impasse/keyword.rb index c2057ca..6ef68fc 100644 --- a/app/models/impasse/keyword.rb +++ b/app/models/impasse/keyword.rb @@ -1,9 +1,11 @@ module Impasse class Keyword < ActiveRecord::Base unloadable - set_table_name "impasse_keywords" + self.table_name = "impasse_keywords" self.include_root_in_json = false + #attr_accessor :keyword, :project_id + belongs_to :project end end diff --git a/app/models/impasse/node.rb b/app/models/impasse/node.rb index 8aa3692..4f13f6e 100755 --- a/app/models/impasse/node.rb +++ b/app/models/impasse/node.rb @@ -1,9 +1,13 @@ module Impasse class Node < ActiveRecord::Base + #include Redmine::SafeAttributes + unloadable - set_table_name "impasse_nodes" + self.table_name = "impasse_nodes" self.include_root_in_json = false + #safe_attributes :id, :name, :node_type_id, :node_order, :parent_id + belongs_to :parent, :class_name=>'Node', :foreign_key=> :parent_id has_many :children, :class_name=> 'Node', :foreign_key=> :parent_id has_many :node_keywords, :class_name => "Impasse::NodeKeyword", :dependent => :delete_all @@ -38,11 +42,11 @@ def is_test_suite? end def active? - !attributes['active'] or attributes['active'].to_i == 1 or attributes['active'].is_a? TrueClass or attributes['active'] == 't' + !attributes['active'] or attributes['active'].is_a? TrueClass or attributes['active'].to_i == 1 or attributes['active'] == 't' end def planned? - attributes['planned'].to_i == 1 or attributes['planned'].is_a? TrueClass or attributes['planned'] == 't' + attributes['planned'].is_a? TrueClass or attributes['planned'].to_i == 1 or attributes['planned'] == 't' end def self.find_children(node_id, test_plan_id=nil, filters=nil, limit=300) @@ -101,7 +105,7 @@ def self.find_children(node_id, test_plan_id=nil, filters=nil, limit=300) unless node_id.to_i == -1 node = find(node_id) - child_counts = self.count(:conditions => [ "path like ?", "#{node.path}_%"]) + child_counts = self.where("path like ?", "#{node.path}_%").count if child_counts > limit conditions[:level] = node.path.count('.') + 1 end @@ -171,13 +175,13 @@ def self.find_planned(node_id, test_plan_id=nil, filters={}, limit=300) unless node_id.to_i == -1 node = self.find(node_id) - child_counts = self.count(:conditions => [ "path like ?", "#{node.path}_%"]) + child_counts = self.where("path like ?", "#{node.path}_%").count if child_counts > limit conditions[:level] = node.path.count('.') + 1 end conditions[:path] = "#{node.path}_%" else - child_counts = Impasse::TestPlanCase.count(:conditions => [ "test_plan_id=?", test_plan_id]) + child_counts = Impasse::TestPlanCase.where(:test_plan_id => test_plan_id).count if child_counts > limit conditions[:level] = 3 end @@ -265,9 +269,7 @@ def save end def update_siblings_order! - siblings = Node.find(:all, - :conditions=>["parent_id=? and id != ?", self.parent_id, self.id], - :order=>:node_order) + siblings = Node.where("parent_id=? and id != ?", self.parent_id, self.id).order(:node_order).to_a if self.node_order < siblings.size siblings.insert(self.node_order, self) else @@ -291,7 +293,7 @@ def update_child_nodes_path(old_path) WHERE path like '#{old_path}_%' END_OF_SQL - connection.update(sql) + ActiveRecord::Base.connection.update(sql) end private diff --git a/app/models/impasse/node_keyword.rb b/app/models/impasse/node_keyword.rb index dbd2a4e..af8ce21 100644 --- a/app/models/impasse/node_keyword.rb +++ b/app/models/impasse/node_keyword.rb @@ -1,9 +1,11 @@ module Impasse class NodeKeyword < ActiveRecord::Base unloadable - set_table_name "impasse_node_keywords" + self.table_name = "impasse_node_keywords" self.include_root_in_json = false + #attr_accessor :keyword, :project_id, :keyword_id, :node_id + belongs_to :node belongs_to :keyword end diff --git a/app/models/impasse/node_type.rb b/app/models/impasse/node_type.rb index 841521e..131257f 100755 --- a/app/models/impasse/node_type.rb +++ b/app/models/impasse/node_type.rb @@ -1,7 +1,7 @@ module Impasse class NodeType < ActiveRecord::Base unloadable - set_table_name "impasse_node_types" + self.table_name = "impasse_node_types" self.include_root_in_json = false end end diff --git a/app/models/impasse/requirement_case.rb b/app/models/impasse/requirement_case.rb index c2b4c13..ddeb2d1 100644 --- a/app/models/impasse/requirement_case.rb +++ b/app/models/impasse/requirement_case.rb @@ -1,7 +1,9 @@ module Impasse class RequirementCase < ActiveRecord::Base unloadable - set_table_name "impasse_requirement_cases" + self.table_name = "impasse_requirement_cases" + + #attr_accessor :requirement_id, :test_case_id belongs_to :test_case belongs_to :requirement_issue, :foreign_key => "requirement_id" diff --git a/app/models/impasse/requirement_issue.rb b/app/models/impasse/requirement_issue.rb index 3ee765e..a79fc51 100644 --- a/app/models/impasse/requirement_issue.rb +++ b/app/models/impasse/requirement_issue.rb @@ -1,7 +1,9 @@ module Impasse class RequirementIssue < ActiveRecord::Base unloadable - set_table_name "impasse_requirement_issues" + self.table_name = "impasse_requirement_issues" + + #attr_accessor :issue_id belongs_to :issue has_many :requirement_cases, :foreign_key => "requirement_id" diff --git a/app/models/impasse/requirement_stats.rb b/app/models/impasse/requirement_stats.rb index 16fc3fb..bf1e361 100644 --- a/app/models/impasse/requirement_stats.rb +++ b/app/models/impasse/requirement_stats.rb @@ -1,6 +1,8 @@ module Impasse class RequirementStats < ActiveRecord::Base unloadable + #dummy table + self.table_name = "impasse_requirement_stats" def self.columns @columns ||= []; diff --git a/app/models/impasse/setting.rb b/app/models/impasse/setting.rb index c2c24a5..c76ee90 100644 --- a/app/models/impasse/setting.rb +++ b/app/models/impasse/setting.rb @@ -1,7 +1,9 @@ module Impasse class Setting < ActiveRecord::Base unloadable - set_table_name "impasse_settings" + self.table_name = "impasse_settings" + + #attr_accessor :project_id, :bug_tracker_id, :requirement_tracker serialize :requirement_tracker diff --git a/app/models/impasse/statistics.rb b/app/models/impasse/statistics.rb index 81cfde5..a6bff5f 100644 --- a/app/models/impasse/statistics.rb +++ b/app/models/impasse/statistics.rb @@ -1,7 +1,7 @@ module Impasse class Statistics < ActiveRecord::Base unloadable - set_table_name 'impasse_test_plans' + self.table_name = 'impasse_test_plans' self.include_root_in_json = false def self.summary_default(test_plan_id, test_suite_id=nil) @@ -91,7 +91,7 @@ def self.summary_default(test_plan_id, test_suite_id=nil) def self.summary_members(test_plan_id, test_suite_id=nil) sql = <<-END_OF_SQL -SELECT users.id, users.login, users.mail, users.firstname, users.lastname, stat.* +SELECT users.id, users.login, users.firstname, users.lastname, stat.* FROM ( SELECT exe.tester_id, diff --git a/app/models/impasse/test_case.rb b/app/models/impasse/test_case.rb index f9bedc6..868b661 100755 --- a/app/models/impasse/test_case.rb +++ b/app/models/impasse/test_case.rb @@ -1,22 +1,26 @@ module Impasse class TestCase < ActiveRecord::Base + #include Redmine::SafeAttributes + unloadable - set_table_name "impasse_test_cases" + self.table_name = "impasse_test_cases" self.include_root_in_json = false + #attr_accessor :id, :summary, :preconditions, :importance + has_many :test_steps, :dependent=>:destroy belongs_to :node, :foreign_key=>"id" has_many :requirement_cases has_many :requirement_issues, :through => :requirement_cases acts_as_customizable - acts_as_attachable :view_permission => :view_files, - :delete_permission => :manage_files + acts_as_attachable :view_permission => :view_testcases, + :delete_permission => :manage_testcases def project root_id = node.path.split(/\./)[1].to_i root = Impasse::Node.find(root_id) - Project.find_by_identifier(root.name) + Project.find_by(:identifier => root.name) end if Rails::VERSION::MAJOR < 3 or (Rails::VERSION::MAJOR == 3 and Rails::VERSION::MINOR < 1) diff --git a/app/models/impasse/test_plan.rb b/app/models/impasse/test_plan.rb index 91dfae8..ff7e16c 100755 --- a/app/models/impasse/test_plan.rb +++ b/app/models/impasse/test_plan.rb @@ -1,9 +1,11 @@ module Impasse class TestPlan < ActiveRecord::Base unloadable - set_table_name "impasse_test_plans" + self.table_name = "impasse_test_plans" self.include_root_in_json = false + #attr_accessor :name, :notes, :version_id + has_many :test_plan_cases has_many :test_cases, :through => :test_plan_cases belongs_to :version @@ -22,14 +24,14 @@ def self.find_all_by_version(project, show_closed = false) test_plans_by_version = {} versions.each do |version| - test_plans = TestPlan.find(:all, :conditions => ["version_id=?", version.id]) + test_plans = TestPlan.where(:version_id => version.id).all test_plans_by_version[version] = test_plans end [test_plans_by_version, versions] end def setting - @setting = Impasse::Setting.find_by_project_id(version.project.id) + @setting = Impasse::Setting.find_by(:project_id => version.project.id) end def related_requirements diff --git a/app/models/impasse/test_plan_case.rb b/app/models/impasse/test_plan_case.rb index 9a535ae..32ad35c 100755 --- a/app/models/impasse/test_plan_case.rb +++ b/app/models/impasse/test_plan_case.rb @@ -1,9 +1,11 @@ module Impasse class TestPlanCase < ActiveRecord::Base unloadable - set_table_name "impasse_test_plan_cases" + self.table_name = "impasse_test_plan_cases" self.include_root_in_json = false + #attr_accessor :test_case_id, :test_plan_id, :node_order + belongs_to :test_plan belongs_to :test_case has_many :executions diff --git a/app/models/impasse/test_step.rb b/app/models/impasse/test_step.rb index c77273f..e923df8 100755 --- a/app/models/impasse/test_step.rb +++ b/app/models/impasse/test_step.rb @@ -1,7 +1,9 @@ module Impasse class TestStep < ActiveRecord::Base unloadable - set_table_name "impasse_test_steps" + self.table_name = "impasse_test_steps" + + #attr_accessor :actions, :step_number, :expected_results belongs_to :test_case diff --git a/app/models/impasse/test_suite.rb b/app/models/impasse/test_suite.rb index 2631c71..93443c7 100755 --- a/app/models/impasse/test_suite.rb +++ b/app/models/impasse/test_suite.rb @@ -1,9 +1,11 @@ module Impasse class TestSuite < ActiveRecord::Base unloadable - set_table_name "impasse_test_suites" + self.table_name = "impasse_test_suites" self.include_root_in_json = false + #attr_accessor :details + belongs_to :node, :foreign_key => :id acts_as_customizable diff --git a/app/views/impasse_custom_fields/_index.html.erb b/app/views/impasse_custom_fields/_index.html.erb index 5c8a257..b5d3c29 100644 --- a/app/views/impasse_custom_fields/_index.html.erb +++ b/app/views/impasse_custom_fields/_index.html.erb @@ -12,9 +12,9 @@ <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%> - "> + <%= link_to h(custom_field.name), { :action => :edit, :id => custom_field } %> - <%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %> + <%= l(Redmine::FieldFormat.find(custom_field.field_format).label) %> <%= checked_image custom_field.is_required? %> <% if tab[:name] == 'IssueCustomField' %> <%= checked_image custom_field.is_for_all? %> @@ -28,7 +28,7 @@ :class => 'icon icon-del') %> - <% end; reset_cycle %> + <% end %> diff --git a/app/views/impasse_custom_fields/edit.html.erb b/app/views/impasse_custom_fields/edit.html.erb index 4b6a20d..361ec0e 100644 --- a/app/views/impasse_custom_fields/edit.html.erb +++ b/app/views/impasse_custom_fields/edit.html.erb @@ -3,7 +3,7 @@ » <%= h @custom_field.name %> <% if Rails::VERSION::MAJOR < 3 %> - <% labelled_tabular_form_for :custom_field, @custom_field, { :action => :edit, :id => @custom_field } do |f| %> + <% labelled_form_for :custom_field, @custom_field, { :action => :edit, :id => @custom_field } do |f| %> <%= render :partial => "custom_fields/form", :locals => {:f => f} %> <%= hidden_field_tag 'type', @custom_field.type %> <%= submit_tag l(:button_save) %> diff --git a/app/views/impasse_custom_fields/new.html.erb b/app/views/impasse_custom_fields/new.html.erb index 9ab4a24..8035fdf 100644 --- a/app/views/impasse_custom_fields/new.html.erb +++ b/app/views/impasse_custom_fields/new.html.erb @@ -3,7 +3,7 @@ » <%= l(:label_custom_field_new) %> <% if Rails::VERSION::MAJOR < 3 %> - <% labelled_tabular_form_for :custom_field, @custom_field, {} do |f| %> + <% labelled_form_for :custom_field, @custom_field, {} do |f| %> <%= render :partial => "custom_fields/form", :locals => {:f => f} %> <%= hidden_field_tag 'type', @custom_field.type %> <%= submit_tag l(:button_create) %> diff --git a/app/views/impasse_execution_bugs/_form.html.erb b/app/views/impasse_execution_bugs/_form.html.erb index b351403..8196227 100644 --- a/app/views/impasse_execution_bugs/_form.html.erb +++ b/app/views/impasse_execution_bugs/_form.html.erb @@ -1,35 +1,55 @@ +<%= labelled_fields_for :issue, @issue do |f| %> <%= call_hook(:view_issues_form_details_top, { :issue => @issue, :form => f }) %> +<%= hidden_field_tag 'form_update_triggered_by', '' %> +<%= hidden_field_tag 'back_url', params[:back_url], :id => nil if params[:back_url].present? %> -
> -<% if Rails::VERSION::MAJOR < 3 %> -

<%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %>

- <%= observe_field :issue_tracker_id, :url => { :action => :new, :project_id => @project, :id => @issue }, - :update => :attributes, - :with => "Form.serialize('issue-form')" %> -<% else %> -

<%= f.select :tracker_id, @issue.project.trackers.collect {|t| [t.name, t.id]}, {:required => true}, - :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %>

+<% if @issue.safe_attribute? 'is_private' %> +

+ <%= f.check_box :is_private, :no_label => true %> +

<% end %> -

<%= f.text_field :subject, :size => 80, :required => true %>

+<% projects = @issue.allowed_target_projects(User.current, @project) %> +<% if (@issue.safe_attribute?('project_id') || @issue.project_id_changed?) && (@project.nil? || projects.length > 1 || @issue.copy?) %> +

<%= f.select :project_id, project_tree_options_for_select(projects, :selected => @issue.project), {:required => true}, + :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %>

+<% end %> -<% if User.current.allowed_to?(:manage_subtasks, @project) %> -

<%= f.text_field :parent_issue_id, :size => 10 %>

-
- <% if Redmine::VERSION::MAJOR < 2 or Redmine::VERSION::MINOR < 1 %> - <%= javascript_tag "observeParentIssueField('#{auto_complete_issues_path(:id => @issue, :project_id => @project) }')" %> - <% else %> - <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project)}')" %> - <% end %> +<% if @issue.safe_attribute?('tracker_id') || (@issue.persisted? && @issue.tracker_id_changed?) %> +

<%= f.select :tracker_id, trackers_options_for_select(@issue), {:required => true}, + :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %>

+<% end %> + +<% if @issue.safe_attribute? 'subject' %> +

<%= f.text_field :subject, :size => 80, :maxlength => 255, :required => true %>

<% end %> -

<%= f.text_area :description, +<% if @issue.safe_attribute? 'description' %> +

+ <%= f.label_for_field :description, :required => @issue.required_attribute?('description') %> + <%= content_tag 'span', :id => "issue_description_and_toolbar", :style => (@issue.new_record? ? nil : 'display:none') do %> + <%= f.text_area :description, :cols => 60, - :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min), + :rows => [[10, @issue.description.to_s.length / 50].max, 20].min, :accesskey => accesskey(:edit), - :class => 'wiki-edit' %>

-
+ :class => 'wiki-edit', + :no_label => true %> + <% end %> +

+<% end %>
- <%= render :partial => 'issues/attributes' %> + <%= render :partial => 'issues/attributes' %>
+ +<% end %> + +<% heads_for_wiki_formatter %> + +<%= javascript_tag do %> +$(document).ready(function(){ + $("#issue_tracker_id, #issue_status_id").each(function(){ + $(this).val($(this).find("option[selected=selected]").val()); + }); +}); +<% end %> diff --git a/app/views/impasse_execution_bugs/_new.html.erb b/app/views/impasse_execution_bugs/_new.html.erb index d0afa7a..39e1f60 100644 --- a/app/views/impasse_execution_bugs/_new.html.erb +++ b/app/views/impasse_execution_bugs/_new.html.erb @@ -1,31 +1,44 @@
-<% if Rails::VERSION::MAJOR < 3 %> - <% labelled_tabular_form_for :issue, @issue, :url => {:controller => 'issues', :action => 'create', :project_id => @project}, - :html => {:multipart => true, :id => 'issue-form', :class => 'tabular new-issue-form'} do |f| %> - <%= error_messages_for 'issue' %> - <%= render :partial => 'form', :locals => {:f => f} %> - <% end %> -<% else %> - <% output = labelled_form_for @issue, - :url => {:controller => 'issues', :action => 'create', :project_id => @project}, - :as => :issue, - :html => {:multipart => true, :id => 'issue-form', :class => 'tabular new-issue-form'} do |f| %> - <%= error_messages_for 'issue' %> +<%= call_hook(:view_issues_new_top, {:issue => @issue}) %> + +<%= labelled_form_for @issue, :url => _project_issues_path(@project), + :html => {:id => 'issue-form', :multipart => true} do |f| %> + <%= error_messages_for 'issue' %> + <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %> +
+
<%= render :partial => 'form', :locals => {:f => f} %> - <% end %> - <%= output %> -<% end %> +
+ + <% if @copy_from && Setting.link_copied_issue == 'ask' %> +

+ + <%= check_box_tag 'link_copy', '1', @link_copy %> +

+ <% end %> + <% if @copy_from && @copy_from.attachments.any? %> +

+ + <%= check_box_tag 'copy_attachments', '1', @copy_attachments %> +

+ <% end %> + <% if @copy_from && !@copy_from.leaf? %> +

+ + <%= check_box_tag 'copy_subtasks', '1', @copy_subtasks %> +

+ <% end %> -
-<%= hidden_field_tag "authenticity_token", form_authenticity_token %> - -

<%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %>

-
- -
+

<%= render :partial => 'attachments/form', :locals => {:container => @issue} %>

+ +
+ <%= render :partial => 'issues/watchers_form' %> +
+
+ + +<% end %> - -
<% content_for :header_tags do %> - <%= stylesheet_link_tag 'scm' %> + <%= robot_exclusion_tag %> <% end %> diff --git a/app/views/impasse_executions/_edit.html.erb b/app/views/impasse_executions/_edit.html.erb index c7e5a70..8b14bda 100644 --- a/app/views/impasse_executions/_edit.html.erb +++ b/app/views/impasse_executions/_edit.html.erb @@ -1,5 +1,5 @@ <% if Rails::VERSION::MAJOR < 3 %> - <% labelled_tabular_form_for :execution, @execution, {} do |f| %> + <% labelled_form_for :execution, @execution, {} do |f| %> <%= render :partial => "form", :locals => { :f => f } %> <% end %> <% else %> diff --git a/app/views/impasse_executions/index.html.erb b/app/views/impasse_executions/index.html.erb index 5f8e156..b3adab4 100755 --- a/app/views/impasse_executions/index.html.erb +++ b/app/views/impasse_executions/index.html.erb @@ -86,7 +86,7 @@ <%= l(:field_expected_date) %> - <%= text_field_tag 'expected_date' %><%= calendar_for('expected_date') %> + <%= date_field_tag 'expected_date' %><%= calendar_for('expected_date') %> "/> + "/>

<% @test_case.custom_field_values.each do |value| %> -

<%= custom_field_tag_with_label :test_case, value %>

+

<%= custom_field_tag_with_label :test_case, value %>

<% end %>
+
- <%=l(:button_add)%> + <%= l(:button_add) %>
- <%= render :partial => "impasse_screenshots/list", :locals => { :attachments => @test_case.attachments, :mode => :edit } %> + <%= render :partial => "impasse_screenshots/list", :locals => {:attachments => @test_case.attachments, :mode => :edit} %>
- - - - - - - - - - - - - <% @test_case.test_steps.each_with_index do |test_step, i| %> - - - - - - - <% end %> - -
#<%=l(:field_actions)%><%=l(:field_expected_results)%>
<%=h test_step.step_number %><%=text_area_tag "test_steps[#{i+1}][actions]", test_step.actions, :rows=>3, :style=>'width:100%' %> - <%= hidden_field_tag "test_steps[#{i+1}][step_number]", test_step.step_number %> - <%= hidden_field_tag "test_steps[#{i+1}][id]", test_step.id %> - <%=text_area_tag "test_steps[#{i+1}][expected_results]", test_step.expected_results, :rows=>3, :style=>'width:100%' %>
+ + + + + + + + + + + + + + <% @test_case.test_steps.each_with_index do |test_step, i| %> + + + + + + + <% end %> + +
#<%= l(:field_actions) %><%= l(:field_expected_results) %>
<%= h test_step.step_number %><%= text_area_tag "test_steps[#{i+1}][actions]", test_step.actions, :rows => 3, :style => 'width:100%' %> + <%= hidden_field_tag "test_steps[#{i+1}][step_number]", test_step.step_number %> + <%= hidden_field_tag "test_steps[#{i+1}][id]", test_step.id %> + <%= text_area_tag "test_steps[#{i+1}][expected_results]", test_step.expected_results, :rows => 3, :style => 'width:100%' %>
<% if @setting.can_manage_requirements? and @test_case.requirement_issues.size > 0 %> -
- - - - - - - - - - <% for requirement in @test_case.requirement_issues %> - <% issue = requirement.issue %> - - - - - - - <% end %> - -
#<%=l(:field_tracker)%><%=l(:field_subject)%>
- <%= link_to h(issue.id), :controller => 'issues', :action => 'show', :id => issue %> - <%=h issue.tracker %> - <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>) - <%= link_to( - image_tag('link_break.png'), { - :controller => 'impasse_requirement_issues', :action => 'remove_test_case', :id => requirement.id, - :test_case_id => @test_case.id, :project_id => @project}, - :class => "remove_requirement" - - ) %>
-
+
+ + + + + + + + + + <% for requirement in @test_case.requirement_issues %> + <% issue = requirement.issue %> + + + + + + + <% end %> + +
#<%= l(:field_tracker) %><%= l(:field_subject) %>
+ <%= link_to h(issue.id), :controller => 'issues', :action => 'show', :id => issue %> + <%= h issue.tracker %> + <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> + (<%= h issue.status %>) + <%= link_to( + image_tag('link_break.png'), { + :controller => 'impasse_requirement_issues', :action => 'remove_test_case', :id => requirement.id, + :test_case_id => @test_case.id, :project_id => @project}, + :class => "remove_requirement" + + ) %>
+
<% end %>
<% unless @test_case.active %> -

<%= form.check_box :active %>

+

<%= form.check_box :active %>

<% end %>
diff --git a/app/views/impasse_test_case/_new.html.erb b/app/views/impasse_test_case/_new.html.erb index 22f563b..91694e1 100644 --- a/app/views/impasse_test_case/_new.html.erb +++ b/app/views/impasse_test_case/_new.html.erb @@ -1,5 +1,5 @@ <% if Rails::VERSION::MAJOR < 3 %> - <% labelled_tabular_form_for :test_case, @test_case, {} do |f| %> + <% labelled_form_for :test_case, @test_case, {} do |f| %> <%= render :partial => "form.#{params[:node_type]}", :locals => {:form => f} %> diff --git a/app/views/impasse_test_case/_show.html.erb b/app/views/impasse_test_case/_show.html.erb index 83d51e5..28a0e93 100644 --- a/app/views/impasse_test_case/_show.html.erb +++ b/app/views/impasse_test_case/_show.html.erb @@ -1,83 +1,85 @@
- - + + <% unless @node.keywords.empty? %> - - - - + + + + <% end %> <% @test_case.visible_custom_field_values.each do |custom_value| %> - <% if !custom_value.value.blank? %> - - - - - <% end %> + <% if !custom_value.value.blank? %> + + + + + <% end %> <% end %>
<%=l(:field_name)%><%=h @node.name %><%= l(:field_name) %><%= h @node.name %>
<%=l(:field_keywords)%><%=h @node.keywords.map{|k| k.keyword }.join(",") %>
<%= l(:field_keywords) %><%= h @node.keywords.map { |k| k.keyword }.join(",") %>
<%=h custom_value.custom_field.name %><%=h show_value(custom_value) %>
<%= h custom_value.custom_field.name %><%= h show_value(custom_value) %>
- + <% if @test_case.summary? %> -

<%=l(:field_summary)%>

-
- <%= textilizable @test_case, :summary %> -
+

<%= l(:field_summary) %>

+ +
+ <%= textilizable @test_case, :summary %> +
<% end %> <% if @test_case.preconditions? %> -

<%=l(:field_preconditions)%>

- <%= textilizable @test_case, :preconditions %> +

<%= l(:field_preconditions) %>

+ <%= textilizable @test_case, :preconditions %> <% end %> <% if @test_case.attachments.size > 0 %> -

<%=l(:label_screenshots)%>

- <%= render :partial => "impasse_screenshots/list", :locals => { :attachments => @test_case.attachments } %> +

<%= l(:label_screenshots) %>

+ <%= render :partial => "impasse_screenshots/list", :locals => {:attachments => @test_case.attachments} %> <% end %>
- <% if @test_case.test_steps.size > 0 %> -

<%=l(:field_test_steps)%>

- - - - - - - <% @test_case.test_steps.each do |test_step| %> - - - - - - <% end %> -
#<%=l(:field_actions)%><%=l(:field_expected_results)%>
<%= test_step.step_number %><%=h test_step.actions %><%=h test_step.expected_results %>
+ <% if @test_case.test_steps.size > 0 %> +

<%= l(:field_test_steps) %>

+ + + + + + + <% @test_case.test_steps.each_with_index do |test_step, i| %> + + + + + + <% end %> +
#<%= l(:field_actions) %><%= l(:field_expected_results) %>
<%= simple_format(h(test_step.step_number)) %><%= simple_format(h(test_step.actions)) %><%= simple_format(h(test_step.expected_results)) %>
<% end %> <% if @setting.can_manage_requirements? and @test_case.requirement_issues.size > 0 %> -

<%=l(:label_requirement_plural) %>

- - - - - - - - <% for requirement in @test_case.requirement_issues %> - <% issue = requirement.issue %> - - - - - - <% end %> - -
#<%=l(:field_tracker)%><%=l(:field_subject)%>
- <%= link_to h(issue.id), :controller => 'issues', :action => 'show', :id => issue %> - <%=h issue.tracker %> - <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>) -
+

<%= l(:label_requirement_plural) %>

+ + + + + + + + <% for requirement in @test_case.requirement_issues %> + <% issue = requirement.issue %> + + + + + + <% end %> + +
#<%= l(:field_tracker) %><%= l(:field_subject) %>
+ <%= link_to h(issue.id), :controller => 'issues', :action => 'show', :id => issue %> + <%= h issue.tracker %> + <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> + (<%= h issue.status %>) +
<% end %>
diff --git a/app/views/impasse_test_case/index.html.erb b/app/views/impasse_test_case/index.html.erb index 1ba1df8..4fd6942 100644 --- a/app/views/impasse_test_case/index.html.erb +++ b/app/views/impasse_test_case/index.html.erb @@ -2,15 +2,15 @@ <%= stylesheet_link_tag 'jquery-ui', 'jquery.noty.css', 'noty_theme_twitter.css', 'jquery.Jcrop.min.css', 'impasse', :plugin => 'redmine_impasse' %> <% heads_for_wiki_formatter %> <%= javascript_include_tag( - 'jquery', 'jquery-ui', 'jquery.cookie.js', 'jquery.color.js', 'jquery.Jcrop.js', - 'jquery.hotkeys.js', 'jquery.jstree.js', 'jquery.blockUI.js', 'jquery.noty.js', - 'impasse_util', 'test_case_tree', 'screenshots', - :plugin => 'redmine_impasse') %> + 'jquery', 'jquery-ui', 'jquery.cookie.js', 'jquery.color.js', 'jquery.Jcrop.js', + 'jquery.hotkeys.js', 'jquery.jstree.js', 'jquery.blockUI.js', 'jquery.noty.js', + 'impasse_util', 'test_case_tree', 'screenshots', + :plugin => 'redmine_impasse') %>