Module: OnlyofficeTestrailWrapper::TestrailProjectPlanHelper
- Extended by:
- Gem::Deprecate
- Included in:
- TestrailProject
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb
Overview
Mehtods to help working with Plan in Project
Instance Method Summary collapse
- #create_new_plan(name, entries = [], description = '', milestone_id = nil) ⇒ Object
- #get_plan_by_id(id) ⇒ Object
- #get_plan_by_name(name) ⇒ Object
-
#get_plans(filters = {}) ⇒ Array<Hash>
Get list of all TestPlans.
- #init_plan_by_name(name) ⇒ Object
- #plan(name_or_id) ⇒ Object
-
#plan_by_name(name) ⇒ TestrailPlan?
Result of plan search.
-
#plans(filters = {}) ⇒ Array<TestrailPlan>
Get list of all TestPlans.
Instance Method Details
#create_new_plan(name, entries = [], description = '', milestone_id = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 75 def create_new_plan(name, entries = [], description = '', milestone_id = nil) new_plan = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_plan/#{@id}", name: StringHelper.warnstrip!(name), description: description, milestone_id: milestone_id, entries: entries), TestrailPlan) OnlyofficeLoggerHelper.log "Created new plan: #{new_plan.name}" new_plan.entries.each_with_index do |entry, i| new_plan.entries[i] = HashHelper.parse_to_class_variable(entry, TestrailPlanEntry) new_plan.entries[i].runs.each_with_index { |run, j| new_plan.entries[i].runs[j] = HashHelper.parse_to_class_variable(run, TestrailRun) } end @plans_names[new_plan.name] = new_plan.id new_plan end |
#get_plan_by_id(id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 22 def get_plan_by_id(id) plan = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_plan/#{id}"), TestrailPlan) OnlyofficeLoggerHelper.log("Initialized plan: #{plan.name}") plan.entries.each_with_index do |test_entry, index| entry = HashHelper.parse_to_class_variable(test_entry, TestrailPlanEntry) entry.runs.each_with_index { |run, i| entry.runs[i] = HashHelper.parse_to_class_variable(run, TestrailRun) } plan.entries[index] = entry end plan.instance_variable_set '@project', self plan end |
#get_plan_by_name(name) ⇒ Object
34 35 36 37 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 34 def get_plan_by_name(name) get_plans if @plans_names.empty? @plans_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_plan_by_id(@plans_names[name]) end |
#get_plans(filters = {}) ⇒ Array<Hash>
Get list of all TestPlans
51 52 53 54 55 56 57 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 51 def get_plans(filters = {}) get_url = "index.php?/api/v2/get_plans/#{@id}" filters.each { |key, value| get_url += "&#{key}=#{value}" } plans = Testrail2.http_get(get_url) @plans_names = HashHelper.get_hash_from_array_with_two_parameters(plans, 'name', 'id') if @plans_names.empty? plans end |
#init_plan_by_name(name) ⇒ Object
17 18 19 20 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 17 def init_plan_by_name(name) found_plan = get_plan_by_name name found_plan.nil? ? create_new_plan(name) : found_plan end |
#plan(name_or_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 6 def plan(name_or_id) case name_or_id.class.to_s when 'Fixnum' get_plan_by_id name_or_id when 'String' init_plan_by_name name_or_id else raise 'Wrong argument. Must be name [String] or id [Integer]' end end |
#plan_by_name(name) ⇒ TestrailPlan?
Returns result of plan search.
44 45 46 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 44 def plan_by_name(name) plans.find { |plan| plan.name == name } end |
#plans(filters = {}) ⇒ Array<TestrailPlan>
Get list of all TestPlans
65 66 67 68 69 70 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb', line 65 def plans(filters = {}) get_url = "index.php?/api/v2/get_plans/#{@id}" filters.each { |key, value| get_url += "&#{key}=#{value}" } plans = Testrail2.http_get(get_url) plans.map { |suite| HashHelper.parse_to_class_variable(suite, TestrailPlan) } end |