Skip to content

Commit

Permalink
Use WorkflowRun#formatted_event_source_name
Browse files Browse the repository at this point in the history
The method is going to be used in the component and other parts of the
code, so the definition has been moved to the model.

Co-authored-by: Eduardo Navarro <enavarro@suse.com>
  • Loading branch information
saraycp and eduardoj committed Oct 25, 2023
1 parent f5a6ffd commit 363e05b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/api/app/components/workflow_run_row_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class WorkflowRunRowComponent < ApplicationComponent
attr_reader :workflow_run, :status, :hook_event, :hook_action, :repository_name, :repository_url, :event_source_name, :event_source_url
attr_reader :workflow_run, :status, :hook_event, :hook_action, :repository_name, :repository_url, :event_source_name, :event_source_url, :formatted_event_source_name

def initialize(workflow_run:)
super
Expand All @@ -12,15 +12,7 @@ def initialize(workflow_run:)
@repository_url = workflow_run.repository_url
@event_source_name = workflow_run.event_source_name
@event_source_url = workflow_run.event_source_url
end

def formatted_event_source_name
case hook_event
when 'pull_request', 'Merge Request Hook'
"##{event_source_name}"
else
event_source_name
end
@formatted_event_source_name = workflow_run.formatted_event_source_name

Check warning on line 15 in src/api/app/components/workflow_run_row_component.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/components/workflow_run_row_component.rb#L15

Added line #L15 was not covered by tests
end

def status_title
Expand Down

0 comments on commit 363e05b

Please sign in to comment.