Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from avvo/suite_names
Browse files Browse the repository at this point in the history
Fix suite naming defaults and display
  • Loading branch information
sringling authored Apr 14, 2017
2 parents fa525e4 + 141340e commit 8db786f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
16 changes: 10 additions & 6 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ def process_suites
suites = s3Wrapper.suite_name_list(name)
puts "suites #{suites}"

suites.each do |suite_name|
Suite.find_or_create_by(project: self, name: suite_name)
if suites.present?
suites.each do |suite_name|
Suite.find_or_create_by!(project: self, name: suite_name)
end
else
Suite.find_or_create_by!(project: self, name: Suite::DEFAULT_NAME)
end

end

def process_builds_and_pull_results
Expand Down Expand Up @@ -78,12 +83,11 @@ def create_build(build_number)

def suite_from_filename(filename:)
suite_name = s3Wrapper.parse_suite_name(name, filename)
suites = Suite.where(project: self, name: suite_name)
suites.first
Suite.find_by(project: self, name: suite_name || Suite::DEFAULT_NAME)
end

def process_junit_file(temp_filename:, build:, suite: )
p "processing build #{build.number} for project: #{name}"
p "processing a file for build #{build.number} for project: #{name}"
junit_suite = JUnitParser.parse_junit(temp_filename)

if junit_suite.present?
Expand All @@ -94,7 +98,7 @@ def process_junit_file(temp_filename:, build:, suite: )
def process_junit_suite(junit_suite:, build_id:, suite:)
junit_suite.test_cases.each do |test_case|

test = Testcase.find_or_create_by(
test = Testcase.find_or_create_by!(
name: test_case.name,
file_name: test_case.file,
project: self,
Expand Down
2 changes: 1 addition & 1 deletion app/models/s3_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def parse_suite_name(project_name, filepath)
full_project.slice!('/')
suite_name = full_project.chomp('/')

suite_name
suite_name.present? ? suite_name : nil
end

def parse_build_number(filepath)
Expand Down
3 changes: 3 additions & 0 deletions app/models/suite.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class Suite < ApplicationRecord

DEFAULT_NAME = 'default'

belongs_to :project
has_many :testcases, dependent: :destroy

Expand Down
6 changes: 5 additions & 1 deletion app/presenters/suite_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ def initialize(suite)
end

def name
@suite.name.split("=")[1].split(",")[0]
if @suite.name.include?('=')
@suite.name.split("=")[1].split(",")[0]
else
@suite.name
end
end

def duration_in_seconds(build)
Expand Down
3 changes: 2 additions & 1 deletion app/views/projects/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ table.table.condensed-table.table-bordered
tr
th [colspan=3]
- @suites.each do |suite|
- suite_presenter = SuitePresenter.new(suite)
th
div.rotate
span
= suite.name
= suite_presenter.name
tr
th status
th
Expand Down
4 changes: 3 additions & 1 deletion app/views/suites/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- suite_presenter = SuitePresenter.new(@suite)

h1
= @suite.name
= suite_presenter.name

p
| Project:
Expand Down
2 changes: 1 addition & 1 deletion app/views/testcases/_run_table.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ table.table.condensed-table.table-bordered
td
= link_to run.testcase.name, testcase_path(run.testcase)
td
= link_to run.testcase.suite.name, suite_path(run.testcase.suite)
= link_to SuitePresenter.new(run.testcase.suite).name, suite_path(run.testcase.suite)
td
- if run.skipped?
= 'SKIPPED'
Expand Down

0 comments on commit 8db786f

Please sign in to comment.